diff options
Diffstat (limited to 'packages/libndsfpc')
149 files changed, 16298 insertions, 0 deletions
diff --git a/packages/libndsfpc/Makefile b/packages/libndsfpc/Makefile new file mode 100644 index 0000000000..43930974ee --- /dev/null +++ b/packages/libndsfpc/Makefile @@ -0,0 +1,2065 @@ +# +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/01/26] +# +default: all +MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded +BSDs = freebsd netbsd openbsd darwin +UNIXs = linux $(BSDs) solaris qnx +LIMIT83fs = go32v2 os2 emx watcom +OSNeedsComspecToRunBatch = go32v2 watcom +FORCE: +.PHONY: FORCE +override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH))) +ifneq ($(findstring darwin,$(OSTYPE)),) +inUnix=1 #darwin +SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH))) +else +ifeq ($(findstring ;,$(PATH)),) +inUnix=1 +SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH))) +else +SEARCHPATH:=$(subst ;, ,$(PATH)) +endif +endif +SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE)))) +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH)))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH)))) +ifeq ($(PWD),) +$(error You need the GNU utils package to use this Makefile) +else +PWD:=$(firstword $(PWD)) +SRCEXEEXT= +endif +else +PWD:=$(firstword $(PWD)) +SRCEXEEXT=.exe +endif +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +else +ifneq ($(findstring cygdrive,$(PATH)),) +inCygWin=1 +endif +endif +ifdef inUnix +SRCBATCHEXT=.sh +else +ifdef inOS2 +SRCBATCHEXT=.cmd +else +SRCBATCHEXT=.bat +endif +endif +ifdef COMSPEC +ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),) +RUNBATCH=$(COMSPEC) /C +endif +endif +ifdef inUnix +PATHSEP=/ +else +PATHSEP:=$(subst /,\,/) +ifdef inCygWin +PATHSEP=/ +endif +endif +ifdef PWD +BASEDIR:=$(subst \,/,$(shell $(PWD))) +ifdef inCygWin +ifneq ($(findstring /cygdrive/,$(BASEDIR)),) +BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR)) +BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR))) +BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR)) +endif +endif +else +BASEDIR=. +endif +ifdef inOS2 +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO=echo +else +ECHO:=$(firstword $(ECHO)) +endif +else +ECHO:=$(firstword $(ECHO)) +endif +endif +export ECHO +endif +override OS_TARGET_DEFAULT=nds +override CPU_TARGET_DEFAULT=arm +override DEFAULT_FPCDIR=../.. +ifndef FPC +ifdef PP +FPC=$(PP) +endif +endif +ifndef FPC +FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH)))) +ifneq ($(FPCPROG),) +FPCPROG:=$(firstword $(FPCPROG)) +ifneq ($(CPU_TARGET),) +FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB) +else +FPC:=$(shell $(FPCPROG) -PB) +endif +ifneq ($(findstring Error,$(FPC)),) +override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH))))) +endif +else +override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH))))) +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) +FOUNDFPC:=$(strip $(wildcard $(FPC))) +ifeq ($(FOUNDFPC),) +FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))) +ifeq ($(FOUNDFPC),) +$(error Compiler $(FPC) not found) +endif +endif +ifndef FPC_COMPILERINFO +FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO) +endif +ifndef FPC_VERSION +FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO)) +endif +export FPC FPC_VERSION FPC_COMPILERINFO +unexport CHECKDEPEND ALLDEPENDENCIES +ifndef CPU_TARGET +ifdef CPU_TARGET_DEFAULT +CPU_TARGET=$(CPU_TARGET_DEFAULT) +endif +endif +ifndef OS_TARGET +ifdef OS_TARGET_DEFAULT +OS_TARGET=$(OS_TARGET_DEFAULT) +endif +endif +ifneq ($(words $(FPC_COMPILERINFO)),5) +FPC_COMPILERINFO+=$(shell $(FPC) -iSP) +FPC_COMPILERINFO+=$(shell $(FPC) -iTP) +FPC_COMPILERINFO+=$(shell $(FPC) -iSO) +FPC_COMPILERINFO+=$(shell $(FPC) -iTO) +endif +ifndef CPU_SOURCE +CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO)) +endif +ifndef CPU_TARGET +CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO)) +endif +ifndef OS_SOURCE +OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO)) +endif +ifndef OS_TARGET +OS_TARGET:=$(word 5,$(FPC_COMPILERINFO)) +endif +FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET) +FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE) +ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) +TARGETSUFFIX=$(OS_TARGET) +SOURCESUFFIX=$(OS_SOURCE) +else +TARGETSUFFIX=$(FULL_TARGET) +SOURCESUFFIX=$(FULL_SOURCE) +endif +ifneq ($(FULL_TARGET),$(FULL_SOURCE)) +CROSSCOMPILE=1 +endif +ifeq ($(findstring makefile,$(MAKECMDGOALS)),) +ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),) +$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first) +endif +endif +ifneq ($(findstring $(OS_TARGET),$(BSDs)),) +BSDhier=1 +endif +ifeq ($(OS_TARGET),linux) +linuxHier=1 +endif +export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=wrong +endif +else +override FPCDIR=wrong +endif +ifdef DEFAULT_FPCDIR +ifeq ($(FPCDIR),wrong) +override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR)) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=wrong +endif +endif +endif +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR:=$(BASEDIR) +ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +ifndef CROSSBINDIR +CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX)) +endif +ifndef BINUTILSPREFIX +ifndef CROSSBINDIR +ifdef CROSSCOMPILE +BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)- +endif +endif +endif +UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX)) +ifeq ($(UNITSDIR),) +UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET)) +endif +PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra) +override PACKAGE_NAME=libndsfpc +override PACKAGE_VERSION=0.1 +ifeq ($(FULL_TARGET),i386-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-win32) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-os2) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-beos) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-solaris) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-qnx) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-netware) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-darwin) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-emx) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-watcom) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-wince) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),i386-symbian) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-atari) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),sparc-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-palmos) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-wince) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-gba) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-nds) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),arm-symbian) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +endif +override INSTALL_FPCPACKAGE=y +ifeq ($(FULL_TARGET),i386-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-win32) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-os2) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-beos) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-solaris) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-qnx) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-netware) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-darwin) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-emx) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-watcom) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-wince) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-symbian) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-atari) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),sparc-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-palmos) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-wince) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-gba) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-nds) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),arm-symbian) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/libmikmod +endif +ifeq ($(FULL_TARGET),i386-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-go32v2) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-win32) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-os2) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-beos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-solaris) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-qnx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netware) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-openbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-wdosx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-emx) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-watcom) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-netwlibc) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-wince) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),i386-symbian) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-amiga) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-atari) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-openbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-palmos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),m68k-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-amiga) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-macos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-morphos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-netbsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-solaris) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),sparc-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-freebsd) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-win64) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),x86_64-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-palmos) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-wince) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-gba) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-nds) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),arm-symbian) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-linux) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-darwin) +override COMPILER_SOURCEDIR+=src tests +endif +ifeq ($(FULL_TARGET),powerpc64-embedded) +override COMPILER_SOURCEDIR+=src tests +endif +ifdef REQUIRE_UNITSDIR +override UNITSDIR+=$(REQUIRE_UNITSDIR) +endif +ifdef REQUIRE_PACKAGESDIR +override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR) +endif +ifdef ZIPINSTALL +ifneq ($(findstring $(OS_TARGET),$(UNIXs)),) +UNIXHier=1 +endif +else +ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),) +UNIXHier=1 +endif +endif +ifndef INSTALL_PREFIX +ifdef PREFIX +INSTALL_PREFIX=$(PREFIX) +endif +endif +ifndef INSTALL_PREFIX +ifdef UNIXHier +INSTALL_PREFIX=/usr/local +else +ifdef INSTALL_FPCPACKAGE +INSTALL_BASEDIR:=/pp +else +INSTALL_BASEDIR:=/$(PACKAGE_NAME) +endif +endif +endif +export INSTALL_PREFIX +ifdef INSTALL_FPCSUBDIR +export INSTALL_FPCSUBDIR +endif +ifndef DIST_DESTDIR +DIST_DESTDIR:=$(BASEDIR) +endif +export DIST_DESTDIR +ifndef COMPILER_UNITTARGETDIR +ifdef PACKAGEDIR_MAIN +COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX) +else +COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX) +endif +endif +ifndef COMPILER_TARGETDIR +COMPILER_TARGETDIR=. +endif +ifndef INSTALL_BASEDIR +ifdef UNIXHier +ifdef INSTALL_FPCPACKAGE +INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION) +else +INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME) +endif +else +INSTALL_BASEDIR:=$(INSTALL_PREFIX) +endif +endif +ifndef INSTALL_BINDIR +ifdef UNIXHier +INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin +else +INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin +ifdef INSTALL_FPCPACKAGE +ifdef CROSSCOMPILE +ifdef CROSSINSTALL +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX) +else +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX) +endif +else +INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX) +endif +endif +endif +endif +ifndef INSTALL_UNITDIR +INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX) +ifdef INSTALL_FPCPACKAGE +ifdef PACKAGE_NAME +INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME) +endif +endif +endif +ifndef INSTALL_LIBDIR +ifdef UNIXHier +INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib +else +INSTALL_LIBDIR:=$(INSTALL_UNITDIR) +endif +endif +ifndef INSTALL_SOURCEDIR +ifdef UNIXHier +ifdef BSDhier +SRCPREFIXDIR=share/src +else +ifdef linuxHier +SRCPREFIXDIR=share/src +else +SRCPREFIXDIR=src +endif +endif +ifdef INSTALL_FPCPACKAGE +ifdef INSTALL_FPCSUBDIR +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME) +else +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +endif +else +INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +else +ifdef INSTALL_FPCPACKAGE +ifdef INSTALL_FPCSUBDIR +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME) +else +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME) +endif +else +INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source +endif +endif +endif +ifndef INSTALL_DOCDIR +ifdef UNIXHier +ifdef BSDhier +DOCPREFIXDIR=share/doc +else +ifdef linuxHier +DOCPREFIXDIR=share/doc +else +DOCPREFIXDIR=doc +endif +endif +ifdef INSTALL_FPCPACKAGE +INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +else +INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +else +ifdef INSTALL_FPCPACKAGE +INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME) +else +INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc +endif +endif +endif +ifndef INSTALL_EXAMPLEDIR +ifdef UNIXHier +ifdef INSTALL_FPCPACKAGE +ifdef BSDhier +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME) +else +ifdef linuxHier +INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples +else +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME) +endif +endif +else +ifdef BSDhier +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +else +ifdef linuxHier +INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +else +INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +endif +endif +endif +else +ifdef INSTALL_FPCPACKAGE +INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME) +else +INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples +endif +endif +endif +ifndef INSTALL_DATADIR +INSTALL_DATADIR=$(INSTALL_BASEDIR) +endif +ifndef INSTALL_SHAREDDIR +INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib +endif +ifdef CROSSCOMPILE +ifndef CROSSBINDIR +CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX)) +ifeq ($(CROSSBINDIR),) +CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE)) +endif +endif +else +CROSSBINDIR= +endif +BATCHEXT=.bat +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +SHAREDLIBPREFIX=libfp +STATICLIBPREFIX=libp +IMPORTLIBPREFIX=libimp +RSTEXT=.rst +ifeq ($(findstring 1.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),go32v1) +STATICLIBPREFIX= +SHORTSUFFIX=v1 +endif +ifeq ($(OS_TARGET),go32v2) +STATICLIBPREFIX= +SHORTSUFFIX=dos +endif +ifeq ($(OS_TARGET),watcom) +STATICLIBPREFIX= +OEXT=.obj +ASMEXT=.asm +SHAREDLIBEXT=.dll +SHORTSUFFIX=wat +endif +ifeq ($(OS_TARGET),linux) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=lnx +endif +ifeq ($(OS_TARGET),freebsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=fbs +endif +ifeq ($(OS_TARGET),netbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=nbs +endif +ifeq ($(OS_TARGET),openbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=obs +endif +ifeq ($(OS_TARGET),win32) +SHAREDLIBEXT=.dll +SHORTSUFFIX=w32 +endif +ifeq ($(OS_TARGET),os2) +BATCHEXT=.cmd +AOUTEXT=.out +STATICLIBPREFIX= +SHAREDLIBEXT=.dll +SHORTSUFFIX=os2 +ECHO=echo +endif +ifeq ($(OS_TARGET),emx) +BATCHEXT=.cmd +AOUTEXT=.out +STATICLIBPREFIX= +SHAREDLIBEXT=.dll +SHORTSUFFIX=emx +ECHO=echo +endif +ifeq ($(OS_TARGET),amiga) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=amg +endif +ifeq ($(OS_TARGET),morphos) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=mos +endif +ifeq ($(OS_TARGET),atari) +EXEEXT=.ttp +SHORTSUFFIX=ata +endif +ifeq ($(OS_TARGET),beos) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=be +endif +ifeq ($(OS_TARGET),solaris) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=sun +endif +ifeq ($(OS_TARGET),qnx) +BATCHEXT=.sh +EXEEXT= +SHORTSUFFIX=qnx +endif +ifeq ($(OS_TARGET),netware) +EXEEXT=.nlm +STATICLIBPREFIX= +SHORTSUFFIX=nw +endif +ifeq ($(OS_TARGET),netwlibc) +EXEEXT=.nlm +STATICLIBPREFIX= +SHORTSUFFIX=nwl +endif +ifeq ($(OS_TARGET),macos) +BATCHEXT= +EXEEXT= +DEBUGSYMEXT=.xcoff +SHORTSUFFIX=mac +endif +ifeq ($(OS_TARGET),darwin) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=dwn +endif +ifeq ($(OS_TARGET),gba) +EXEEXT=.gba +SHAREDLIBEXT=.so +SHORTSUFFIX=gba +endif +ifeq ($(OS_TARGET),symbian) +SHAREDLIBEXT=.dll +SHORTSUFFIX=symbian +endif +else +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +STATICLIBPREFIX= +SHORTSUFFIX=v1 +endif +ifeq ($(OS_TARGET),go32v2) +STATICLIBPREFIX= +SHORTSUFFIX=dos +endif +ifeq ($(OS_TARGET),watcom) +STATICLIBPREFIX= +SHORTSUFFIX=wat +endif +ifeq ($(OS_TARGET),linux) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=lnx +endif +ifeq ($(OS_TARGET),freebsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=fbs +endif +ifeq ($(OS_TARGET),netbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=nbs +endif +ifeq ($(OS_TARGET),openbsd) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=obs +endif +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +SHORTSUFFIX=w32 +endif +ifeq ($(OS_TARGET),os2) +BATCHEXT=.cmd +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +AOUTEXT=.out +SMARTEXT=.sl2 +STATICLIBPREFIX= +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +SHORTSUFFIX=os2 +ECHO=echo +endif +ifeq ($(OS_TARGET),amiga) +EXEEXT= +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.library +SHORTSUFFIX=amg +endif +ifeq ($(OS_TARGET),atari) +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT=.ttp +SHORTSUFFIX=ata +endif +ifeq ($(OS_TARGET),beos) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=be +endif +ifeq ($(OS_TARGET),solaris) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=sun +endif +ifeq ($(OS_TARGET),qnx) +BATCHEXT=.sh +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +SHORTSUFFIX=qnx +endif +ifeq ($(OS_TARGET),netware) +STATICLIBPREFIX= +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.nlm +EXEEXT=.nlm +SHORTSUFFIX=nw +endif +ifeq ($(OS_TARGET),netwlibc) +STATICLIBPREFIX= +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.nlm +EXEEXT=.nlm +SHORTSUFFIX=nwl +endif +ifeq ($(OS_TARGET),macos) +BATCHEXT= +PPUEXT=.ppu +ASMEXT=.s +OEXT=.o +SMARTEXT=.sl +STATICLIBEXT=.a +EXEEXT= +DEBUGSYMEXT=.xcoff +SHORTSUFFIX=mac +endif +endif +ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) +FPCMADE=fpcmade.$(SHORTSUFFIX) +ZIPSUFFIX=$(SHORTSUFFIX) +ZIPCROSSPREFIX= +ZIPSOURCESUFFIX=src +ZIPEXAMPLESUFFIX=exm +else +FPCMADE=fpcmade.$(TARGETSUFFIX) +ZIPSOURCESUFFIX=.source +ZIPEXAMPLESUFFIX=.examples +ifdef CROSSCOMPILE +ZIPSUFFIX=.$(SOURCESUFFIX) +ZIPCROSSPREFIX=$(TARGETSUFFIX)- +else +ZIPSUFFIX=.$(TARGETSUFFIX) +ZIPCROSSPREFIX= +endif +endif +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO= __missing_command_ECHO +else +ECHO:=$(firstword $(ECHO)) +endif +else +ECHO:=$(firstword $(ECHO)) +endif +endif +export ECHO +ifndef DATE +DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(DATE),) +DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(DATE),) +DATE= __missing_command_DATE +else +DATE:=$(firstword $(DATE)) +endif +else +DATE:=$(firstword $(DATE)) +endif +endif +export DATE +ifndef GINSTALL +GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(GINSTALL),) +GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(GINSTALL),) +GINSTALL= __missing_command_GINSTALL +else +GINSTALL:=$(firstword $(GINSTALL)) +endif +else +GINSTALL:=$(firstword $(GINSTALL)) +endif +endif +export GINSTALL +ifndef CPPROG +CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(CPPROG),) +CPPROG= __missing_command_CPPROG +else +CPPROG:=$(firstword $(CPPROG)) +endif +endif +export CPPROG +ifndef RMPROG +RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(RMPROG),) +RMPROG= __missing_command_RMPROG +else +RMPROG:=$(firstword $(RMPROG)) +endif +endif +export RMPROG +ifndef MVPROG +MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MVPROG),) +MVPROG= __missing_command_MVPROG +else +MVPROG:=$(firstword $(MVPROG)) +endif +endif +export MVPROG +ifndef MKDIRPROG +MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MKDIRPROG),) +MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(MKDIRPROG),) +MKDIRPROG= __missing_command_MKDIRPROG +else +MKDIRPROG:=$(firstword $(MKDIRPROG)) +endif +else +MKDIRPROG:=$(firstword $(MKDIRPROG)) +endif +endif +export MKDIRPROG +ifndef ECHOREDIR +ifndef inUnix +ECHOREDIR=echo +else +ECHOREDIR=$(ECHO) +endif +endif +ifndef COPY +COPY:=$(CPPROG) -fp +endif +ifndef COPYTREE +COPYTREE:=$(CPPROG) -Rfp +endif +ifndef MKDIRTREE +MKDIRTREE:=$(MKDIRPROG) -p +endif +ifndef MOVE +MOVE:=$(MVPROG) -f +endif +ifndef DEL +DEL:=$(RMPROG) -f +endif +ifndef DELTREE +DELTREE:=$(RMPROG) -rf +endif +ifndef INSTALL +ifdef inUnix +INSTALL:=$(GINSTALL) -c -m 644 +else +INSTALL:=$(COPY) +endif +endif +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=$(GINSTALL) -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif +ifndef MKDIR +MKDIR:=$(GINSTALL) -m 755 -d +endif +export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= __missing_command_PPUMOVE +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE +ifndef FPCMAKE +FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(FPCMAKE),) +FPCMAKE= __missing_command_FPCMAKE +else +FPCMAKE:=$(firstword $(FPCMAKE)) +endif +endif +export FPCMAKE +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= __missing_command_ZIPPROG +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= __missing_command_TARPROG +else +TARPROG:=$(firstword $(TARPROG)) +endif +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG +ASNAME=$(BINUTILSPREFIX)as +LDNAME=$(BINUTILSPREFIX)ld +ARNAME=$(BINUTILSPREFIX)ar +RCNAME=$(BINUTILSPREFIX)rc +ifneq ($(findstring 1.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),win32) +ifeq ($(CROSSBINDIR),) +ASNAME=asw +LDNAME=ldw +ARNAME=arw +endif +endif +endif +ifndef ASPROG +ifdef CROSSBINDIR +ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT) +else +ASPROG=$(ASNAME) +endif +endif +ifndef LDPROG +ifdef CROSSBINDIR +LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT) +else +LDPROG=$(LDNAME) +endif +endif +ifndef RCPROG +ifdef CROSSBINDIR +RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT) +else +RCPROG=$(RCNAME) +endif +endif +ifndef ARPROG +ifdef CROSSBINDIR +ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT) +else +ARPROG=$(ARNAME) +endif +endif +AS=$(ASPROG) +LD=$(LDPROG) +RC=$(RCPROG) +AR=$(ARPROG) +PPAS=ppas$(SRCBATCHEXT) +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif +ifdef DATE +DATESTR:=$(shell $(DATE) +%Y%m%d) +else +DATESTR= +endif +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG +ZIPOPT=-9 +ZIPEXT=.zip +ifeq ($(USETAR),bz2) +TAROPT=vj +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif +ifndef NOCPUDEF +override FPCOPTDEF=$(CPU_TARGET) +endif +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif +ifneq ($(CPU_TARGET),$(CPU_SOURCE)) +override FPCOPT+=-P$(CPU_TARGET) +endif +ifeq ($(OS_SOURCE),openbsd) +override FPCOPT+=-FD$(NEW_BINUTILS_PATH) +endif +ifndef CROSSBOOTSTRAP +ifneq ($(BINUTILSPREFIX),) +override FPCOPT+=-XP$(BINUTILSPREFIX) +endif +ifneq ($(BINUTILSPREFIX),) +override FPCOPT+=-Xr$(RLINKPATH) +endif +endif +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif +ifdef LINKSMART +override FPCOPT+=-XX +endif +ifdef CREATESMART +override FPCOPT+=-CX +endif +ifdef DEBUG +override FPCOPT+=-gl +override FPCOPTDEF+=DEBUG +endif +ifdef RELEASE +ifneq ($(findstring 2.0.,$(FPC_VERSION)),) +ifeq ($(CPU_TARGET),i386) +FPCCPUOPT:=-OG2p3 +endif +ifeq ($(CPU_TARGET),powerpc) +FPCCPUOPT:=-O1r +endif +else +FPCCPUOPT:=-O2 +endif +override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n +override FPCOPTDEF+=RELEASE +endif +ifdef STRIP +override FPCOPT+=-Xs +endif +ifdef OPTIMIZE +override FPCOPT+=-O2 +endif +ifdef VERBOSE +override FPCOPT+=-vwni +endif +ifdef COMPILER_OPTIONS +override FPCOPT+=$(COMPILER_OPTIONS) +endif +ifdef COMPILER_UNITDIR +override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR)) +endif +ifdef COMPILER_LIBRARYDIR +override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR)) +endif +ifdef COMPILER_OBJECTDIR +override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR)) +endif +ifdef COMPILER_INCLUDEDIR +override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR)) +endif +ifdef CROSSBINDIR +override FPCOPT+=-FD$(CROSSBINDIR) +endif +ifdef COMPILER_TARGETDIR +override FPCOPT+=-FE$(COMPILER_TARGETDIR) +ifeq ($(COMPILER_TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/ +endif +endif +ifdef COMPILER_UNITTARGETDIR +override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR) +ifeq ($(COMPILER_UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/ +endif +else +ifdef COMPILER_TARGETDIR +override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif +ifdef CREATESHARED +override FPCOPT+=-Cg +ifeq ($(CPU_TARGET),i386) +override FPCOPT+=-Aas +endif +endif +ifeq ($(findstring 2.0.,$(FPC_VERSION)),) +ifeq ($(OS_TARGET),linux) +ifeq ($(CPU_TARGET),x86_64) +override FPCOPT+=-Cg +endif +endif +endif +ifdef LINKSHARED +endif +ifdef OPT +override FPCOPT+=$(OPT) +endif +ifdef FPCOPTDEF +override FPCOPT+=$(addprefix -d,$(FPCOPTDEF)) +endif +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif +ifdef USEENV +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif +override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET) +override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE) +ifneq ($(AFULL_TARGET),$(AFULL_SOURCE)) +override ACROSSCOMPILE=1 +endif +ifdef ACROSSCOMPILE +override FPCOPT+=$(CROSSOPT) +endif +override COMPILER:=$(FPC) $(FPCOPT) +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(FULL_SOURCE),$(FULL_TARGET)) +ifdef RUNBATCH +EXECPPAS:=@$(RUNBATCH) $(PPAS) +else +EXECPPAS:=@$(PPAS) +endif +endif +endif +.PHONY: fpc_units +ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),) +override ALLTARGET+=fpc_units +override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS)) +override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS)) +override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES) +override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES) +endif +fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES) +ifdef TARGET_RSTS +override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS)) +override CLEANRSTFILES+=$(RSTFILES) +endif +.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared +$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET) + @$(ECHOREDIR) Compiled > $(FPCMADE) +fpc_all: $(FPCMADE) +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 +fpc_debug: + $(MAKE) all DEBUG=1 +fpc_release: + $(MAKE) all RELEASE=1 +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res +$(COMPILER_UNITTARGETDIR): + $(MKDIRTREE) $(COMPILER_UNITTARGETDIR) +$(COMPILER_TARGETDIR): + $(MKDIRTREE) $(COMPILER_TARGETDIR) +%$(PPUEXT): %.pp + $(COMPILER) $< + $(EXECPPAS) +%$(PPUEXT): %.pas + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.pp + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.pas + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.lpr + $(COMPILER) $< + $(EXECPPAS) +%$(EXEEXT): %.dpr + $(COMPILER) $< + $(EXECPPAS) +%.res: %.rc + windres -i $< -o $@ +vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR) +vpath %.inc $(COMPILER_INCLUDEDIR) +vpath %$(OEXT) $(COMPILER_UNITTARGETDIR) +vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR) +.PHONY: fpc_shared +override INSTALLTARGET+=fpc_shared_install +ifndef SHARED_LIBVERSION +SHARED_LIBVERSION=$(FPC_VERSION) +endif +ifndef SHARED_LIBNAME +SHARED_LIBNAME=$(PACKAGE_NAME) +endif +ifndef SHARED_FULLNAME +SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT) +endif +ifndef SHARED_LIBUNITS +SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS) +override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS)) +endif +fpc_shared: +ifdef HASSHAREDLIB + $(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1 +ifneq ($(SHARED_BUILD),n) + $(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR) +endif +else + @$(ECHO) Shared Libraries not supported +endif +fpc_shared_install: +ifneq ($(SHARED_BUILD),n) +ifneq ($(SHARED_LIBUNITS),) +ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),) + $(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR) +endif +endif +endif +.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall +ifdef INSTALL_UNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS)) +endif +ifdef INSTALL_BUILDUNIT +override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES)) +endif +ifdef INSTALLPPUFILES +override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) +ifneq ($(UNITTARGETDIRPREFIX),) +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES))) +override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES)))) +endif +override INSTALL_CREATEPACKAGEFPC=1 +endif +ifdef INSTALLEXEFILES +ifneq ($(TARGETDIRPREFIX),) +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES))) +endif +endif +fpc_install: all $(INSTALLTARGET) +ifdef INSTALLEXEFILES + $(MKDIR) $(INSTALL_BINDIR) +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR) +endif +ifdef INSTALL_CREATEPACKAGEFPC +ifdef FPCMAKE +ifdef PACKAGE_VERSION +ifneq ($(wildcard Makefile.fpc),) + $(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc + $(MKDIR) $(INSTALL_UNITDIR) + $(INSTALL) Package.fpc $(INSTALL_UNITDIR) +endif +endif +endif +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(INSTALL_UNITDIR) + $(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR) +endif +ifneq ($(wildcard $(LIB_FULLNAME)),) + $(MKDIR) $(INSTALL_LIBDIR) + $(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR) +ifdef inUnix + ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME) +endif +endif +endif +ifdef INSTALL_FILES + $(MKDIR) $(INSTALL_DATADIR) + $(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR) +endif +fpc_sourceinstall: distclean + $(MKDIR) $(INSTALL_SOURCEDIR) + $(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR) +fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS)) +ifdef HASEXAMPLES + $(MKDIR) $(INSTALL_EXAMPLEDIR) +endif +ifdef EXAMPLESOURCEFILES + $(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR) +endif +ifdef TARGET_EXAMPLEDIRS + $(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR) +endif +.PHONY: fpc_distinstall +fpc_distinstall: install exampleinstall +.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/../fpc-pack +else +PACKDIR=/tmp/fpc-pack +endif +endif +ifndef ZIPNAME +ifdef DIST_ZIPNAME +ZIPNAME=$(DIST_ZIPNAME) +else +ZIPNAME=$(PACKAGE_NAME) +endif +endif +ifndef FULLZIPNAME +FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX) +endif +ifndef ZIPTARGET +ifdef DIST_ZIPTARGET +ZIPTARGET=DIST_ZIPTARGET +else +ZIPTARGET=install +endif +endif +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif +ifndef inUnix +USEZIPWRAPPER=1 +endif +ifdef USEZIPWRAPPER +ZIPPATHSEP=$(PATHSEP) +ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT)) +else +ZIPPATHSEP=/ +endif +ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR)) +ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR)) +ifdef USETAR +ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT) +ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) * +else +ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT) +ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) * +endif +fpc_zipinstall: + $(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1 + $(MKDIR) $(DIST_DESTDIR) + $(DEL) $(ZIPDESTFILE) +ifdef USEZIPWRAPPER +ifneq ($(ECHOREDIR),echo) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER) + $(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER) +else + echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER) + echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER) + echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER) +endif +ifdef inUnix + /bin/sh $(ZIPWRAPPER) +else +ifdef RUNBATCH + $(RUNBATCH) (ZIPWRAPPER) +else + $(ZIPWRAPPER) +endif +endif + $(DEL) $(ZIPWRAPPER) +else + $(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE) +endif + $(DELTREE) $(PACKDIR) +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX) +fpc_zipexampleinstall: +ifdef HASEXAMPLES + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX) +endif +fpc_zipdistinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=distinstall +.PHONY: fpc_clean fpc_cleanall fpc_distclean +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif +ifdef CLEAN_UNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS)) +endif +ifdef CLEANPPUFILES +override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) +ifdef DEBUGSYMEXT +override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES)) +endif +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES))) +endif +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef CLEAN_FILES + -$(DEL) $(CLEAN_FILES) +endif +ifdef LIB_NAME + -$(DEL) $(LIB_NAME) $(LIB_FULLNAME) +endif + -$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT) +fpc_cleanall: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef COMPILER_UNITTARGETDIR +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +endif + -$(DELTREE) units + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) +ifneq ($(PPUEXT),.ppu) + -$(DEL) *.o *.ppu *.a +endif + -$(DELTREE) *$(SMARTEXT) + -$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) *_ppas$(BATCHEXT) +ifdef AOUTEXT + -$(DEL) *$(AOUTEXT) +endif +ifdef DEBUGSYMEXT + -$(DEL) *$(DEBUGSYMEXT) +endif +fpc_distclean: cleanall +.PHONY: fpc_baseinfo +override INFORULES+=fpc_baseinfo +fpc_baseinfo: + @$(ECHO) + @$(ECHO) == Package info == + @$(ECHO) Package Name..... $(PACKAGE_NAME) + @$(ECHO) Package Version.. $(PACKAGE_VERSION) + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC.......... $(FPC) + @$(ECHO) FPC Version.. $(FPC_VERSION) + @$(ECHO) Source CPU... $(CPU_SOURCE) + @$(ECHO) Target CPU... $(CPU_TARGET) + @$(ECHO) Source OS.... $(OS_SOURCE) + @$(ECHO) Target OS.... $(OS_TARGET) + @$(ECHO) Full Source.. $(FULL_SOURCE) + @$(ECHO) Full Target.. $(FULL_TARGET) + @$(ECHO) SourceSuffix. $(SOURCESUFFIX) + @$(ECHO) TargetSuffix. $(TARGETSUFFIX) + @$(ECHO) + @$(ECHO) == Directory info == + @$(ECHO) + @$(ECHO) Required pkgs... $(REQUIRE_PACKAGES) + @$(ECHO) + @$(ECHO) Basedir......... $(BASEDIR) + @$(ECHO) FPCDir.......... $(FPCDIR) + @$(ECHO) CrossBinDir..... $(CROSSBINDIR) + @$(ECHO) UnitsDir........ $(UNITSDIR) + @$(ECHO) PackagesDir..... $(PACKAGESDIR) + @$(ECHO) + @$(ECHO) GCC library..... $(GCCLIBDIR) + @$(ECHO) Other library... $(OTHERLIBDIR) + @$(ECHO) + @$(ECHO) == Tools info == + @$(ECHO) + @$(ECHO) As........ $(AS) + @$(ECHO) Ld........ $(LD) + @$(ECHO) Ar........ $(AR) + @$(ECHO) Rc........ $(RC) + @$(ECHO) + @$(ECHO) Mv........ $(MVPROG) + @$(ECHO) Cp........ $(CPPROG) + @$(ECHO) Rm........ $(RMPROG) + @$(ECHO) GInstall.. $(GINSTALL) + @$(ECHO) Echo...... $(ECHO) + @$(ECHO) Shell..... $(SHELL) + @$(ECHO) Date...... $(DATE) + @$(ECHO) FPCMake... $(FPCMAKE) + @$(ECHO) PPUMove... $(PPUMOVE) + @$(ECHO) Upx....... $(UPXPROG) + @$(ECHO) Zip....... $(ZIPPROG) + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) Target Loaders........ $(TARGET_LOADERS) + @$(ECHO) Target Units.......... $(TARGET_UNITS) + @$(ECHO) Target Implicit Units. $(TARGET_IMPLICITUNITS) + @$(ECHO) Target Programs....... $(TARGET_PROGRAMS) + @$(ECHO) Target Dirs........... $(TARGET_DIRS) + @$(ECHO) Target Examples....... $(TARGET_EXAMPLES) + @$(ECHO) Target ExampleDirs.... $(TARGET_EXAMPLEDIRS) + @$(ECHO) + @$(ECHO) Clean Units......... $(CLEAN_UNITS) + @$(ECHO) Clean Files......... $(CLEAN_FILES) + @$(ECHO) + @$(ECHO) Install Units....... $(INSTALL_UNITS) + @$(ECHO) Install Files....... $(INSTALL_FILES) + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) + @$(ECHO) DateStr.............. $(DATESTR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) ZipPrefix............ $(ZIPPREFIX) + @$(ECHO) ZipCrossPrefix....... $(ZIPCROSSPREFIX) + @$(ECHO) ZipSuffix............ $(ZIPSUFFIX) + @$(ECHO) FullZipName.......... $(FULLZIPNAME) + @$(ECHO) Install FPC Package.. $(INSTALL_FPCPACKAGE) + @$(ECHO) + @$(ECHO) Install base dir..... $(INSTALL_BASEDIR) + @$(ECHO) Install binary dir... $(INSTALL_BINDIR) + @$(ECHO) Install library dir.. $(INSTALL_LIBDIR) + @$(ECHO) Install units dir.... $(INSTALL_UNITDIR) + @$(ECHO) Install source dir... $(INSTALL_SOURCEDIR) + @$(ECHO) Install doc dir...... $(INSTALL_DOCDIR) + @$(ECHO) Install example dir.. $(INSTALL_EXAMPLEDIR) + @$(ECHO) Install data dir..... $(INSTALL_DATADIR) + @$(ECHO) + @$(ECHO) Dist destination dir. $(DIST_DESTDIR) + @$(ECHO) Dist zip name........ $(DIST_ZIPNAME) + @$(ECHO) +.PHONY: fpc_info +fpc_info: $(INFORULES) +.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \ + fpc_makefile_dirs +fpc_makefile: + $(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc +fpc_makefile_sub1: +ifdef TARGET_DIRS + $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS)) +endif +ifdef TARGET_EXAMPLEDIRS + $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS)) +endif +fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS)) +fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2 +fpc_makefiles: fpc_makefile fpc_makefile_dirs +all: fpc_all +debug: fpc_debug +smart: fpc_smart +release: fpc_release +units: fpc_units +examples: +shared: fpc_shared +install: fpc_install +sourceinstall: fpc_sourceinstall +exampleinstall: fpc_exampleinstall +distinstall: fpc_distinstall +zipinstall: fpc_zipinstall +zipsourceinstall: fpc_zipsourceinstall +zipexampleinstall: fpc_zipexampleinstall +zipdistinstall: fpc_zipdistinstall +clean: fpc_clean +distclean: fpc_distclean +cleanall: fpc_cleanall +info: fpc_info +makefiles: fpc_makefiles +.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif +.NOTPARALLEL: diff --git a/packages/libndsfpc/Makefile.fpc b/packages/libndsfpc/Makefile.fpc new file mode 100644 index 0000000000..d93733b03a --- /dev/null +++ b/packages/libndsfpc/Makefile.fpc @@ -0,0 +1,32 @@ +# +# Makefile.fpc for nds units +# + +[package] +name=libndsfpc +version=0.1 + +[target] +units=nds9 nds7 dswifi9 dswifi7 fat gbfs mikmod9 mikmod7 +examples= + +[compiler] +options= +includedir=src src/dswifi src/fat src/libmikmod +sourcedir=src tests + + +[install] +fpcpackage=y + +[default] +cpu=arm +target=nds +fpcdir=../.. + +[require] +nortl=y + +[rules] +.NOTPARALLEL: + diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.git b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.git new file mode 100644 index 0000000000..bc83d8b33c --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.git @@ -0,0 +1,8 @@ +# disable alpha and set opaque bit for all pixels +-gT! + +# use lz77 compression +-gzl + +# 16 bit bitmap +-gB16 diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.png b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.png Binary files differnew file mode 100644 index 0000000000..a99f433e87 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/data/drunkenlogo.png diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/main.pp new file mode 100644 index 0000000000..9516b0ea2a --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/16bit_color_bmp/main.pp @@ -0,0 +1,83 @@ +program main; +{$L drunkenlogo.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +const + drunkenlogoBitmapLen = 26988; + +var + drunkenlogoBitmap: array [0..6746] of cuint; cvar; external; + + +function getSize(source: pcuint8; dest: pcuint16; arg: cuint32): integer; +begin + getSize := pcuint32(source)^; +end; + +function readByte(source: pcuint8): cuint8; +begin + readByte := source^; +end; + + +var + drunkenlogo_decomp: TDecompressionStream; + +begin + drunkenlogo_decomp.getSize := TGetSize(@getSize); + drunkenlogo_decomp.getResult := nil; + drunkenlogo_decomp.readByte := TReadByte(@readByte); + // irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // set the mode for 2 text layers and two extended background layers + videoSetMode(MODE_5_2D or DISPLAY_BG3_ACTIVE); + + // set the sub background up for text display (we could just print to one + // of the main display text backgrounds just as easily + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + + // set the first bank as background memory and the third as sub background memory + // B and D are not used (if you want a bitmap greater than 256x256 you will need more + // memory so another vram bank must be used and mapped consecutivly + vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_LCD); + + // set up text background for text + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := RGB15(31,31,31);//by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + iprintf(#10#10#9 + 'Hello DS devers' + #10); + iprintf(#9 + 'www.drunkencoders.com' + #10); + iprintf(#9 + '16 bit bitmap demo'); + + // set up our bitmap background + BG3_CR^ := BG_BMP16_256x256; + + // these are rotation backgrounds so you must set the rotation attributes: + // these are fixed point numbers with the low 8 bits the fractional part + // this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap + BG3_XDX^ := 1 shl 8; + BG3_XDY^ := 0; + BG3_YDX^ := 0; + BG3_YDY^ := 1 shl 8; + + BG3_CX^ := 0; + BG3_CY^ := 0; + + swiDecompressLZSSVram(@drunkenlogoBitmap, BG_GFX, 0, @drunkenlogo_decomp); + while true do + swiWaitForVBlank(); + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.git b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.git new file mode 100644 index 0000000000..f3358514b8 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.git @@ -0,0 +1,5 @@ +# 8 bit bitmap +-gB8 + +# bitmap format +-gb diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.png b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.png Binary files differnew file mode 100644 index 0000000000..ea66c9e42f --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/data/drunkenlogo.png diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/main.pp new file mode 100644 index 0000000000..45fb64df94 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/256_color_bmp/main.pp @@ -0,0 +1,78 @@ +program main; +{$L drunkenlogo.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +const + drunkenlogoPalLen = 512; + drunkenlogoBitmapLen = 65536; + +var + drunkenlogoPal: array [0..255] of cushort; cvar; external; + drunkenlogoBitmap: array [0..16383] of cuint; cvar; external; + + +begin + //irqs are nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + //set the mode for 2 text layers and two extended background layers + videoSetMode(MODE_5_2D or DISPLAY_BG3_ACTIVE); + + //set the sub background up for text display (we could just print to one + //of the main display text backgrounds just as easily + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + + //set the first bank as background memory and the third as sub background memory + //B and D are not used + vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_LCD); + + ////////////////set up text background for text///////////////////// + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := u32(RGB15(31,31,31));//by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + iprintf(#10#10#9 + 'Hello DS devers' + #10); + iprintf(#9 + 'www.drunkencoders.com' + #10); + iprintf(#9 + '256 color bitmap demo'); + + ///////////////set up our bitmap background/////////////////////// + + BG3_CR^ := BG_BMP8_256x256; + + //these are rotation backgrounds so you must set the rotation attributes: + //these are fixed point numbers with the low 8 bits the fractional part + //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap + BG3_XDX^ := 1 shl 8; + BG3_XDY^ := 0; + BG3_YDX^ := 0; + BG3_YDY^ := 1 shl 8; + //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2 + BG3_CX^ := 0; + BG3_CY^ := 32 shl 8; + +{ + for i := 0 to 256*2 - 1 do + BG_PALETTE[i] := palette_bin[i]; + for i := 0 to 256*256 - 1 do + BG_GFX[i] := drunkenlogo_bin[i]; +} + + + dmaCopy(@drunkenlogoBitmap, BG_GFX, drunkenlogoBitmapLen); + dmaCopy(@drunkenlogoPal, BG_PALETTE, drunkenlogoPalLen); + + while true do + swiWaitForVBlank(); + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/drunkenlogo.bin.o b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/drunkenlogo.bin.o Binary files differnew file mode 100644 index 0000000000..ce9052e475 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/drunkenlogo.bin.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/main.pp new file mode 100644 index 0000000000..6b5695c06b --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/main.pp @@ -0,0 +1,137 @@ +program main; +{$L drunkenlogo.bin.o} +{$L palette.bin.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + drunkenlogo_bin_end: array [0..0] of u8; cvar; external; + drunkenlogo_bin: array [0..0] of u8; cvar; external; + drunkenlogo_bin_size: u32; cvar; external; + + palette_bin_end: array [0..0] of u8; cvar; external; + palette_bin: array [0..0] of u8; cvar; external; + palette_bin_size: u32; cvar; external; + + angle: u32; + scrollX, scrollY: s16; + scaleX, scaleY: s16; + rcX, rcY: s16; + keys: u32; + s, c: s16; + + +begin + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // set the mode for 2 text layers and two extended background layers + videoSetMode(MODE_5_2D or DISPLAY_BG3_ACTIVE); + + // set the sub background up for text display (we could just print to one + // of the main display text backgrounds just as easily + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + + // set the first bank as background memory and the third as sub background memory + // B and D are not used + vramSetMainBanks( VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_LCD); + + // set up text background for text + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := u32(RGB15(31,31,31));//by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + + + // set up our bitmap background + + BG3_CR^ := BG_BMP8_256x256; + + // these are rotation backgrounds so you must set the rotation attributes: + // these are fixed point numbers with the low 8 bits the fractional part + // this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap + BG3_XDX^ := 1 shl 8; + BG3_XDY^ := 0; + BG3_YDX^ := 0; + BG3_YDY^ := 1 shl 8; + // our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2 + BG3_CX^ := 0; + BG3_CY^ := 32 shl 8; + + dmaCopy(@drunkenlogo_bin, BG_GFX, 256*256); + dmaCopy(@palette_bin, BG_PALETTE, 256*2); + + angle := 0; + + // the screen origin is at the rotation center...so scroll to the rotation + // center + a small 32 pixle offset so our image is centered + scrollX := 0 + 128; + scrollY := 32 + 96 ; + + //scale is fixed point + scaleX := 1 shl 8; + scaleY := 1 shl 8; + + //this is the screen pixel that the image will rotate about + rcX := 128; + rcY := 96; + + while true do + begin + printf(#10#10#9 + 'Hello DS devers' + #10); + printf(#9 + 'www.drunkencoders.com' + #10); + printf(#9 + 'BG Rotation demo' + #10); + + iprintf('Angle %3d(actual) %3d(degrees)' + #10, [angle and $1FF, (angle and $1FF) * 360 div 512]); + iprintf('Scroll X: %4d Y: %4d' + #10, [scrollX, scrollY]); + iprintf('Rot center X: %4d Y: %4d' + #10, [rcX, rcY]); + iprintf('Scale X: %4d Y: %4d' + #10, [scaleX, scaleY]); + + scanKeys(); + keys := keysHeld(); + + if ( keys and KEY_L ) <> 0 then angle := angle + 1; + if ( keys and KEY_R ) <> 0 then angle := angle - 1; + if ( keys and KEY_LEFT ) <> 0 then scrollX := scrollX + 1; + if ( keys and KEY_RIGHT ) <> 0 then scrollX := scrollX - 1; + if ( keys and KEY_UP ) <> 0 then scrollY := scrollY + 1; + if ( keys and KEY_DOWN ) <> 0 then scrollY := scrollY - 1; + if ( keys and KEY_A ) <> 0 then scaleX := scaleX + 1; + if ( keys and KEY_B ) <> 0 then scaleX := scaleX - 1; + if ( keys and KEY_START ) <> 0 then rcX := rcX + 1; + if ( keys and KEY_SELECT ) <> 0 then rcY := rcY + 1; + if ( keys and KEY_X ) <> 0 then scaleY := scaleY + 1; + if ( keys and KEY_Y ) <> 0 then scaleY := scaleY - 1; + + // Compute sin and cos + s := SIN_bin[angle and $1FF] shr 4; + c := COS_bin[angle and $1FF] shr 4; + + swiWaitForVBlank(); + + // Set the background registers + + BG3_XDX^ := cuint16(( c * scaleX ) shr 8); + BG3_XDY^ := cuint16((-s * scaleX ) shr 8); + + BG3_YDX^ := cuint16(( s * scaleY ) shr 8); + BG3_YDY^ := cuint16(( c * scaleY ) shr 8); + + BG3_CX^ := cuint32((scrollX shl 8) - rcX * (c - s)); + BG3_CY^ := cuint32((scrollY shl 8) - rcY * (s + c)); + + // clear the console screen (ansi escape sequence) + printf(#27 + '[2J'); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/palette.bin.o b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/palette.bin.o Binary files differnew file mode 100644 index 0000000000..6a5fb61a46 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/BG_Rotation/palette.bin.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/data/ball.pcx b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/data/ball.pcx Binary files differnew file mode 100644 index 0000000000..d7120162ac --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/data/ball.pcx diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/main.pp new file mode 100644 index 0000000000..5a5231fcec --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Complex_2D/main.pp @@ -0,0 +1,254 @@ +program main; +{$L ball.pcx.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + ball_pcx_end: array [0..0] of u8; cvar; external; + ball_pcx: array [0..0] of u8; cvar; external; + ball_pcx_size: u32; cvar; external; + + +const + NUM_SPRITES = 128; + +var + OAMCopySub: array [0..127] of SpriteEntry; + +type +//simple sprite struct + TSprite = record + x, y: integer; //location + dx, dy: integer; //speed + oam: PSpriteEntry; + gfxID: integer; //graphics lovation + end; + PSprite = ^TSprite; + + +procedure MoveSprite(sp: PSprite); +var + x, y: integer; +begin + x := sp^.x shr 8; + y := sp^.y shr 8; + + sp^.oam^.st.attribute[1] := sp^.oam^.st.attribute[1] and $FE00; + sp^.oam^.st.attribute[1] := sp^.oam^.st.attribute[1] or (x and $01FF); + + sp^.oam^.st.attribute[0] := sp^.oam^.st.attribute[0] and $FF00; + sp^.oam^.st.attribute[0] := sp^.oam^.st.attribute[0] or (y and $00FF); +end; + +procedure initOAM(); +var + i: integer; +begin + for i := 0 to 127 do + OAMCopySub[i].st.attribute[0] := ATTR0_DISABLED; +end; + +procedure updateOAM(); +begin + dmaCopy(@OAMCopySub, OAM_SUB, sizeof(OAMCopySub)); +end; + + +function irqVBlank(): pointer; +begin +end; + +var + back, front: pcuint16; + sprites: array [0..NUM_SPRITES - 1] of TSprite; + i, delta: integer; + ix, iy: integer; + screen: integer; + map0, map1: pcuint16; + red: cuint16; + ball: sImage; + +begin + back := VRAM_A; + front := VRAM_B; + + i := 0; + delta := 0; + ix := 0; + iy := 0; + screen := 1; + map0 := pcuint16(SCREEN_BASE_BLOCK_SUB(1)); + map1 := pcuint16(SCREEN_BASE_BLOCK_SUB(2)); + + //turn on the power to the system + powerON(POWER_ALL); + + //set main display to render directly from the frame buffer + videoSetMode(MODE_FB1); + + //set up the sub display + videoSetModeSub(MODE_0_2D or DISPLAY_SPR_1D_LAYOUT or DISPLAY_SPR_ACTIVE or + DISPLAY_BG0_ACTIVE or DISPLAY_BG1_ACTIVE ); + + //vram banks are somewhat complex + vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_SUB_SPRITE); + + // a vblank interrupt is needed to use swiWaitForVBlank() + // since the dispatcher handles the flags no handler is required + irqInit(); + irqSet(IRQ_VBLANK, @irqVBlank); + + //load our ball pcx file into an image + loadPCX(pu8(ball_pcx), @ball); + + //tile it so it is usefull as sprite data + imageTileData(@ball); + + // Sprite initialisation + for i := 0 to 255 do + SPRITE_PALETTE_SUB[i] := u32(ball.palette[i]); + + for i := 0 to 32*16 - 1 do + SPRITE_GFX_SUB[i] := u32(ball.image.data16[i]); + + //turn off sprites + initOAM(); + + for i := 0 to NUM_SPRITES - 1 do + begin + //random place and speed + sprites[i].x := rand() and $FFFF; + sprites[i].y := rand() and $7FFF; + sprites[i].dx := (rand() and $FF) + $100; + sprites[i].dy := (rand() and $FF) + $100; + + if (rand() and 1) <> 0 then + sprites[i].dx := -sprites[i].dx; + if (rand() and 1) <> 0 then + sprites[i].dy := -sprites[i].dy; + + sprites[i].oam := @OAMCopySub[i]; + sprites[i].gfxID := 0; + + //set up our sprites OAM entry attributes + sprites[i].oam^.st.attribute[0] := ATTR0_COLOR_256 or ATTR0_SQUARE; + sprites[i].oam^.st.attribute[1] := ATTR1_SIZE_32; + sprites[i].oam^.st.attribute[2] := sprites[i].gfxID; + end; + + //set up two backgrounds to scroll around + SUB_BG0_CR^ := BG_COLOR_256 or (1 shl SCREEN_SHIFT); + SUB_BG1_CR^ := BG_COLOR_256 or (2 shl SCREEN_SHIFT); + + BG_PALETTE_SUB[0] := u32(RGB15(10,10,10)); + BG_PALETTE_SUB[1] := u32(RGB15(0,16,0)); + BG_PALETTE_SUB[2] := u32(RGB15(0,0,31)); + + //load the maps with alternating tiles (0,1 for bg0 and 0,2 for bg1) + for iy := 0 to 31 do + for ix := 0 to 31 do + begin + map0[iy * 32 + ix] := (ix xor iy) and 1; + map1[iy * 32 + ix] := ((ix xor iy) and 1) shl 1; + end; + + //fill 2 tiles with different colors + for i := 0 to (64 div 2) - 1 do + begin + BG_GFX_SUB[i+32] := $0101; + BG_GFX_SUB[i+32+32] := $0202; + end; + + while (true) do + begin + //scroll the background + SUB_BG0_X0^ := delta; + inc(delta); + SUB_BG0_Y0^ := delta; + + //move the sprites + for i := 0 to NUM_SPRITES - 1 do + begin + sprites[i].x := sprites[i].x + sprites[i].dx; + sprites[i].y := sprites[i].y + sprites[i].dy; + + //check for collision with the screen boundries + if (sprites[i].x < (1 shl 8)) or (sprites[i].x > (247 shl 8)) then + sprites[i].dx := -sprites[i].dx; + + if (sprites[i].y < (1 shl 8)) or (sprites[i].y > (182 shl 8)) then + sprites[i].dy := -sprites[i].dy; + + //reposition the sprites + MoveSprite(@sprites[i]); + end; + + + + //do the plasma/fire + for ix := 0 to SCREEN_WIDTH - 1 do + begin + back[ix + SCREEN_WIDTH * (SCREEN_HEIGHT - 1)] := rand() and $FFFF; + back[ix + SCREEN_WIDTH * (SCREEN_HEIGHT - 2)] := rand() and $FFFF; + end; + + inc(back); + + for iy := 1 to SCREEN_HEIGHT - 3 do + begin + for ix := 1 to SCREEN_WIDTH - 2 do + begin + red := 0; + + red := red + front[0]; + red := red + front[2]; + + front := front + SCREEN_WIDTH; + + red := red + front[0]; + red := red + front[1]; + red := red + front[2]; + + front := front + SCREEN_WIDTH; + + red := red + front[0]; + red := red + front[1]; + red := red + front[2]; + + front := front - ((2 * SCREEN_WIDTH) - 1); + + back[0] := (red shr 3); + inc(back); + end; + inc(back,2); + inc(front,2); + + end; + + swiWaitForVBlank(); + + updateOAM(); + + //flip screens + if (screen) <> 0 then + begin + videoSetMode(MODE_FB1); + front := VRAM_B; + back := VRAM_A; + screen := 0; + end else + begin + videoSetMode(MODE_FB0); + front := VRAM_A; + back := VRAM_B; + screen := 1; + end; + end; +end. + diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/Double_Buffer/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Double_Buffer/main.pp new file mode 100644 index 0000000000..c565b907c9 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Double_Buffer/main.pp @@ -0,0 +1,95 @@ +program main; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + frontBuffer: pcuint16; + backBuffer: pcuint16; + colorMask: cuint16; + iy, ix: integer; + temp: pcuint16; + + +begin + irqInit(); + // a vblank interrupt is needed to use swiWaitForVBlank() + // since the dispatcher handles the flags no handler is required + irqEnable(IRQ_VBLANK); + + //set the mode for 2 text layers and two extended background layers + videoSetMode(MODE_5_2D or DISPLAY_BG3_ACTIVE); + + //set the sub background up for text display (we could just print to one + //of the main display text backgrounds just as easily + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + + //set the first two banks as background memory and the third as sub background memory + //D is not used..if you need a bigger background then you will need to map + //more vram banks consecutivly (VRAM A-D are all 0x20000 bytes in size) + vramSetMainBanks( VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, + VRAM_C_SUB_BG , VRAM_D_LCD); + + // set up text background for text + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := u32(RGB15(31,31,31));//by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + printf(#10#10#9 + 'Hello DS devers' + #10); + printf(#9 + 'www.drunkencoders.com' + #10); + printf(#9 + 'double buffer demo'); + + // set up our bitmap background + + BG3_CR^ := BG_BMP16_256x256; + + //these are rotation backgrounds so you must set the rotation attributes: + //these are fixed point numbers with the low 8 bits the fractional part + //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap + BG3_XDX^ := 1 shl 8; + BG3_XDY^ := 0; + BG3_YDX^ := 0; + BG3_YDY^ := 1 shl 8; + //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2 + BG3_CX^ := 0; + BG3_CY^ := 0; + + + frontBuffer := pcuint16($06000000); + backBuffer := pcuint16($06000000 + 256 * 256 * 2); + + //this is just used so we can write red color bits to one frame and green to the + //other + colorMask := $1F; + + while true do + begin + //draw a box + for iy := 60 to 196 - 60 - 1 do + for ix := 60 to 256 - 60 - 1 do + backBuffer[iy * 256 + ix] := (rand() and colorMask) or BIT(15); + + swiWaitForVBlank(); + + //swap + temp := frontBuffer; + frontBuffer := backBuffer; + backBuffer := temp; + + //flip + //base is 16KB and screen size is 256x256x2 (128KB) + BG3_CR^ := BG3_CR^ xor BG_BMP_BASE( 128 div 16 ); + + //this will cause red or green bits only to be set and swap each + //frame + colorMask := colorMask xor $3FF; + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/Sprite_Bitmap/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Sprite_Bitmap/main.pp new file mode 100644 index 0000000000..960eb38626 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/Sprite_Bitmap/main.pp @@ -0,0 +1,140 @@ +program main; +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + sprites: array [0..127] of SpriteEntry; + spriteRotations: pSpriteRotation; + i, angle: integer; + +//turn off all the sprites +procedure initSprites(); +var + i: integer; +begin + for i := 0 to 127 do + begin + sprites[i].st.attribute[0] := ATTR0_DISABLED; + sprites[i].st.attribute[1] := 0; + sprites[i].st.attribute[2] := 0; + sprites[i].st.attribute[3] := 0; + end; +end; + +//copy our sprite to object attribute memory +procedure updateOAM(); +begin + DC_FlushRange(@sprites, 128 * sizeof(SpriteEntry)); + dmaCopy(@sprites, OAM, 128 * sizeof(SpriteEntry)); +end; + +begin + //rotation attributes overlap so assign then to the same location + spriteRotations := pSpriteRotation(@sprites); + + //turn everything on + powerON(POWER_ALL_2D); + + //irqs are nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + //enable vram and map it to the right places + vramSetMainBanks( VRAM_A_MAIN_SPRITE, //A and B maped consecutivly as sprite memory + VRAM_B_MAIN_SPRITE, //this gives us 256KB which is the max + VRAM_C_MAIN_BG_0x06000000, //map C to background memory + VRAM_D_LCD //not using D + ); + + //set the video mode + videoSetMode( MODE_0_2D or + DISPLAY_SPR_ACTIVE or //turn on sprites + DISPLAY_BG0_ACTIVE or //turn on background 0 + DISPLAY_SPR_1D or //this is used when in tile mode + DISPLAY_SPR_1D_BMP //and this in bitmap mode + ); + + + // black backdrop + BG_PALETTE[0] := u32(RGB15(0,0,0)); + + + BG0_CR^ := BG_MAP_BASE(31);//use bg0 for the text + + BG_PALETTE[255] := u32(RGB15(31,31,31));//by default font rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK(31)), pu16(CHAR_BASE_BLOCK(0)), 16); + + //turn off the sprites + initSprites(); + + + // direct bitmap sprite + // print at using ansi escape sequence \x1b[line;columnH + printf(#27 + '[1;1H' + 'Direct Bitmap:'); + sprites[0].st.attribute[0] := ATTR0_BMP or ATTR0_ROTSCALE_DOUBLE or 10; + sprites[0].st.attribute[1] := ATTR1_SIZE_32 or 20; + sprites[0].st.attribute[2] := ATTR2_ALPHA(1)or 0; + + // red 32*32 square for 1d bitmap mode + for i := 0 to 32*32 - 1 do + SPRITE_GFX[i] := RGB15(31,0,0) or (1 shl 15); //dont forget alpha bit + + // 256 color sprite + // print at using ansi escape sequence \x1b[line;columnH + printf(#27 + '[9;1H' + '256 color:'); + sprites[1].st.attribute[0] := ATTR0_COLOR_256 or ATTR0_ROTSCALE_DOUBLE or 75; + sprites[1].st.attribute[1] := ATTR1_SIZE_32 or 20; // size 64x64, x 10 + sprites[1].st.attribute[2] := 64; + + // Blue for 256 color sprite + SPRITE_PALETTE[1] := RGB15(0,0,31); + + // blue 64*64 square for 256 color mode (must write two pixles at time) + for i := 0 to 32*16 - 1 do + SPRITE_GFX[i+64*16] := (1 shl 8) or 1; + + // 16 color sprite + // print at using ansi escape sequence \x1b[line;columnH + printf(#27 + '[16;1H' + '16 color:'); + sprites[2].st.attribute[0] := ATTR0_COLOR_16 or ATTR0_ROTSCALE_DOUBLE or 135; + sprites[2].st.attribute[1] := ATTR1_SIZE_32 or 20; + sprites[2].st.attribute[2] := ATTR2_PALETTE(1) or 96; + + //yellow for 16 color sprite (it is using palette 1 so colors 16-31) + SPRITE_PALETTE[17] := RGB15(31,31,0); + + // yellow 32*32 square for 16 color mode (must write 4 pixels at a time) + for i := 0 to 32*8 - 1 do + SPRITE_GFX[i+96*16] := (1 shl 12) or (1 shl 8) or (1 shl 4) or 1; + + + + angle:=0; + + //we tied all our sprites to the same rotation attributes (0) + spriteRotations[0].hdx := 256; + spriteRotations[0].hdy := 0; + spriteRotations[0].vdx := 0; + spriteRotations[0].vdy := 256; + + while true do + begin + angle := angle + 1; + + spriteRotations[0].hdx := COS_bin[angle and $1FF] shr 4; + spriteRotations[0].hdy := SIN_bin[angle and $1FF] shr 4; + spriteRotations[0].vdx := -spriteRotations[0].hdy; + spriteRotations[0].vdy := spriteRotations[0].hdx; + + swiWaitForVBlank(); + + updateOAM(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/ansi_console/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/ansi_console/main.pp new file mode 100644 index 0000000000..2ed40611b5 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/ansi_console/main.pp @@ -0,0 +1,57 @@ +program main; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +begin + +//--------------------------------------------------------------------------------- + // initialise the irq dispatcher + irqInit(); + // a vblank interrupt is needed to use swiWaitForVBlank() + // since the dispatcher handles the flags no handler is required + irqEnable(IRQ_VBLANK); + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := u32(RGB15(31,31,31)); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + // ansi escape sequence to clear screen and home cursor + // #27 + [line;columnH + iprintf(#27 + '[2J'); + + // ansi escape sequence to set print co-ordinates + // #27 + [line;columnH + iprintf(#27 + '[10;10H' + 'Hello World!'); + + // ansi escape sequence to move cursor up + // #27 + [linesA + iprintf(#27 + '[10A' + 'Line 0'); + + // ansi escape sequence to move cursor left + // #27 + [columnsD + iprintf(#27 + '[28D' + 'Column 0'); + + // ansi escape sequence to move cursor down + // #27 + [linesB + iprintf(#27 + '[19B' + 'Line 19'); + + // ansi escape sequence to move cursor right + // #27 + [columnsC + iprintf(#27 + '[5C' + 'Column 20'); + + while true do + swiWaitForVBlank(); + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.bmp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.bmp Binary files differnew file mode 100644 index 0000000000..bc6ca47475 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.bmp diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.git b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.git new file mode 100644 index 0000000000..f3358514b8 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/data/font.git @@ -0,0 +1,5 @@ +# 8 bit bitmap +-gB8 + +# bitmap format +-gb diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/main.pp new file mode 100644 index 0000000000..08ea8218d6 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/custom_font/main.pp @@ -0,0 +1,69 @@ +program main; +{$L font.o} +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + i: integer; + sub_tile: pu16; + sub_map: pu16; + +const + font_WIDTH = 8; + font_HEIGHT = 768; + + fontPalLen = 512; + fontBitmapLen = 6144; + +var +//byte array representing the picture + fontBitmap: array [0..1535] of cuint16; cvar; external; + fontPal: array [0..255] of cuint16; cvar; external; + + +const + char_base = 0; + screen_base = 20; + + +begin + irqInit(); + irqEnable(IRQ_VBLANK); + + videoSetMode(0); + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR^ := BG_256_COLOR or BG_TILE_BASE(char_base) or BG_MAP_BASE(screen_base); + + sub_tile := pu16(CHAR_BASE_BLOCK_SUB(char_base)); + sub_map := pu16(SCREEN_BASE_BLOCK_SUB(screen_base)); + + //95 and 32 show how many characters there are and 32 shows which ASCII character to start, respectively + //95 is the smaller set of ACSII characters. It usually will start with 32 + consoleInit(pu16(fontBitmap), sub_tile, 95, 32, sub_map, CONSOLE_USE_COLOR255, 8); + + //Load the Font Data and Palette stuff here + for i := 0 to fontBitmapLen - 1 do + sub_tile[i] := u32(fontBitmap[i]); + + + + for i := 0 to fontPalLen - 1 do + BG_PALETTE_SUB[i] := u32(fontPal[i]); + + + + printf('Custom Font Demo' + #10); + printf(' by Poffy' + #10); + printf('modified by WinterMute' + #10); + printf('for libnds examples' + #10); + + while true do + swiWaitForVBlank(); +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/hello_world/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/hello_world/main.pp new file mode 100644 index 0000000000..462aa78490 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/hello_world/main.pp @@ -0,0 +1,54 @@ +program main; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + frame: integer; + touchXY: touchPosition; + + + +function Vblank(): pointer; +begin + inc(frame); +end; + +begin + + irqInit(); + irqSet(IRQ_VBLANK, @Vblank); + irqEnable(IRQ_VBLANK); + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := u32(RGB15(31,31,31)); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + printf(' Hello DS dev''rs' + #10); + printf(' www.devkitpro.org' + #10); + printf(' www.drunkencoders.com'); + + while true do + begin + swiWaitForVBlank(); + touchXY := touchReadXY(); + + // print at using ansi escape sequence #27 + [line;columnH + iprintf(#27 + '[10;0H' + 'Frame = %d',[frame]); + iprintf(#27 + '[16;0H' + 'Touch x = %04X, %04X' + #10, [touchXY.x, touchXY.px]); + iprintf('Touch y = %04X, %04X' + #10, [touchXY.y, touchXY.py]); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.bmp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.bmp Binary files differnew file mode 100644 index 0000000000..bc6ca47475 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.bmp diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.git b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.git new file mode 100644 index 0000000000..f3358514b8 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/data/font.git @@ -0,0 +1,5 @@ +# 8 bit bitmap +-gB8 + +# bitmap format +-gb diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/main.pp new file mode 100644 index 0000000000..3d2fcb5051 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/2D/rotscale_text/main.pp @@ -0,0 +1,128 @@ +program main; +{$L font.o} +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + i: integer; + sub_tile: pu16; + sub_map: pu16; + scaleX, scaleY: s16; + scrollX, scrollY: s16; + rcX, rcY: s16; + angle: cuint = 0; + keys: u32; + angleSin, angleCos: s16; + +const + font_WIDTH = 8; + font_HEIGHT = 768; + fontPalLen = 512; + fontBitmapLen = 6144; + +var +//byte array representing the picture + fontBitmap: array [0..1535] of cuint16; cvar; external; + fontPal: array [0..255] of cuint16; cvar; external; + + +const + char_base = 0; + screen_base = 20; + + +begin + irqInit(); + irqEnable(IRQ_VBLANK); + + videoSetMode(0); + videoSetModeSub(MODE_5_2D or DISPLAY_BG3_ACTIVE or DISPLAY_BG_EXT_PALETTE); + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG3_CR^ := BG_TILE_BASE(char_base) or BG_MAP_BASE(screen_base) or ROTBG_SIZE_256x256; + + sub_tile := pu16(CHAR_BASE_BLOCK_SUB(char_base)); + sub_map := pu16(SCREEN_BASE_BLOCK_SUB(screen_base)); + + //95 and 32 show how many characters there are and 32 shows which ASCII character to start, respectively + //95 is the smaller set of ACSII characters. It usually will start with 32 + consoleInit(pu16(fontBitmap), sub_tile, 95, 32, sub_map, CONSOLE_USE_COLOR255, 8); + + //Load the Font Data and Palette stuff here + for i := 0 to fontBitmapLen - 1 do + sub_tile[i] := u32(fontBitmap[i]); + // extended palettes are written with bank mapped to lcd + vramSetBankH(VRAM_H_LCD); + + for i := 0 to fontPalLen - 1 do + VRAM_H_EXT_PALETTE[3, 0, i] := u32(fontPal[i]); + + // map bank to extended palette after writing data + vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE); + + + + + iprintf('Custom Font Demo' + #10); + iprintf(' by Poffy' + #10); + iprintf('modified by WinterMute' + #10); + iprintf('for libnds examples' + #10); + + //scale is fixed point + scaleX := 1 shl 8; + scaleY := 1 shl 8; + + scrollX := 128; + scrollY := 96; + + //this is the screen pixel that the image will rotate about + rcX := 128; + rcY := 96; + + angle := 0; + + while true do + begin + scanKeys(); + keys := keysHeld(); + + if ( keys and KEY_L ) <> 0 then angle := angle + 1; + if ( keys and KEY_R ) <> 0 then angle := angle - 1; + + if ( keys and KEY_LEFT ) <> 0 then scrollX := scrollX + 1; + if ( keys and KEY_RIGHT ) <> 0 then scrollX := scrollX - 1; + if ( keys and KEY_UP ) <> 0 then scrollY := scrollY + 1; + if ( keys and KEY_DOWN ) <> 0 then scrollY := scrollY - 1; + + if ( keys and KEY_A ) <> 0 then scaleX := scaleX + 1; + if ( keys and KEY_B ) <> 0 then scaleX := scaleX - 1; + + if( keys and KEY_X ) <> 0 then scaleY := scaleY + 1; + if( keys and KEY_Y ) <> 0 then scaleY := scaleY - 1; + + // wrap angle + angle := angle and $1ff; + + // Compute sin and cos + angleSin := SIN_bin[angle] shr 4; + angleCos := COS_bin[angle] shr 4; + + swiWaitForVBlank(); + + // Set the background registers + SUB_BG3_XDX^ := cuint16(( angleCos * scaleX ) shr 8); + SUB_BG3_XDY^ := cuint16((-angleSin * scaleX ) shr 8); + SUB_BG3_YDX^ := cuint16(( angleSin * scaleY ) shr 8); + SUB_BG3_YDY^ := cuint16(( angleCos * scaleY ) shr 8); + + SUB_BG3_CX^ := cuint16((scrollX shl 8) - rcX * ( angleCos - angleSin)); + SUB_BG3_CY^ := cuint16((scrollY shl 8) - rcY * ( angleSin + angleCos)); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/BoxTest/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/BoxTest/main.pp new file mode 100644 index 0000000000..28acf75ff8 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/BoxTest/main.pp @@ -0,0 +1,248 @@ +(*--------------------------------------------------------------------------------- + + $id $ + + Box test to demonstrate 3D bounding box es. also shows the effect of culling and + clipping on vertex usage + $log $ +*--------------------------------------------------------------------------------*) + +program main; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + + +var + rotX: cfloat = 0; + rotY: cfloat = 0; + translate: cfloat = -5.0; + + //some profiling code + time: cuint16; + + //keep track of vertex ram usage + polygon_count, vertex_count: integer; + + //object + rx: integer = 50; + ry: integer = 15; + oldx: integer = 0; + oldy: integer = 0; + + hit: integer; + +//some code for profiling +function startTimer(timer: cint): cuint16; +begin + TIMER_CR(timer)^ := (0); + TIMER_DATA(0)^ := (0); + TIMER_CR(timer)^ := (TIMER_DIV_1); + startTimer := TIMER_DATA(0)^; +end; + +function getTimer(timer: integer): cuint32; +begin + getTimer := TIMER_DATA(timer)^; +end; +{ $define getTimer(timer) := (TIMER_DATA(timer))^} + +//draws a box...same signature as boxTest +procedure DrawBox(x, y, z, height, width, depth: cfloat); +begin + glBegin(GL_QUADS); + //z face + glColor3f(1,0,0); + glVertex3f(x , y , z ); + glVertex3f(x + width, y , z ); + glVertex3f(x + width, y + height, z ); + glVertex3f(x , y + height, z ); + + //z + depth face + glColor3f(1,0,1); + glVertex3f(x , y , z + depth); + glVertex3f(x , y + height, z + depth); + glVertex3f(x + width, y + height, z + depth); + glVertex3f(x + width, y , z + depth); + + + //x face + glColor3f(1,1,0); + glVertex3f(x , y , z ); + glVertex3f(x , y + height, z ); + glVertex3f(x , y + height, z + depth); + glVertex3f(x , y , z + depth); + + //x + width face + glColor3f(1,1,1); + glVertex3f(x + width, y , z ); + glVertex3f(x + width, y , z + depth); + glVertex3f(x + width, y + height, z + depth); + glVertex3f(x + width, y + height, z ); + + //y face + glColor3f(0,1,0); + glVertex3f(x , y , z ); + glVertex3f(x , y , z + depth); + glVertex3f(x + width, y , z + depth); + glVertex3f(x + width, y , z ); + + //y + height face + glColor3f(0,1,1); + glVertex3f(x , y + height, z ); + glVertex3f(x + width, y + height, z ); + glVertex3f(x + width, y + height, z + depth); + glVertex3f(x , y + height, z + depth); + + glEnd(); + +end; + +var + i: integer; +//draw the clock +begin + + // Turn on everything + powerON(POWER_ALL); + + //put 3D on top + lcdMainOnTop(); + + //setup the sub screen for basic printing + consoleDemoInit(); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our view port to be the same size as the screen + glViewPort(0,0,255,191); + + //main loop + while true do + begin + + scanKeys(); + + //process input + if (keysHeld() and KEY_LEFT) <> 0 then rotY := rotY + 1; + if (keysHeld() and KEY_RIGHT) <> 0 then rotY := rotY - 1; + if (keysHeld() and KEY_UP) <> 0 then rotX := rotX + 1; + if (keysHeld() and KEY_DOWN) <> 0 then rotX := rotX - 1; + if (keysHeld() and KEY_L) <> 0 then translate := translate + 0.1; + if (keysHeld() and KEY_R) <> 0 then translate := translate - 0.1; + + //reset x and y when user touches screen + if (keysDown() and KEY_TOUCH) <> 0 then + begin + oldx := touchReadXY().px; + oldy := touchReadXY().py; + end; + + //if user drags then grab the delta + if (keysHeld() and KEY_TOUCH) <> 0 then + begin + rx := rx + touchReadXY().px - oldx; + ry := ry + touchReadXY().py - oldy; + oldx := touchReadXY().px; + oldy := touchReadXY().py; + end; + + //change ortho vs perspective + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (keysHeld() and KEY_B) <> 0 then + glOrtho(-4,4,-3,3,0.1,10) + else + gluPerspective(35, 256.0 / 192.0, 0.1, 10); + + //change cull mode + if (keysHeld() and KEY_A) <> 0 then + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE ) + else + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_FRONT ); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + //handle camera + glRotateY(rotY); + glRotateX(rotX); + glTranslatef(0,0,translate); + + //move the cube + glRotateX(ry); + glRotateY(rx); + + DrawBox(-1,-1,-1,2,2,2); + + printf(#27 + '[2J' + 'Box test cycle count'); + + time := startTimer(0); + hit := BoxTestf(-1,-1,-1,2,2,2); + printf(#10 + 'Single test (float): %i', [2*(getTimer(0) - time)]); + + time := startTimer(0); + BoxTest(inttov16(-1),inttov16(-1),inttov16(-1),inttov16(2),inttov16(2),inttov16(2)); + printf(#10 + 'Single test (fixed): %i', [2*(getTimer(0) - time)]); + + time := startTimer(0); + + for i := 0 to 63 do + BoxTest(inttov16(-1),inttov16(-1),inttov16(-1),inttov16(2),inttov16(2),inttov16(2)); + + printf(#10 + '64 tests avg. (fixed): %i', [(getTimer(0) - time) / 32]); + if hit > 0 then + printf(#10 + 'Box Test result: hit') + else + printf(#10 + 'Box Test result: miss'); + + while (GFX_STATUS^ and (1 shl 27)) <> 0 do; // wait until the geometry engine is not busy + + glGetInt(GL_GET_VERTEX_RAM_COUNT, vertex_count); + glGetInt(GL_GET_POLYGON_RAM_COUNT, polygon_count); + + + if (keysHeld() and KEY_A) <> 0 then + printf(#10#10 + 'Ram usage: Culling none') + else + printf(#10#10 + 'Ram usage: Culling back faces'); + + printf(#10 + 'Vertex ram: %i', vertex_count); + printf(#10 + 'Polygon ram: %i', polygon_count); + printf(#10#10 + 'Press A to change culling'); + printf(#10#10 + 'Press B to change Ortho vs Persp'); + printf(#10 + 'Press Left and Right Up and Down to rotate'); + printf(#10 + 'Press L and R to zoom'); + printf(#10 + 'Touch screen to rotate cube'); + + //a handy little built in function to wait for a screen refresh + swiWaitForVBlank(); + + // flush to screen + glFlush(0); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List/main.pp new file mode 100644 index 0000000000..04d53d7889 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List/main.pp @@ -0,0 +1,118 @@ +program main; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + + +var +//display list +{ + triangle: array [0..12] of cuint32 = ( + 12, + FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR), + GL_TRIANGLE, + RGB15(31,0,0), + VERTEX_PACK(inttov16(-1),inttov16(-1)), VERTEX_PACK(0,0), + RGB15(0,31,0), + FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END), + VERTEX_PACK(inttov16(1),inttov16(-1)), VERTEX_PACK(0,0), + RGB15(0,0,31), + VERTEX_PACK(inttov16(0),inttov16(1)), VERTEX_PACK(0,0) +); +} + triangle: array [0..12] of cuint32; + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: u16; + + +procedure SetDisplayList; +begin + triangle[0] := 12; + triangle[1] := FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR); + triangle[2] := GL_TRIANGLE; + triangle[3] := RGB15(31,0,0); + triangle[4] := VERTEX_PACK(inttov16(-1),inttov16(-1)); + triangle[5] := VERTEX_PACK(0,0); + triangle[6] := RGB15(0,31,0); + triangle[7] := FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END); + triangle[8] := VERTEX_PACK(inttov16(1),inttov16(-1)); + triangle[9] := VERTEX_PACK(0,0); + triangle[10] := RGB15(0,0,31); + triangle[11] := VERTEX_PACK(inttov16(0),inttov16(1)); + triangle[12] := VERTEX_PACK(0,0); +end; + +begin + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + SetDisplayList; + + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + + while true do + begin + glPushMatrix(); + //move it away from the camera + glTranslate3f32(0, 0, floattof32(-1)); + + glRotateX(rotateX); + glRotateY(rotateY); + + glMatrixMode(GL_TEXTURE); + glIdentity(); + + glMatrixMode(GL_MODELVIEW); + + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + scanKeys(); + + keys := keysHeld(); + + if ((keys and KEY_UP)) <> 0 then rotateX := rotateX + 3; + if ((keys and KEY_DOWN)) <> 0 then rotateX := rotateX - 3; + if ((keys and KEY_LEFT)) <> 0 then rotateY := rotateY + 3; + if ((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY - 3; + + glCallList(@triangle); + + glPopMatrix(1); + + glFlush(0); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/data/teapot.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/data/teapot.bin Binary files differnew file mode 100644 index 0000000000..5fb08a6ac6 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/data/teapot.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/main.pp new file mode 100644 index 0000000000..10e8385c15 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Display_List_2/main.pp @@ -0,0 +1,84 @@ +program main; +{$L teapot.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +//teapot display list provided by Mike260, as well as the display list gl code. + +var + teapot_bin_end: array [0..0] of u8; cvar; external; + teapot_bin: array [0..0] of u16; cvar; external; + teapot_bin_size: u32; cvar; external; + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: cuint16; + +begin + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 3.5, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + glLight(1, RGB15(31,0,31), 0, floattov10(1) - 1, 0); + glLight(2, RGB15(0,31,0) , floattov10(-1.0), 0, 0); + glLight(3, RGB15(0,0,31) , floattov10(1.0) - 1, 0, 0); + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or + POLY_FORMAT_LIGHT2 or POLY_FORMAT_LIGHT3 ) ; + + while true do + begin + glPushMatrix(); + + glRotateX(rotateX); + glRotateY(rotateY); + + scanKeys(); + keys := keysHeld(); + if (keys and KEY_UP) = 0 then rotateX := rotateX +3; + if (keys and KEY_DOWN) = 0 then rotateX := rotateX -3; + if (keys and KEY_LEFT) = 0 then rotateY := rotateY +3; + if (keys and KEY_RIGHT) = 0 then rotateY := rotateY -3; + + glCallList(@teapot_bin); + + glPopMatrix(1); + + glFlush(0); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/cafe.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/cafe.bin Binary files differnew file mode 100644 index 0000000000..3a3dc3975f --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/cafe.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/teapot.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/teapot.bin Binary files differnew file mode 100644 index 0000000000..423968b900 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/data/teapot.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/main.pp new file mode 100644 index 0000000000..a7982062d2 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Env_Mapping/main.pp @@ -0,0 +1,144 @@ +program main; +{$L teapot.o} +{$L cafe.o} + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + teapot_bin_end: array [0..0] of u8; cvar; external; + teapot_bin: array [0..0] of u16; cvar; external; + teapot_bin_size: u32; cvar; external; + cafe_bin_end: array [0..0] of u8; cvar; external; + cafe_bin: array [0..0] of u16; cvar; external; + cafe_bin_size: u32; cvar; external; + prev_pen: array [0..1] of cint = ($7FFFFFFF, $7FFFFFFF); + + + +procedure get_pen_delta(dx, dy: pcint); +var + keys: u32; + touchXY: touchPosition; +begin + keys := keysHeld(); + + if (keys and KEY_TOUCH) <> 0 then + begin + touchXY := touchReadXY(); + + if (prev_pen[0] <> $7FFFFFFF) then + begin + dx^ := (prev_pen[0] - touchXY.x); + dy^ := (prev_pen[1] - touchXY.y); + end; + + prev_pen[0] := touchXY.x; + prev_pen[1] := touchXY.y; + end else + begin + prev_pen[0] := $7FFFFFFF; + prev_pen[1] := $7FFFFFFF; + dx^ := 0; + dy^ := 0; + end; +end; + +var + rotateX: Integer = 0; + rotateY: Integer = 0; + tex_scale: GLvector; + keys: u32; + cafe_texid: cint; + pen_delta: array [0..1] of cint; + +begin + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + + // intialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + vramSetBankA(VRAM_A_TEXTURE); + glEnable(GL_TEXTURE_2D); + + + glGenTextures(1, @cafe_texid); + glBindTexture(0, cafe_texid); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, GL_TEXTURE_WRAP_S or GL_TEXTURE_WRAP_T or TEXGEN_NORMAL, pcuint8(@cafe_bin)); + + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + while true do + begin + //TEXGEN_NORMAL helpfully pops our normals into this matrix and uses the result as texcoords + glMatrixMode(GL_TEXTURE); + glIdentity(); + + tex_scale.x := (64 shl 16); + tex_scale.y := (-64 shl 16); + tex_scale.z := (1 shl 16); + glScalev( @tex_scale ); //scale normals up from (-1,1) range into texcoords + glRotateXi(rotateX shr 3); //rotate texture-matrix to match the camera + glRotateYi(rotateY shr 3); + + + glMatrixMode(GL_POSITION); + glIdentity(); + glTranslate3f32(0, 0, floattof32(-3)); + glRotateXi(rotateX shr 3); + glRotateYi(rotateY shr 3); + + glMaterialf(GL_EMISSION, RGB15(31,31,31)); + + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK ); + + scanKeys(); + keys := keysHeld(); + + if ( keys and KEY_UP ) <> 0 then rotateX := rotateX + (3 shl 3); + if ( keys and KEY_DOWN ) <> 0 then rotateX := rotateX - (3 shl 3); + if ( keys and KEY_LEFT ) <> 0 then rotateY := rotateY + (3 shl 3); + if ( keys and KEY_RIGHT ) <> 0 then rotateY := rotateY - (3 shl 3); + + + get_pen_delta( @pen_delta[0], @pen_delta[1] ); + rotateY := rotateY - pen_delta[0]; + rotateX := rotateX - pen_delta[1]; + + + glBindTexture( 0, cafe_texid ); + glCallList(@teapot_bin); + + glFlush(0); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/data/drunkenlogo.pcx b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/data/drunkenlogo.pcx Binary files differnew file mode 100644 index 0000000000..610722bec6 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/data/drunkenlogo.pcx diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/main.pp new file mode 100644 index 0000000000..1c3c737660 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Ortho/main.pp @@ -0,0 +1,183 @@ +program main; +{$L drunkenlogo.pcx.o} +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + drunkenlogo_pcx_end: array [0..0] of cuint8; cvar; external; + drunkenlogo_pcx: array [0..0] of cuint8; cvar; external; + drunkenlogo_pcx_size: cuint32; cvar; external; + +var + xrot: cfloat; // X Rotation ( NEW ) + yrot: cfloat; // Y Rotation ( NEW ) + zrot: cfloat; // Z Rotation ( NEW ) + + texture: array [0..0] of integer; // Storage For One Texture ( NEW ) + + + +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pcuint8(drunkenlogo_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + imageDestroy(@pcx); + + LoadGLTextures := true; +end; + + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +begin + glTranslatef(0.0,0.0,-5.0); + + glRotatef(xrot,1.0,0.0,0.0); + glRotatef(yrot,0.0,1.0,0.0); + glRotatef(zrot,0.0,0.0,1.0); + + glBindTexture(GL_TEXTURE_2D, texture[0]); + + glBegin(GL_QUADS); + // Front Face + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + // Back Face + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + // Top Face + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + // Bottom Face + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + // Right face + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + // Left Face + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glEnd(); + + xrot := xrot + 0.3; + yrot := yrot + 0.2; + zrot := zrot + 0.4; + DrawGLScene := true; +end; + + + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); // reserve some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize gl + glInit(); + + //enable textures + //glEnable(GL_TEXTURE_2D); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + glLight(1, RGB15(31,31,31) , 0, 0, floattov10(-1.0)); + glLight(2, RGB15(31,31,31) , 0, 0, floattov10(1.0)); + + glMatrixMode(GL_TEXTURE); + glIdentity(); + + glMatrixMode(GL_MODELVIEW); + + //need to set up some material properties since DS does not have them set by default + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + LoadGLTextures(); + + // set the vertex color to white + glColor3f(1,1,1); + + while true do + begin + scanKeys(); + + //reset the projection matrix + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + // set the projection matrix as either ortho or perspective + if (keysHeld() and KEY_R) = 0 then + gluPerspective(35, 256.0 / 192.0, 0.1, 100) + else + glOrtho(-3, 3,-2, 2, 0.1, 100); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + //ds specific, several attributes can be set here + if (keysHeld() and KEY_L) <> 0 then + glPolyFmt(POLY_ALPHA(0) or POLY_CULL_NONE or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or POLY_FORMAT_LIGHT2) + else + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or POLY_FORMAT_LIGHT2); + + + //Push our original Matrix onto the stack (save state) + glPushMatrix(); + + DrawGLScene(); + + // Pop our Matrix from the stack (restore state) + glPopMatrix(1); + + // flush to screen + glFlush(0); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data.inc b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data.inc new file mode 100644 index 0000000000..88d68cf7a1 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data.inc @@ -0,0 +1,80 @@ + // most of the following textures were generated from online samples available at + // http://www.marlinstudios.com/samples/sampvtf.htm and http://www.3dtotal.com/textures_v15/ + texture_bin_end: array [0..0] of u8; cvar; external; + texture_bin: array [0..0] of u16; cvar; external; + texture_bin_size: u32; cvar; external; + + texture1_RGB16_pal_bin_end: array [0..0] of u8; cvar; external; + texture1_RGB16_pal_bin: array [0..0] of u16; cvar; external; + texture1_RGB16_pal_bin_size: u32; cvar; external; + + texture1_RGB16_tex_bin_end: array [0..0] of u8; cvar; external; + texture1_RGB16_tex_bin: array [0..0] of u16; cvar; external; + texture1_RGB16_tex_bin_size: u32; cvar; external; + + texture2_RGB16_pal_bin_end: array [0..0] of u8; cvar; external; + texture2_RGB16_pal_bin: array [0..0] of u16; cvar; external; + texture2_RGB16_pal_bin_size: u32; cvar; external; + + texture2_RGB16_tex_bin_end: array [0..0] of u8; cvar; external; + texture2_RGB16_tex_bin: array [0..0] of u16; cvar; external; + texture2_RGB16_tex_bin_size: u32; cvar; external; + + texture3_RGB16_pal_bin_end: array [0..0] of u8; cvar; external; + texture3_RGB16_pal_bin: array [0..0] of u16; cvar; external; + texture3_RGB16_pal_bin_size: u32; cvar; external; + + texture3_RGB16_tex_bin_end: array [0..0] of u8; cvar; external; + texture3_RGB16_tex_bin: array [0..0] of u16; cvar; external; + texture3_RGB16_tex_bin_size: u32; cvar; external; + + texture4_RGB16_pal_bin_end: array [0..0] of u8; cvar; external; + texture4_RGB16_pal_bin: array [0..0] of u16; cvar; external; + texture4_RGB16_pal_bin_size: u32; cvar; external; + + texture4_RGB16_tex_bin_end: array [0..0] of u8; cvar; external; + texture4_RGB16_tex_bin: array [0..0] of u16; cvar; external; + texture4_RGB16_tex_bin_size: u32; cvar; external; + + texture5_RGB16_pal_bin_end: array [0..0] of u8; cvar; external; + texture5_RGB16_pal_bin: array [0..0] of u16; cvar; external; + texture5_RGB16_pal_bin_size: u32; cvar; external; + + texture5_RGB16_tex_bin_end: array [0..0] of u8; cvar; external; + texture5_RGB16_tex_bin: array [0..0] of u16; cvar; external; + texture5_RGB16_tex_bin_size: u32; cvar; external; + + texture6_RGB4_pal_bin_end: array [0..0] of u8; cvar; external; + texture6_RGB4_pal_bin: array [0..0] of u16; cvar; external; + texture6_RGB4_pal_bin_size: u32; cvar; external; + + texture6_RGB4_tex_bin_end: array [0..0] of u8; cvar; external; + texture6_RGB4_tex_bin: array [0..0] of u16; cvar; external; + texture6_RGB4_tex_bin_size: u32; cvar; external; + + + texture7_RGB4_pal_bin_end: array [0..0] of u8; cvar; external; + texture7_RGB4_pal_bin: array [0..0] of u16; cvar; external; + texture7_RGB4_pal_bin_size: u32; cvar; external; + + texture7_RGB4_tex_bin_end: array [0..0] of u8; cvar; external; + texture7_RGB4_tex_bin: array [0..0] of u16; cvar; external; + texture7_RGB4_tex_bin_size: u32; cvar; external; + + + texture8_RGB32_A3_pal_bin_end: array [0..0] of u8; cvar; external; + texture8_RGB32_A3_pal_bin: array [0..0] of u16; cvar; external; + texture8_RGB32_A3_pal_bin_size: u32; cvar; external; + + texture8_RGB32_A3_tex_bin_end: array [0..0] of u8; cvar; external; + texture8_RGB32_A3_tex_bin: array [0..0] of u16; cvar; external; + texture8_RGB32_A3_tex_bin_size: u32; cvar; external; + + + texture9_RGB32_A3_pal_bin_end: array [0..0] of u8; cvar; external; + texture9_RGB32_A3_pal_bin: array [0..0] of u16; cvar; external; + texture9_RGB32_A3_pal_bin_size: u32; cvar; external; + + texture9_RGB32_A3_tex_bin_end: array [0..0] of u8; cvar; external; + texture9_RGB32_A3_tex_bin: array [0..0] of u16; cvar; external; + texture9_RGB32_A3_tex_bin_size: u32; cvar; external; diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture.bin new file mode 100644 index 0000000000..423699d1f7 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture.bin @@ -0,0 +1 @@ +µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµ¬µ¬µÎ¹RÊrÎr嬱µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÂ1Æï½µµµµµµµµµµµî½RÊsÎ1Æî½µµµ0Â÷ÞœóÝûÝûÝû¼óXç1Ƶµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½“ΛïœïÖÚ´Ö”ÒQÊï½Î¹µµµÂµÖ´Òã¼÷½÷½÷œóãνRÊ›ï½÷ÞûþûþÿþÿþÿþÿöÞµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµµµµ¬µÍ¹1Æã½ó½ï½óÞ÷þûþÿÞûœórÎ͵RÊã½ó½÷½ó½ó½óÞ÷ÞûÞûÝû“Ò9çÿûÞûÞûÞûÞûÞûþÿþÿÞûÞûZëÖÚß”ÒÂιï½Î¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµÎ¹RÊzëÞ÷½ï½ïÞ÷½÷Þ÷ÿûÿÿÿÿ½÷´Ò8ß|çœç½ïÞ÷Þûþûþÿÿÿÿÿÿû½÷¾ó¾ïÞó½óÝóÞ÷Ý÷Þ÷Þ÷Þ÷ÞóÞóÞóÞ÷Þ÷½÷›ï½÷´Öî½µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µÌµ
¾pÊ-¾í¹¬µµµµµµµµµµµÍ¹”ÒÞ÷Þ÷¾ó½ó½ó½óÞ÷ÿûÿûþûÿûÞ÷ëœçÞ÷ÿÿÿÿÿÿÿÿÿûÿûß÷½ïœï÷Úß{ëÞ÷Þ÷Þ÷Þ÷ÞóÞóÞó¾ï¾ó½ï½ë½óÞ÷þûÿûÝûrÒµµµµµµµµµµ¬µ«±¬±¬µ¬µ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµìµôÖÛÒÒí¹¬µ¬µµµµµµµµµµµrʾ÷Þ÷›ïÖÖßÞ÷ÞûÞûÞ÷Þ÷Þ÷ÿû¾óÞóÞ÷Þ÷Þ÷ß÷ÿûÿûß÷ß÷¾÷0Ƭ¹Í¹Í¹RÊ{ë½ïœëœçëëëœç|ãœç½ïÝ÷Þ÷Þû¼÷Qʵµµµµµµµ¬µ¬µ.¾Êʺìµí¹í¹±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî½¶6Û7ÛÓÎ-¾µ±µµµµµµµµµÍµµÒ¾÷œó1Æι9ã¾ó½ó¾ó¾óÞ÷Þ÷Þ÷¾ó½ïë½ïÞ÷ÿûÿÿÿÿÿÿÿÿÿÿÞûÝûÝ÷YëÂ0ÂsÎ9ãë½ë½ë½ë½ï½ï½ïÝóÞ÷Þ÷Ý÷Þûãµµµµµµµµµ«±M¾òÒÒβʲÊoÆ-¾í¹î½Íµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµí¹ºôÎöÒôÒN¬µ±µµµµ¬±¬µ¬µµµï½:ã¾ózë͹Ûëëë¾óÞó¾óëëëë½ïÞ÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿû½÷zë÷ÞsÎœï½ï½ï½ïÝóÝóÞóÝó½ó½óÝ÷Zë0Ƶµµµµµµµµ¬µ-¾ÒαÊÓÊÓÊÓÎóÒ±ÎOÆ.¾͵¬µ¬µ¬µ¬µµµµµµµµµµµµµµµµµµµµµµµµµµ±±µµµµµµµµµµµµÍ¹ºÔÎõÎÓÊí¹¬±µµµÍµ¾Ìµ¬µ¬±µî¹ZçëZçµ:ßç¾ï¾ï½ïïëë½ï¾óÞûÿûÿÿÿÿßûÿûÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿÿÿÿÞû½÷Þ÷Þ÷½ó½ï½ó½ó½ï½ëÞóÞ÷ÞûÕÚιµµµµµµµµµ¬µ-ºÒÊÓÎÓÊÔÊÔÊÔÊôÒóÖóÖpÆ-¾ìµÍµµµµµµµµµµµµµµµµ¬µ¬µµµµ¬µµµµ¬µµµ¬µµ¬µ¬±¬µ¬µµµµµ¬µµµÍ¹í¹ëµôÒõÒ×±Îí¹¬±¬µµÍµ‘ÊÓβÎí¹µ¬µÍµrʼï»ó›óÞ÷Þó½ïë|çë¾óÞ÷Þ÷Þ÷þûÝûÝûÝ÷¾óßûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÞ÷Þ÷Þ÷Þ÷ÿ÷þûÿÿþÿ’Ò1Æî¹µµµµµµµµÌµoÂÒÊÓÊÓÎôÎôÎôÎôÎôÒÓ×óÒNÂì¹í¹µµ¬µµŒ±¬µ¬µ¬µµµµµµµµ¬±Œ±¬±¬µµµµµ¬µ«±¬±¬±¬µÌµÌ±¬±µµµµµÍµË±-¾NÂ
ºËµ×Ó×ÒÒí¹¬±¬µ¬µ.¾ÓÎÓÎÓÎì¹í¹
¾ì¹í¹³Ò
¾
ºqÊyç½ïëï¾óÞ÷Þ÷½ï›ë’ÎqÊpÆ/¾{ëÿÿÿûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿûÿûþûÿÿÿÿÿ÷ß÷ÞûÝ÷8ãrεµµµµµµÌµNÂÒÎÒÊÓÊôÎ××ôÒ×õÒôÎ××ÑÎN¾¬µµ¬µí¹í¹í¹ÍµÌµÍµ¬µÍµ¬µµ¬µNÂÎ
¾Œ±µ±µ¬µËµNÂÒÒì¹ëµ,¾ÒÒOƬµ¬µµµµÍ¹ì¹6ÛÓÎôÒO²Î××ÓÒí¹µ¬µ
¾ÓÎôÎ×pÆpÂôÒÔÒôÖôÖNÂpÆבÊ.¾YçÞ÷ÿûÞ÷¾ó¾ó½ó’γÊöÒõÎ
º7ãÿÿÿÿÿûÿ÷ÿûÿÿÿÿÿûÿûÿûÿÿÿÿÿÿÿÿÞû¼óÿûÿûþûþûþÿÿûÞó¾ïßóÿ÷ÿû›ï´Öµ±µµµµÌµNÂÓÎÓÎóÎôÎ×ß7ãxçÛ×ôÒôÒÛóÖoÆ.¬µî¹.¾ÛÛNÂì¹N²ÎÒÒpÊ
¾Ë±±ÊôÖÊ˵µ±µ¬µì¹óÖÔÎpÆ˵±ÊÛóÖî½µµµµÍµ-º6ÛôÎôÒÓÒOÂ7Û×ôÖ
¾Í¹ìµ²ÎÓÎôÒ±ÎNÂôÒ³ÊÓÎôÖÓÒÒÎ.ºõÎײξYëÿÿÿû¾ó¾ó½óOƳÎÓÕÎ
º³Òÿÿÿÿÿ÷ÿ÷ÿ÷ÿ÷ß÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿ÷âî½ÕÖÞûÿûÿûÿûÞ÷ß÷ß÷¾ï¾ïÿûÿÿœ÷±µµµµí¹OÂÒÎÓÎÓÎÒαÊpÆ.Â.¾O¾²ÊôÒôÒ×ÛÛoÆ.¾
¾OÂõÖõÒÓÒ
ºÓÎôÒõÒÛÓÒNÂOÂõÖôÒ-¾Íµ±µ¬µ
ºôÖÔÊôÒì¹ÒÎÛ6߲άµµµµÍ¹-ºxç×ÓÎÒÒ.¾õÖÛÛ
¾í¹O¾ôÒôÒ²Î
ºÊÓÒ²ÊÓÒÓҲΑÊ/¾õÎõÒ×pÊqÊÞûÿÿÞ÷Þ÷½ïpÊ‘Ê×ôξ²Îÿÿÿÿÿ÷ß÷ß÷¿ïß÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿßû{ëQÆ÷Úß÷ß÷ß÷ßó¾ï¾ëßïß÷ÿûÿû{ïî½±µµµµ¾OÂÒÎóÒÒÎÒÎNÂNÂíµí½
¾
ºº³ÊôÒôÒÛÛnÆ˵ºôÖÓ×ôÎôÒ×õÒôÒÓÎóÒ‘ÊpÊÛPÆ͵µµ¬µºÆõÎ6ß
¾ÓÒÛ5ÛóÖ
¾±¬µµ¬µ
ºÛôÒôÒóÒ
º×6Û6ß.¾õÒõÒóÒ
ºì¹M¾ôÖ‘Æ
ºí¹ì¹O¾öÒõÒõÒ×6ß¾ßÿÿÞûÞ÷œëqʲÎÛ×.¾NÂÝ÷ÿÿÿûÿûÿ÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿÿûßó¾ïµÒµÒÞóßóßóß÷ÿûßóßóÿûÿûÿûYçιµµµµµ¾NÂóÒóÒÒÎÓÒÓÒ
¾º¬µµÍµ-¾
º×ôÒ×ÛóÖNÂ˱ÒÎÓôÎÛ6ßÓÒpƑʲʑƱÎNÂבÊí¹µµ¬µº‘ÊõÎ7ã
¾óÖÛôÖ5ÛÊ̵µµ¬µí¹5ßôÒÓóÖìµôÒ6Û6ßÓÒõÖ7Û×oÆì¹ËµoÆ×ÒÎ̵¬µÌµ‘Ê×ôÒõÖÛ6Û’ÎO¼óÿÿÿû½ïrÊôÚÛôÒpÆO¼÷ÿÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿ÷ß÷ß÷zïsÎÞûÿûÿûÿ÷ß÷ÿûÿûÿûÿ÷ÿû›ïιµµµµµî¹OÂóÒÓÎôÎôÒÛÊ
¾¬±¬±±Íµì¹ÓÒ6ÛÓôÖ5ßÒÖN²Î7ÛõÒ×ó־͵í¹o±ÊÊOÂבÊ̵µµµ
¾±ÊôÒWã
ºÛÛóÒ6Û×O¬µ¬µ¬µì¹±ÎÒÎ×Û
¾6ß7ß6ß7ß7Û7ßÛ
ºÍµËµÆÛÒÒ«±µÍ¹pÊôÖôÒ×ÛÛÛ.ÂÔÖ½÷ÿÿÞ÷’ÎóÒôÎÒÊpƺzëÞûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûßûß÷ß÷9çÖÖÿûÿûÿÿÿÿÿûßóßóßóßóÞûrεµµµµµÍ¹.¾ôÒôÎôÎôÎÛÓÖ
ºÍµµ¬µ¬µËµoÆÓôÒ×6ß6ßÊPÆõÖÓÊÔÎPÂí¹¬µÍµìµ
ººÓÎבÊ̵µµµ.¾ÒÎôÒ6ß-¾ÓÖÒÒÒÎ××ÒÒ
ºµ¬µì¹ÒÒÒÎÓÎÛ-¾6ß6ß6ß6Û7Û7ß±Î쵵˵ÆôÖÒÎí¹Ìµí¹.¾qÊÛôÖ×ÛóÖ²Îìµ7ãþûÞû²Ò³ÎõÖôÒoÆëµ/µãÿÿÿÿÿûÿ÷ÿ÷ÿûÿÿÿÿÿûÿûß÷ßóÞó½ï¾óß÷ß÷ÿ÷ßûßûß÷¿ïßóÿûœïµµµµµµÍ¹.¾ôÒôÎÓÊôÎ×óÖ͹µµµµ«±²ÎôÒóÒóÒÛxç±ÎOÂÒγÊÔÎoÆ͵¬±µ¬µËµ.¾×ôÒ‘Î̹µµµ/ÂÒÎôÒÛ.ÂÛÛ±ÊóÒ6Û5ßoÆ칬µí¹ÓÒóÒÓÎÛ.ÂÛÛ×7ß7ÛÛoÆ̵µëµ±ÊôÖôÖóÖÓÒÓÒÊOÂ6ßÛôÖÛÛÛ.Â/½óÞ÷³ÖõÖ×ôÒ‘ÆëµôÚrÎ͹”Ò¾óÞïÿûÿûÿÿÿÿÿÿÿûÿûÿûÿûÿûÿûÿûÿûÿûÿÿÿûÿûÿ÷ßóß÷ÿÿãî½µ±µµµµÍµ.ÂôÖôÒÓÊÔÊ×Ûí¹µµ¬µí¹º×ÒÎÒÎóÒ×yçÒÒNÂÓÒÓÊõÒpÆŒµµµµÌµ-¾×בÎ̱µµµ.¾ÓÒôÒÛ.ÂßÛ±ÊóÖ6ã6ßÒÒº¾ì¹oÆôÒôÒôÖ-¾óÖÓÎ×7Û7ÛWãÛº.Â˵±ÊÓÒóұʱÊÒαÊ.¾×6ÛÛôÖÛ7ßÛ
ºöÚþû²ÒÛÓôΑÊëµßÞÿ{ïî½sʾïÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûßûÿûÿûÿûß÷ÿûß÷¿ï¾ë¾óßöÞιµµµµµÍµ-¾ôÖ×ÔÊÔÊôÒÛ
¾ÍµÍµ
¾ì¹ôÖ5ßóÒÒÎôÒÓ6ß±Î-¾ôÒôÎõÒpÆŒµµµµì¹N¾××óÖ«±µµµ
¾ÓÒôÒ×-¾ÛÛÆƱÊóÖ5ßNÆ
ºí¹N¾Ó×óÖ
ºÓÒõÒ××6ßWãôÖ±Î뵺ôÖÒÎÆƱʱαÎ
¾ôÖóÒÛôÖõÖÓÕÎÓÒ
¾›óÓÖÔÎÓ×oÆìµôÖÿÿÿÿ9닱ßß÷ßóÞïßóßó¾ï¿ï¿ï¾ïßóßóÞóß÷ß÷ßóßóßóßó¾ëžã¾ëß÷½÷µµµµµµ-¾ÓÒ×ÔÎôÎôÖÛÊ
¾
º
ºõÖ7ÛôÒÓÊÓÎÓÎ×5ßÆ.¾×ÓÎôÖpʵµµµÌµ‘ÊôÒÛ5ß̵µµµì¹±Î×6Û.ÂÓÒÛÒÎÒÎÒÎÒÒ۱κ.Â-ºÓÎ6ÛÛ¾Û7ÛÛ6ßÛÊÛ6ß/Â/ÂÛÆƱʑÊpÆOÆ.¾±ÊóÒÓÒoƲÎÓõÎ6Û.¾pƲΒÊõÒÛ±Îëµ’ÎÞûÞ÷½óÂÛžçžããããžã¾ëßïßóß÷ßóßó¿ï¾ë¾ë¾ë:ß÷ÖžçãßóÿûþÿµµµµµµN±Ê×ôÎõÒ×ÛÛ‘Ê’Ê×ÓÔβʲÊÓÎÒÎóÒÒÒ-¾pÆÓÒóÒôÒʬ±µµµÌµ²ÎÛÛÛ̵µµµí¹±Ê×6ã.±ÊôÖ6ßÛÊÒÒÛôÖìµëµ.¾ôÎ×ôÖ¾7ß××xç¾NÂÆ6ßóÖì¹ôÚóÖÒÎÊì¹ì¹
ºÓÒóÒ²ÎÊ/ÂpÊOÂÓõÎÓÎOº‘ÊÓÊõÒ’Îìµ8ãÿû¾ïç[ß|ß\ß\ß}ß}ãžç¾ëßïß÷Þ÷{çœë¾ï¿ï¾ë¾ï¾ïrÊRÆžç¾ëÿ÷ÿÿ¼÷͹µµµµµµ-¾/Â6ß×Û7ß7ß×õÒõÒôÒôÒôÎÓÊÓÎôÒ×ÒÒoÆìµpÆóÒÓÊÓΑʬ±µµµÌµÓÖWã×6ß-¾Ìµ¬±¬µ.ÂÒÒÛxëNÂÓÎ×5Û.ÂʱºÛ6Û‘Ê.¾±ÊÓÎײκÛôÒ6Û6ßì¹pÆ
º×ôÖpÆìµôÖóÖ-¾¬±î¹
ºÛôÖôÖ‘Î’Ê8ߺôÖõÒ6Û×ôÖõÒõÎôΒʺõÚœïë:ßÖÒ:ß}ã¾ëÞóßóßó¾ï¾óÞóßQÆ÷Úß÷ßóß÷ÿ÷œï1Æ:ß¾ë¿ïßûÝû”Ö¬µµµµµµ¬µ
¾-¾6ãWç6Û7Û7Û7Û×óÎôÒôÎôÒôÒôÒ×5ÛoÆ.¾.¾-¾ÒÊÒÊÓβά±µµµÌ¹ôÚ6ß×6ßÓÖëµÌµí¹²Î6ß6Û6ßNÂÓÎÓ6ß-¾-¾ËµôÖóұʱÊÒÊóÎ×ÒÒº²ÎôÒôÖôÖìµ¾
ºÓÒôÖÓÒ
ºpÆÒÒ
ºÍ¹Í¹¾ÓÖÒÎÒÒ²Ò¾Xã.¾qÊVßôÖÛ6ßôÒÔÊײҺ̵µï½Í¹‹±Íµ”ξ÷ÿû¾ï¾ï¾óœïÖÚî½Â8ãÞ÷ÿûÿûÿûÞ÷çžë¿ó½ó÷Þ0Æ͹µµµµµµµ
¾ºßxë6ß6Û×××ÓõÎõÎõÎõÒÓóÒÊ
ºëµ.¾oÆÒαÆÓÊÒÒ͵µµµí¹ôÚ5ß××ÛÛôÖÛ7ß7ß6߲κÔÎõÒÛ.Âí¹ì¹ÒÒÒÒ±ÆÓÊóÒ×±ÎëµÓÎôÒ×Û¾¾
¾±ÊôÖóÒ²Î
¾ÓÒOÂì¹OÆ.Â5ßÓÎÓαÎ
ºXã³ÎOÂWã×Û×ôÖôÒ5ۑκÔÒÖҔΔÎ÷ޔξrÊ8ã9ããÕÖ0Æ0ÆÂÖÚßûÿûÿûÿûß÷ßóßóÞ÷÷Þî½µµ¬µ±µµµµµµÍ¹º²Îšï6ß×××7Û8×Ó8×7ÛôÖÊ.¾.ÂôÖôÖ¾OÂóґƒƲʾµµµí¹ÓÒWã××ÛWßXã7ß7ß7Û6ÛoÆìµõÖÔÎôÒNÂ͵ì¹OÆôÖ²ÆÓÎôÎôÒ6ÛÊ˱ôÖ××ôÒ.¾í¹OÂpÆÛôÒÓÎOÂpÆóÒPÂpÆPÆOÂÓÎ×ôÖ.¾Zã8ßì¹ôÖ5Û××××ÛÒÒëµÛ|ã[ã9ß9ã¾ï[ã”Ò0Â0ÂQÆsεҔÎrÊÞ÷ÿûÿûß÷ßó¿ïß÷ÿû8笱µµµµµµµµµµµÍµ
ºoÆwçxç6Û7Û6ßÛõÖÓұΑÊoÆpÆÓÒôÖ×6ßóÖ.¾óÒÒÎÒÎÊì¹µµµî¹-¾Wã6ßÛXãXßWß7ßXß7ßÓκ˵ÓÎÒÎ×oÆí¹Í¹
¾×õÎõÎôÎ×ôÖ,¾Ë±²ÎôÖÓÊÔÎ.¾Íµ/ÂìµÓÎ7ßÓÒÓÖ
ºóÒÂÓÎôÖPƲÊõÎöÒ.¾zçœëpÆpÆ6ß×××ôÒôÒóÖì¹×}ã[ã9ß\ã~ß}ã[ã}çëœë[ç:ãQÆãÿÿÿûß÷ßó¿ïßóÿûßû’Ò¬µÎ¹µµµµµµµµµµµ¬µ
ºO‘ÎÊpÊpÆ.Â.¾qʲÎôÖ6ßXãWß6ß×5ß6ß.¾NÂNº̵µ±µµµÌµ
¾±ÎôÖXãXãWã6ßôÚʺí¹ìµÊÒÒÓÖì¹ÌµµÌµpÆôÒôÖÒÎÆNÂ˵칱ÎßÛʾ±Í¹
¾oÆ7ß×ôÖ.¾ÛÆ‘ÆÓÒpʳÎÛôÒºZßZçÔÖ
º6ßÛ×õÒÓ×ÒÎìµÛ|ãZç:ßÓ<×|ççžçç|ë{çµÒrʽóÿûÿûÿûÿ÷ß÷ÿûß÷ë0¬µÍµµµµµµµµµµµµ¬µµ¬µÍ¹¬µ¬µµí¹±ÎWã7ßXãzçÛÓÒõÖ6ß6ã6ßÛ.Â̵µ¬µµµµ¬µµ¬µ¬µ¬µí¹ìµìµ
¾ì¹Ìµ¬±µ¬µÌ¹Ë±ëµìµÌµµ±¬µËµìµì¹ëµËµÌµµÍµì¹-¾-¾
º/Â͹¬µí¹
¾-¾
¾
ºOÂÛôÒ²ÎpÊ
º-¾oÂ.¾PÂzç9ãYç’Î.¾²ÎÓÒÓÒ²ÊpÆìµ0º[ßZçZã;Û<×|ã|ç¾ë}ã}ç{ë|ëQÊãÿûÿûß÷ÿûÿûÿûÞ÷9ãSÆtÊrÊ͹±µµµµµµµµµµµµµµµµµì¹ôÖ7ß7ÛYãÛ
¾
¾.¾7ßXç5ß6ãÎ͵µ¬µ¬µ±±±µµµ¬µ¬µµ¬µµµµµ¬µµµ¬µÍ¹í¹í¹í¹ÍµÍ¹ÍµÌµì¹.¾.¾í¹Î¹µÍ¹.¾
º
¾
¾
¾/¾µÍ¹Í¹î¹0¾qÆqÆqʳÒÛµÎÕÒ÷ÖZßZã:ã[ßZß÷ִγγғÎÕÒÖÒ[Û|ç{ç\ß]Û}ã|ëçç|ã|ç|çÖÒsξ÷ÿûÿûÿûÿûÿûÞ÷µÒ¾¶Æ;×øÚ͹µ±µµµµµµµµµµµ¬µ¬µµµµ
¾6ßXã8ßYßqÆ̵±¾qÊ™ïxë6ãOƬ±Íµî½¾N¾¬µ¬µ«±Ëµì¹ì¹«±¬µ¬µ±µµ¬µí¹ì¹.¾OÂʲÎÊìµ
ºoƱÎÓÒpÆ
¾
º.¾N¾²Ê²Ê‘ÊÆNÂ.ÂιRÆøÎ[ß{çZë8ß\ß|ßçç{ë9ç{ã|ãçç{ç9ßç}ãã}ã|ã[ã\ã<Û}ß|ë|çã}ã}ç{çZã0Â:ã¾ïßóß÷ßóßóß÷œï¾–ÆùÎ\ß{çµµµµµµµµµµµµµµµµµµ
º×ÛXßYãºÍ¹µ¬µî½/ÂPÆí¹¬µ¬µ.¾pÆÓÒôÖÊ
¾ì¹¾Ìµ
ºôÒ×6ßÒÒ
¾ÌµÌµµµµìµôÖ×ôÎôÒÛÛO‘ÎôÒ‘ÆpÆÓұʺ.¾ÓβÊÓÒõÒÔαÊNÂ͹͹0Â×Ê:×{ã{ëYç{ã|ß}ã}ãëZë{ëœçžëççZç[ã}ß}ß}ß\Û\ã[ã\ß]ßçœëë¾ëžëë|ã”ÎQÆ}ç¾ë¾ë|ë|ëÞ÷ÞûãsÆ×\ßç¾ïrιµµµµµµµµµµµµµµµµ¬µ
º×7ÛXßXã-¾í¹µµ¬µµ¬µ¬µ¬µí¹ÓÒ6ÛXß7ßWã6ßÓÒ
¾.ÂOÂYã×ôÒôÒ5ßÛoÆì¹Íµ¬µËµ³ÎõÒõÒÛ6ã6ãNÂÓÒ
ºÌµÍ¹¾²ÎNÂO²ʑʺ
º³ÎÛoÆιï½tÆÏ|ã{ã{çZç|ã}ã}ß\Û{çZëëëžë½ë{ç[ç}ç}ß}ß]Û\ß;Û\Û]ßçœëë¾ë¾ï¾ï\çøÖï½ÕÖ½ïë[ç1Æ1ƵÖsÎÊ}ãžçžëžë÷Úιµµµµµµµµµµµµµµµµ¬µ/ÂÛ6ÛXãWçºÍµ¬µµµµµ¬µ¬µOÂÛÛyçXãWãyëXçÛºpÊšëXßôÒ³ÎôÒõÒôÖ²ÎìµÍµËµOÂ×õÖoÆ
¾
ººÓ¬µOÂpÆʺ²Ê.¾¾.Â.±ʾ×Ê[Û|ç{çZç{ççžç\Û|ãZëœïëç}ãœëzë|ç}ß}ß]ß}ß|ã;Û\Û}ãë|ë¾ï¾ë¾ï|ë:Û1Âî½Î¹0¾͹ι͵ιι¾•Êçžçžë}ãZãï½µµµµµµµµµµµµµµµµŒ±pÆXßXãšïšï
ºÍ¹µµµµµ¬µÍ¹ÓÒ7Û6ÛÓÒoÆpÆÛXãÛÊ-¾yë7ßõÖôÖÓÒ×Û6Û±Î칩pÆõÒ‘Æʱí¹ì¹oÂôÒ‘Æìµí¹OÂÒÒnÆ.ºÓÎ-¾¾µî¹Ì¹î¹î½RÂÓ\ß|ç{ç{ç|çã}ß}ãœë{ï½ïççœç{ëZç}ã}ß}ß]ß}ç:ß;×<×ç|ç¾ï¾ëžç½ó|ç۾ιµµµµµµµµQÆ×Ö¾ë¾ï¾ï}ã{ç¾µµµµµµµµµµµµµµµµŒ±pÆXßYãyç7ç.Â͹µµµµµÍµí¹õÚ6ß²Ê
ºî½OÆ-¾ôÖ6ÛóÖêµôÖXãÛ
¾OÆOƲÎ×6ßÎʱ³ÎõÒ²Îëµî½í¹ÊÓÎÒÎÓÎÓÒÓÒ,ººpÆÓÒOºOÂ/Âî½î¹ºÖÊ:×|ã{ëZç[ã|ã}ß<×}ç{ïœëëç}çœë{ë|ç}ã}ã\Û}ã|ç;ß<×[Û:ßçžë}ãžëœï{çsÊï½µµµµµ¬µµµµ0Âß¾óßó¾ïçZç͹µµµµµµµµµµµµµµµµ‹±¾Xãyç™ëxëÂ͹µµµµµÍ¹ìµ7ãxë.¾¾±µOƲÎXãÛ뵑ÊXã7ß.Âî¹î¹.¾²ÎWãßNÂ.¾õÖÓÖoÆ.¾.¾ºÓÒÓÎÓÎôÖ-¾ëµÊ±ÓÒôÖÓβÊpÂOƺ¾ÕÒ:ÛלëZçZã|ã\ß\Û\ß|ëœïëç}ãë{ë{ççžç}ß}ßë[ã;Û\Û{çZãçžçç¾ó{çÛï½Î¹¬µµµµµµµµÍ¹0Â\çßóß÷¾ëžë8ãî½µµµµµµµµµµµµµµµµ«±ìµ7ßxçxçyëÂ͵µµµµµí¹ëµôÖyç‘ʾ¬µµ.ÂPÆXçWã,¾oÆ7ß7ßPÆ͹µ¾PÆÛßoÆí¹××õÒ×ÛOÆpÂôÒôÒoÆNÂ-¾ìµ-¾‘ÊÓÒÛõÖÛõÖ.¾º9ß{ãœëZç|ç|ß]Û<×çœëœë}ã|ß}ãœë|ëç}ã}ß\Û|ç[ã;Û\Û|ç{ç|çžçžç¾óï{çrÊïÁ±µµµµµµµµÎ¹1Â\ã¾ï¿ïžç¾ïÕÚî¹µµµµµµµµµµµµµµµµÌµëµßšëyë»óOÆ͵µµµ¬µÌµì¹º
¾‘Ê7ÛÔÖ͵µ/ÂpÆXçWçnÆ
º6ÛÛOƵµµ.¾²ÎÛ±Îì¹ôÒ7ßÛ6ßWã²Î‘Ê×õÒ×ÛôÖOÂ
ºí¹.¾¾OÆõÖõÒóÖ-¾“ÎzçZç{ç|ã\ß<×}ß{çœëç|ß\ßœçœïëžç}ã\Û}ã[ç:ß|ß¾ç|ë|ë}çç¾ï½ó[ç÷ÚµµµµµµµµµÎµ¾¶Îžç¾ëžç}ãï0ÆιµµµµµµµµµµµµµµµµÍ¹ëµÓÒXãyëÜ÷ÓÖ͵µ±µÍ¹.ÂÒÒß6ã.³ÎX㾬µ¾.¾ÛÛ.Â
¾7ß6ßpÆ͵¬µµ/‘ÊóÒÒÒìµÓÎ6ãôÚNÂʵ˱6ßÛÛÛöÖ6ÛÓÒí¹µµÍµ.Â.¾õÒÔÒMÂ/¾Yã9ã{ç}ã\Û<×|ã{ëœï}ã}ã|ãœëœï¾ëžç\ß|ß|ç9ß;Ûç½ëœïœëçë¾ó|ë[ãQÆï½±µµµµµµµµ¾¾×žçžçžç}ãøÚ¬µµµµµµµµµµµµµµµµµµµÌµ³Ò™ëyë¼óßî½±±µí¹ÒÎ6ÛÛ6ßOƲÎ7ß.±Â.¾6ÛÛ.‘ÎXã7ßPÆµ.Â.²ÎôÖÓÖ
ºÓÎÛ.Âí¹Ìµ.¾šïßÒÒìµ/¾ÓÎôÒ¾¾Íµ¬±/Â-¾õÒôÒoƾ8ã9ã}ç}ß<Û\ß|çœï½ï}ã}ã|ë›ë½ëžç}ß\Û|çZãÛ\ßžë½ï¾ó¾ïç¾ï½÷{ãÖÖî½µµµµµµµµ±ÎµRÆØÒ\ß}ßžç~ã\ßQÆ͹µµµµµµµµµµµµµµµµµµ¬µ.™ïšëyë7ãOÆí¹î½í¹qÆôÒôÎôÖÛNÂÓÎÛOÆPÆpÊOÆ7ßôÖ
¾õÚzçÛOÆ/Â.ÂNÂqÆ7ßWãÓÖì¹ôÖóÖ
ºí¹Ì¹oÆxëß‘Î
¾ì¹pÂõÖ‘ÎOÂì¹ìµìµÓÒ8ßWãoÆqÆYç{ç}ã]ß]ß|çœï½óë\ß|çœïœï¾ë}ã<Û\ã|ç9ß;×ã¾ï½óÞóëë½óœë[ã1Âï½µµµµµµµµµRÆ•Ê<Û\Û~ã}ã\Û×Ö͹µµµµµµµµµµµµµµµµµµµµÌµõÚšë™ë»ó6ßOÂOƲÎÛ××6ßÒÒ-¾ôÖõÒÓÎpÆ‘ÎÛVã‘Î
º7ãyç×OÆ.¾N³Ò7ß7ßÛÊ/ÂÛ6ßOÆʱ˱ʱÓÒXãßí¹¬µpÆ6ßõÚOÂÔÖ³ÊÔÒXãyçôÚ
ºöÖzçç}ã]ß}ã|ç¼ó¾ï}ã}ßœë{ëïë\Û]ß}çZã×;מë¾ïÞó¾ë}ãçœë[ãßï½Î¹µµµµµµ±µ1ÂsÆ;Û}ß}ãžç~ç:ßÂ͹µµµµµµµµµµµµµµµµµµµµ¬µ.Â7ãšëšïšëXçXã7Û6Û7Û6ÛÛpÊ.¾ÛÛõÎÓ7Û6ßÛ
¾ì¹ôÖ7ß6ßÛôÖÛ6ß6ßÛóÖì¹³ÒÛ×ÒÒNÂN¾oÆ
ºöÖ7Û¾µ
ºôÖXçN²ÎôÖõÖ7ã5ßpÆ“ÎZç|ç|ß}ã]ßçï½óë<Û\ßœïœï¾ï}ß;×|ã[ç:ß;×]ß¾ï¾ó¿ï}ã}ãë{ç:ã1Æï½±µµµµµµµ0ÂRÆ×}ãžçžçç|ç´Ò͵µµµµµµµµµµµµµµµµµµµµµ¬µî¹PÆWãyçXãXß7Û7Û6Û6ßôÖ‘Êí¹Í¹pÊxç×ÕÊ×ôÖOÆpÆ6ÛÓÒôÖÛÛÛ±ÎNÂìµÌµÛ7ß×7ÛÛ6ÛÛ
¾ß7ã
¾µí¹±Î7ãÊ˱-¾‘ΑÊpƳÒ8ã{ç}ã}ß]Û]ßëœï½ï\ß<Ûëœï½ïžë\Û;Û|ç:ß:×\Ûçï¾ëžç}ãçœë[ãÖÖιµµµµµ±µÎ¹¾”Ê;Ûžç¿ë¾ë¾ë¾ï÷Úιµ±µµµµµµµµµµµµµµµµµµµµµµµ¾²ÎÛ6Û6Û×ÒÎÊ.¾Íµ¬µµ.¾pÆõÖ³Îqʾ͵¬µí¹-¾±ÊÒÒÓÒÊOÆ.¾Ìµ¬µµ«±³ÒXã×YßXãÛÒÒì¹.Â
ºÌµ¬±Íµ-¾Û²Ò¾’ΓÊõÖYçzë8ã|ç}ß]ß]ßçœï½ïë]ßç{ëœïï}ã\Û|ãZã:Û;×\ßëëã~ãçë{ã[ã1Æ鱬µ±µµÎ¹ï¹¾¶Î\ãžë¾ï¾ï¿ïÞóZçî½µµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±í¹í¹¾í¹Ìµ¬µ¬µµµµÍµí¹í¹¾î¹µŒ±µ¬±¬±¬µÌµÌµ¬µµµ¬±¬µµÌµì¹.¾
¾¾í¹ì¹ËµÌµ«±¬µ¬±±µ
ºôÚ7ãOÂrÂ×{ãZç9ã[ç|ã}ß\ß}ãëïžë}ß|ß½ï{ïœïç}ãç{ë:ß;Û<×}ãë}ç}ß}ãë|ç[ß÷Öî½µµµÍ¹î¹ï¹¾–Ê<Û}ã¿ë¿ï¿ï¿óßóYçµµµµµµµµµµµµµµµµµµµµµµµµµµµ±µµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµ±µµµµµµ±¬µÌµ‘ÊXã²Î
º×ZßYã9ã|ã}ß|ß}ßçœë½ï}ç\Ûžë½óœïë}ãçœëZã:Û<×\ßëç\ß\Ûçœï[ã[ß1Æï½Î¹Î¹ï½1Æ•ÊùÖ<Û~ãžãžçžç¾ë¿ïÞ÷ãµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµÍµ
ºõÖ7ÛpÆOÂ8ßYç{ç|ß\ß\ß|ãœëœëë\Û}ã½ó½ó½ëç}çë[ç:ß;×<×|ãë}ã}ß}çë{ç[ßÖÒ”Î:ßß:ãœï¾ïžëžçžçžã~ã}ßžã¾ï½ó´Öî¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÌµpÆ7ÛõÒOÂpÆ8ã|ç|ã\ß}ßë{ëë}ã\ßïœïëç}ãç|ëZã[ß<×\Û}ë}ç}ãžç¾ïœë[ã:Û1¾<Ûžç¾ëžë¿ë¿ëžë¿ë¾ëžã~ç\ß:ßÖÖ0Â͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹’ʺÓÎÓôÎOÂ.¾Ûzã[ß\ãœë|ëç\Û|ãœóœïëççëZã[ß\ß\ß}çëã}ãžëï{ç;Û”ÊuÆžë¿ó¾ï¾ï¿ï¿ïžç~ã}ã;ß×ÒRÆï½µµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Æ9ßÆ
ºôÒÔÎ×pʾ8ß[ß|ç{ëœç|ß\Û|ë›ïëç}ã|ç{ë[ã\ß|ß|çïžë}ãžç¾ï|ë;Û×RÂ;Û~ççžçžçç[ãÛµÎRÂï¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹ÖÒ\ãyç.Â-ºôÎÓ6Û‘ÊrÆ[ß|ç|ç}ç;Û|ã{ëœëç}ã|ã{ë[ç\ã}ßç½ïëžã~ãžë¾ï[ãÓ•ÎsÆÛøֶΔÊRÆÂï¹Í¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Â×\Û{ã8Û.¾NÂôÒÛ±ÎqÂ[ã{ç|ç|ã[Û{ç{ëœë}ç\ß|çZã[ã|ß|ãëëžç}ã}ãžëœë×øÎî¹ï½Î¹Î¹µµµµ¬µµµµ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ØÒ<×}ã|ßZßßOÂ.ºoÆqÆ×{ã{çë|ã{ã{ëœëç\ß[ßZçZã|ã}ãœë½ëç}ß]ßçœë[ç:×R±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï¹Ó;×\ß[ßZã9ßZß××[ß|ã[ß{ã|ã[ß{ã{ç|ç|ã[ß[ç:ã[ß|ß|çïç}ß\Û}ßë{ç[ß÷Ö͵µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±ºÓ\Û\ã[ß9Û:Û;Û[Û|ß}ã[ß[ß|ã[Û:Û:ß[ß[ß\ß|ãYãZã\ß|çïë}ã\Û\Û}ã|ç:Û9×1µµ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬±ð¹ùÎÓ|ãç{ç:ß[Û\Û|ß|ã[ß{ã}ã|ã[ã[ã[ß;Û;Û:ß:ß|ç|ãœëœï}ã}ß<Û}ß|ç[ãϵÎ͵±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹sÂØÊ;Û[ß{ãZã[ã[ß[ã[ã{ã|ß|ãç{ã[ã\ß;Û:Û×:Û|ã{ãœëœë|ã\Û\ß|ã|ç×øÎï¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹1¾×Ò:Û;Ûëë}ç|ã|ß\ß\Û|ß|ç{ã[ß:Û:×9Û:ß|ã[ß[ã|çë}ã\ß|ã|ã[ß:×sÊ͵¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½1µÎ[ã|ãç¾ëžç}ã\Û\ß\ß\ß[ß:Û:Û;ß[ß[ã|ã[ã|ã|ã|ß}ß|ã[ã;×øÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½sÊøÖ\ã}ççççç}ã\ß;Û;Û[Û\ß[ß[ß\ß\Û\Û\ß}ã[ã[ß:ÛrÊιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µ¬µµ¬µÍµ0ƵÒZãëë|çç|ç|ã|ß|ã\ß\ß;Û;Û\Û\ß|ã[ã[ß;Û÷Öï½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹RÆß{ç{ç|ç|ã|ãç|ã|ã[ß:Û[ß[ßZß[ã[ß;ßRÊ͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµÎ¹QÆÖÖöÚ{ç|ç|ã|ß}ã|ã:ß:ßZãZã|ç;ÛÖÒî½±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ±±µ¹î¹1ƵÖß[ã|ã|ß\Û|ß|çë\ßøÒ0Âι±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½î¹tÊøÖ×\ßžç}ã[ßµÎιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹î½ÂRʵÒ×ÒÖÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµ±µµµÍ¹Î¹ï½î½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµŒ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_pal.bin new file mode 100644 index 0000000000..e9b04b72bf --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_pal.bin @@ -0,0 +1 @@ +¸6x&w.V*6&6"5"&Ò%cC¾ov2V&¹.Ô
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_tex.bin Binary files differnew file mode 100644 index 0000000000..03068e687d --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture1_RGB16_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_pal.bin Binary files differnew file mode 100644 index 0000000000..9b1d466d21 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_pal.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_tex.bin Binary files differnew file mode 100644 index 0000000000..1e4cd1c853 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture2_RGB16_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_pal.bin Binary files differnew file mode 100644 index 0000000000..174ed18640 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_pal.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_tex.bin Binary files differnew file mode 100644 index 0000000000..5254cb965d --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture3_RGB16_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_pal.bin Binary files differnew file mode 100644 index 0000000000..0d7b385707 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_pal.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_tex.bin Binary files differnew file mode 100644 index 0000000000..ade6231da9 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture4_RGB16_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_pal.bin new file mode 100644 index 0000000000..0ee8f0fa71 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_pal.bin @@ -0,0 +1 @@ +>ò9Ñ5°1¯--Ž-Ž)n)m)m%L%œsvJÓ1Ç
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_tex.bin Binary files differnew file mode 100644 index 0000000000..036f1a1bec --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture5_RGB16_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_pal.bin new file mode 100644 index 0000000000..18a6bc0b4f --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_pal.bin @@ -0,0 +1 @@ +Bï=1F*
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_tex.bin Binary files differnew file mode 100644 index 0000000000..0acb3a4efd --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture6_RGB4_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_pal.bin new file mode 100644 index 0000000000..2664fc4571 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_pal.bin @@ -0,0 +1 @@ +}[Ž!–B§
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_tex.bin Binary files differnew file mode 100644 index 0000000000..b6d1e38795 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture7_RGB4_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_pal.bin Binary files differnew file mode 100644 index 0000000000..d770464540 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_pal.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_tex.bin Binary files differnew file mode 100644 index 0000000000..7084002f86 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture8_RGB32_A3_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_pal.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_pal.bin Binary files differnew file mode 100644 index 0000000000..f855ce6411 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_pal.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_tex.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_tex.bin Binary files differnew file mode 100644 index 0000000000..8ca2cfe3b0 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/data/texture9_RGB32_A3_tex.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/main.pp new file mode 100644 index 0000000000..40d4b45bf4 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Paletted_Cube/main.pp @@ -0,0 +1,307 @@ +program main; +{$L texture.o} +{$L texture1_RGB16_pal.o} +{$L texture1_RGB16_tex.o} +{$L texture2_RGB16_pal.o} +{$L texture2_RGB16_tex.o} +{$L texture3_RGB16_pal.o} +{$L texture3_RGB16_tex.o} +{$L texture4_RGB16_pal.o} +{$L texture4_RGB16_tex.o} +{$L texture5_RGB16_pal.o} +{$L texture5_RGB16_tex.o} +{$L texture6_RGB4_pal.o} +{$L texture6_RGB4_tex.o} +{$L texture7_RGB4_pal.o} +{$L texture7_RGB4_tex.o} +{$L texture8_RGB32_A3_pal.o} +{$L texture8_RGB32_A3_tex.o} +{$L texture9_RGB32_A3_pal.o} +{$L texture9_RGB32_A3_tex.o} + + + + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +var +{$include data.inc} + +var +//verticies for the cube + CubeVectors: array [0..23] of v16; +//polys + CubeFaces: array [0..23] of u8; + //texture coordinates + uv: array [0..3] of u32; + normals: array [0..5] of u32; + + +procedure Initialize(); +begin +//verticies for the cube + CubeVectors[0] := floattov16(-0.5); CubeVectors[1] := floattov16(-0.5); CubeVectors[2] := floattov16(0.5); + CubeVectors[3] := floattov16(0.5); CubeVectors[4] := floattov16(-0.5); CubeVectors[5] := floattov16(0.5); + CubeVectors[6] := floattov16(0.5); CubeVectors[7] := floattov16(-0.5); CubeVectors[8] := floattov16(-0.5); + CubeVectors[9] := floattov16(-0.5); CubeVectors[10] := floattov16(-0.5); CubeVectors[11] := floattov16(-0.5); + CubeVectors[12] := floattov16(-0.5); CubeVectors[13] := floattov16(0.5); CubeVectors[14] := floattov16(0.5); + CubeVectors[15] := floattov16(0.5); CubeVectors[16] := floattov16(0.5); CubeVectors[17] := floattov16(0.5); + CubeVectors[18] := floattov16(0.5); CubeVectors[19] := floattov16(0.5); CubeVectors[20] := floattov16(-0.5); + CubeVectors[21] := floattov16(-0.5); CubeVectors[22] := floattov16(0.5); CubeVectors[23] := floattov16(-0.5); + +//polys + CubeFaces[0] := 3; CubeFaces[1] := 2; CubeFaces[2] := 1; CubeFaces[3] := 0; + CubeFaces[4] := 0; CubeFaces[5] := 1; CubeFaces[6] := 5; CubeFaces[7] := 4; + CubeFaces[8] := 1; CubeFaces[9] := 2; CubeFaces[10] := 6; CubeFaces[11] := 5; + CubeFaces[12] := 2; CubeFaces[13] := 3; CubeFaces[14] := 7; CubeFaces[15] := 6; + CubeFaces[16] := 3; CubeFaces[17] := 0; CubeFaces[18] := 4; CubeFaces[19] := 7; + CubeFaces[20] := 5; CubeFaces[21] := 6; CubeFaces[22] := 7; CubeFaces[23] := 4; + + //texture coordinates + uv[0] := TEXTURE_PACK(inttot16(128), 0); + uv[1] := TEXTURE_PACK(inttot16(128),inttot16(128)); + uv[2] := TEXTURE_PACK(0, inttot16(128)); + uv[3] := TEXTURE_PACK(0,0); + + normals[0] := NORMAL_PACK(0,floattov10(-0.97),0); + normals[1] := NORMAL_PACK(0,0,floattov10(0.97)); + normals[2] := NORMAL_PACK(floattov10(0.97),0,0); + normals[3] := NORMAL_PACK(0,0,floattov10(-0.97)); + normals[4] := NORMAL_PACK(floattov10(-0.97),0,0); + normals[5] := NORMAL_PACK(0,floattov10(0.97),0); +end; + +//draw a cube face at the specified color +procedure drawQuad(poly: integer); +var + f1, f2, f3, f4: u32; +begin + f1 := CubeFaces[poly * 4] ; + f2 := CubeFaces[poly * 4 + 1] ; + f3 := CubeFaces[poly * 4 + 2] ; + f4 := CubeFaces[poly * 4 + 3] ; + + + glNormal(normals[poly]); + + GFX_TEX_COORD^ := (uv[0]); + glVertex3v16(CubeVectors[f1*3], CubeVectors[f1*3 + 1], CubeVectors[f1*3 + 2] ); + + GFX_TEX_COORD^ := (uv[1]); + glVertex3v16(CubeVectors[f2*3], CubeVectors[f2*3 + 1], CubeVectors[f2*3 + 2] ); + + GFX_TEX_COORD^ := (uv[2]); + glVertex3v16(CubeVectors[f3*3], CubeVectors[f3*3 + 1], CubeVectors[f3*3 + 2] ); + + GFX_TEX_COORD^ := (uv[3]); + glVertex3v16(CubeVectors[f4*3], CubeVectors[f4*3 + 1], CubeVectors[f4*3 + 2] ); +end; + +type + TTextures = record + format, pal_addr: cint; + size: u32; + end; + +var + textureIDS: array [0..9] of cint; + textures: array [0..9] of TTextures; + i: integer; + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keyspressed: u16; + keys: u16; + nTexture: integer; + +begin + Initialize(); + powerON(POWER_ALL); + lcdMainOnTop(); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + // black backdrop + BG_PALETTE_SUB[0] := RGB15(0,0,0); + SUB_BG0_CR^ := BG_MAP_BASE(31); + BG_PALETTE_SUB[255] := RGB15(31,31,31);//by default font rendered with color 255 + + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + //enable textures + glEnable(GL_TEXTURE_2D); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + // setup other material properties + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(20,20,20)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(5,5,5)); + + // setup the lighting + glLight(0, RGB15(31,31,31) , 0, floattov10(-0.5), floattov10(-0.85)); + + vramSetBankA(VRAM_A_TEXTURE); + + glGenTextures(10, textureIDS); + + // inital full 16 bit colour texture + glBindTexture(0, textureIDS[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture_bin)); + textures[0].format := GL_RGB; + textures[0].pal_addr := 0; + textures[0].size := texture_bin_size; // size field just recorded for on-screen info + + + // Load some 16 colour textures + glBindTexture(0, textureIDS[1]); + glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture1_RGB16_tex_bin)); + textures[1].format := GL_RGB16; + textures[1].pal_addr := gluTexLoadPal( pu16(texture1_RGB16_pal_bin), 16, GL_RGB16 ); + textures[1].size := texture1_RGB16_tex_bin_size+texture1_RGB16_pal_bin_size; + + glBindTexture(0, textureIDS[2]); + glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture2_RGB16_tex_bin)); + textures[2].format := GL_RGB16; + textures[2].pal_addr := gluTexLoadPal( pu16(texture2_RGB16_pal_bin), 16, GL_RGB16 ); + textures[2].size := texture2_RGB16_tex_bin_size+texture2_RGB16_pal_bin_size; + + glBindTexture(0, textureIDS[3]); + glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture3_RGB16_tex_bin)); + textures[3].format := GL_RGB16; + textures[3].pal_addr := gluTexLoadPal( pu16(texture3_RGB16_pal_bin), 16, GL_RGB16 ); + textures[3].size := texture3_RGB16_tex_bin_size+texture3_RGB16_pal_bin_size; + + glBindTexture(0, textureIDS[4]); + glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture4_RGB16_tex_bin)); + textures[4].format := GL_RGB16; + textures[4].pal_addr := gluTexLoadPal( pu16(texture4_RGB16_pal_bin), 16, GL_RGB16 ); + textures[4].size := texture4_RGB16_tex_bin_size+texture4_RGB16_pal_bin_size; + + glBindTexture(0, textureIDS[5]); + glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture5_RGB16_tex_bin)); + textures[5].format := GL_RGB16; + textures[5].pal_addr := gluTexLoadPal( pu16(texture5_RGB16_pal_bin), 16, GL_RGB16 ); + textures[5].size := texture5_RGB16_tex_bin_size+texture5_RGB16_pal_bin_size; + + + // Load some 4 colour textures + glBindTexture(0, textureIDS[6]); + glTexImage2D(0, 0, GL_RGB4, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture6_RGB4_tex_bin)); + textures[6].format := GL_RGB4; + textures[6].pal_addr := gluTexLoadPal( pu16(texture6_RGB4_pal_bin), 4, GL_RGB4 ); + textures[6].size := texture6_RGB4_tex_bin_size+texture6_RGB4_pal_bin_size; + + glBindTexture(0, textureIDS[7]); + glTexImage2D(0, 0, GL_RGB4, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture7_RGB4_tex_bin)); + textures[7].format := GL_RGB4; + textures[7].pal_addr := gluTexLoadPal( pu16(texture7_RGB4_pal_bin), 4, GL_RGB4 ); + textures[7].size := texture7_RGB4_tex_bin_size+texture7_RGB4_pal_bin_size; + + + // Load some 32 colour textures, 8 levels of alpha + glBindTexture(0, textureIDS[8]); + glTexImage2D(0, 0, GL_RGB32_A3, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture8_RGB32_A3_tex_bin)); + textures[8].format := GL_RGB32_A3; + textures[8].pal_addr := gluTexLoadPal( pu16(texture8_RGB32_A3_pal_bin), 32, GL_RGB32_A3 ); + textures[8].size := texture8_RGB32_A3_tex_bin_size+texture8_RGB32_A3_pal_bin_size; + + glBindTexture(0, textureIDS[9]); + glTexImage2D(0, 0, GL_RGB32_A3, TEXTURE_SIZE_128, TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture9_RGB32_A3_tex_bin)); + textures[9].format := GL_RGB32_A3; + textures[9].pal_addr := gluTexLoadPal( pu16(texture9_RGB32_A3_pal_bin), 32, GL_RGB32_A3 ); + textures[9].size := texture9_RGB32_A3_tex_bin_size+texture9_RGB32_A3_pal_bin_size; + + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + iprintf(#27 + '[4;8H' + 'Paletted Cube'); + iprintf(#27 + '[6;2H' + 'Right/Left shoulder to switch'); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 2.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE or POLY_FORMAT_LIGHT0 or POLY_ID(1) ) ; + + glColor3f(1,1,1); + + glMatrixMode(GL_MODELVIEW); + + nTexture := 0; + while true do + begin + glPushMatrix(); + + glRotateX(rotateX); + glRotateY(rotateY); + + scanKeys(); + keys := keysHeld(); + if((keys and KEY_UP)) <> 0 then rotateX := rotateX +3; + if((keys and KEY_DOWN)) <> 0 then rotateX := rotateX -3; + if((keys and KEY_LEFT)) <> 0 then rotateY := rotateY +3; + if((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY -3; + + keysPressed := keysDown(); + if (keysPressed and KEY_R) = 0 then + begin + inc(nTexture); + if( nTexture = 10 ) then + nTexture := 0; + end; + if (keysPressed and KEY_L) = 0 then + begin + dec(nTexture); + if( nTexture = -1 ) then + nTexture := 9; + end; + + glBindTexture(nTexture, textureIDS[nTexture]); + if( textures[nTexture].format <> GL_RGB ) then + glColorTable(textures[nTexture].format, textures[nTexture].pal_addr); + + //draw the obj + glBegin(GL_QUAD); + for i := 0 to 5 do + drawQuad(i); + glEnd(); + + glPopMatrix(1); + + glFlush(0); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cone.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cone.bin Binary files differnew file mode 100644 index 0000000000..577dd5649b --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cone.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cylinder.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cylinder.bin Binary files differnew file mode 100644 index 0000000000..8f38f8f02c --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/cylinder.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/sphere.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/sphere.bin Binary files differnew file mode 100644 index 0000000000..008e7fec60 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/data/sphere.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/main.pp new file mode 100644 index 0000000000..86bfefd0c2 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Picking/main.pp @@ -0,0 +1,219 @@ +(*--------------------------------------------------------------------------------- +Demonstrates how to use 3D picking on the DS + +Author: Gabe Ghearing +Created: Feb 2007 + +This file is released into the public domain + +Basic idea behind picking; + Draw the scene a second time with a projection matrix that only renders what is +directly below the cursor. The GPU keeps track of how many polygons are drawn, so +if a polygon is drawn in this limited view the polygon is directly below the cursor. +Several polygons may be drawn under the cursor, so a position test is used for each +object(a collection of polygons) to tell which object is closest to the camera. +The object that is closest to the camera and under the cursor is the one that the +user is clicking on. + +There are several optimizations that are not done in this example, such as: + - Simplify models during the picking pass, the model needs to occupy the + same area, but can usually use fewer polygons. + - Save the projection matrix with glGetFixed() instead of recreating it + every pass. + +*--------------------------------------------------------------------------------*) + +program main; +{$L cone.o} +{$L cylinder.o} +{$L sphere.o} + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +type + TClickable = ( clNothing, clCone, clCylinder, clSphere); + +var + cone_bin_end: array [0..0] of u8; cvar; external; + cone_bin: array [0..0] of u16; cvar; external; + cone_bin_size: u32; cvar; external; + cylinder_bin_end: array [0..0] of u8; cvar; external; + cylinder_bin: array [0..0] of u16; cvar; external; + cylinder_bin_size: u32; cvar; external; + sphere_bin_end: array [0..0] of u8; cvar; external; + sphere_bin: array [0..0] of u16; cvar; external; + sphere_bin_size: u32; cvar; external; + + clicked: TClickable; // what is being clicked + closeW: integer; // closest distace to camera + polyCount: integer; // keeps track of the number of polygons drawn + +// run before starting to draw an object while picking +procedure startCheck(); +begin + while PosTestBusy() do; // wait for the position test to finish + while GFX_BUSY do; // wait for all the polygons from the last object to be drawn + PosTest_Asynch(0,0,0); // start a position test at the current translated position + polyCount := GFX_POLYGON_RAM_USAGE^; // save the polygon count +end; + +// run afer drawing an object while picking +procedure endCheck(obj: TClickable); +begin + while GFX_BUSY do; // wait for all the polygons to get drawn + while PosTestBusy() do; // wait for the position test to finish + if (GFX_POLYGON_RAM_USAGE^ > polyCount) then // if a polygon was drawn + begin + if PosTestWresult() <= closeW then + begin + // this is currently the closest object under the cursor! + closeW := PosTestWresult(); + clicked := obj; + end; + end; +end; + +var + rotateX: cuint32 = 0; + rotateY: cuint32 = 0; + touchXY: touchPosition; + viewport: array [0..3] of integer = (0,0,255,191); // used later for gluPickMatrix() + keys: u16; + +begin + // power up everything; this a bit wasteful but this isn't a power management example + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + lcdMainOnBottom(); // we are going to be touching the 3D display + + // initialize gl + glInit(); + + // enable edge outlining, this will be used to show which object is selected + glEnable(GL_OUTLINE); + + //set the first outline color to white + glSetOutlineColor(0,RGB15(31,31,31)); + + // setup the rear plane + glClearColor(0,0,0,0); // set BG to black and clear + glClearPolyID(0); // the BG and polygons will have the same ID unless a polygon is highlighted + glClearDepth($7FFF); + + // setup the camera + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); // setup the light + + while true do + begin + // handle key input + scanKeys(); + keys := keysHeld(); + if ((keys and KEY_UP)) = 0 then rotateX := rotateX +3; + if((keys and KEY_DOWN)) = 0 then rotateX := rotateX -3; + if((keys and KEY_LEFT)) = 0 then rotateY := rotateY +3; + if((keys and KEY_RIGHT)) = 0 then rotateY := rotateY -3; + + // get touchscreen position + touchXY := touchReadXY(); + + glViewPort(0,0,255,191); // set the viewport to fullscreen + + // setup the projection matrix for regular drawing + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(30, 256.0 / 192.0, 0.1, 20); + + glMatrixMode(GL_MODELVIEW); // use the modelview matrix while drawing + + glPushMatrix(); // save the state of the current matrix(the modelview matrix) + glTranslate3f32(0,0,floattof32(-6)); + glRotateXi(rotateX); // add X rotation to the modelview matrix + glRotateYi(rotateY); // add Y rotation to the modelview matrix + + glPushMatrix(); // save the state of the modelview matrix while making the first pass + // draw the scene for displaying + + glTranslate3f32(floattof32(2.9),floattof32(0),floattof32(0)); // translate the modelview matrix to the drawing location + if (clicked = clCone) then + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(1)) // set a poly ID for outlining + else + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(0)); // set a poly ID for no outlining (same as BG) + + glCallList((@cone_bin)); // draw a green cone from a predefined packed command list + + + glTranslate3f32(floattof32(-3),floattof32(1.8),floattof32(2)); // translate the modelview matrix to the drawing location + if (clicked = clCylinder) then + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(1)) // set a poly ID for outlining + else + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(0)); // set a poly ID for no outlining (same as BG) + + glCallList((@cylinder_bin)); // draw a blue cylinder from a predefined packed command list + + + glTranslate3f32(floattof32(0.5),floattof32(-2.6),floattof32(-4)); // translate the modelview matrix to the drawing location + if(clicked = clSphere) then + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(1)) // set a poly ID for outlining + else + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_ID(0)); // set a poly ID for no outlining (same as BG) + + glCallList((@sphere_bin)); // draw a red sphere from a predefined packed command list + + + glPopMatrix(1); // restores the modelview matrix to where it was just rotated + + // draw the scene again for picking + + clicked := clNothing; //reset what was clicked on + closeW := $7FFFFFFF; //reset the distance + + //set the viewport to just off-screen, this hides all rendering that will be done during picking + glViewPort(0,192,0,192); + + // setup the projection matrix for picking + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPickMatrix((touchXY.px),(191-touchXY.py),4,4,viewport); // render only what is below the cursor + gluPerspective(30, 256.0 / 192.0, 0.1, 20); // this must be the same as the original perspective matrix + + glMatrixMode(GL_MODELVIEW); // switch back to modifying the modelview matrix for drawing + + glTranslate3f32(floattof32(2.9),floattof32(0),floattof32(0)); // translate the modelview matrix to the drawing location + startCheck(); + glCallList((@cone_bin)); // draw a cone from a predefined packed command list + endCheck(clCone); + + glTranslate3f32(floattof32(-3),floattof32(1.8),floattof32(2)); // translate the modelview matrix to the drawing location + startCheck(); + glCallList((@cylinder_bin)); // draw a cylinder from a predefined packed command list + endCheck(clCylinder); + + glTranslate3f32(floattof32(0.5),floattof32(-2.6),floattof32(-4)); // translate the modelview matrix to the drawing location + startCheck(); + glCallList((@sphere_bin)); // draw a sphere from a predefined packed command list + endCheck(clSphere); + + glPopMatrix(1); // restores the modelview matrix to its original state + + glFlush(0); // wait for everything to be drawn before starting on the next frame + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Quad/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Quad/main.pp new file mode 100644 index 0000000000..de3745258e --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Quad/main.pp @@ -0,0 +1,101 @@ +program main; +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: cuint16; + +begin + + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + while true do + begin + glPushMatrix(); + + //move it away from the camera + glTranslate3f32(0, 0, floattof32(-1)); + + glRotateX(rotateX); + glRotateY(rotateY); + + + glMatrixMode(GL_MODELVIEW); + + + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + scanKeys(); + + keys := keysHeld(); + + if ((keys and KEY_UP)) <> 0 then rotateX := rotateX + 3; + if((keys and KEY_DOWN)) <> 0 then rotateX := rotateX - 3; + if((keys and KEY_LEFT)) <> 0 then rotateY := rotateY + 3; + if((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY - 3; + + //draw the obj + glBegin(GL_QUAD); + + glColor3b(255,0,0); + glVertex3v16(inttov16(-1),inttov16(-1),0); + + glColor3b(0,255,0); + glVertex3v16(inttov16(1), inttov16(-1), 0); + + glColor3b(0,0,255); + glVertex3v16(inttov16(1), inttov16(1), 0); + + glColor3b(255,0,255); + glVertex3v16(inttov16(-1), inttov16(1), 0); + + glEnd(); + + glPopMatrix(1); + + glFlush(0); + + swiWaitForVBlank(); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Tri/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Tri/main.pp new file mode 100644 index 0000000000..f926b57106 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Simple_Tri/main.pp @@ -0,0 +1,98 @@ +program main; +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: cuint16; + +begin + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + while true do + begin + glPushMatrix(); + + //move it away from the camera + glTranslate3f32(0, 0, floattof32(-1)); + + glRotateX(rotateX); + glRotateY(rotateY); + + + glMatrixMode(GL_MODELVIEW); + + + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + scanKeys(); + + keys := keysHeld(); + + if ((keys and KEY_UP)) <> 0 then rotateX := rotateX + 3; + if((keys and KEY_DOWN)) <> 0 then rotateX := rotateX - 3; + if((keys and KEY_LEFT)) <> 0 then rotateY := rotateY + 3; + if((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY - 3; + + + //draw the obj + glBegin(GL_TRIANGLE); + + glColor3b(255,0,0); + glVertex3v16(inttov16(-1),inttov16(-1),0); + + glColor3b(0,255,0); + glVertex3v16(inttov16(1), inttov16(-1), 0); + + glColor3b(0,0,255); + glVertex3v16(inttov16(0), inttov16(1), 0); + + glEnd(); + + glPopMatrix(1); + + glFlush(0); + + swiWaitForVBlank(); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/data/texture.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/data/texture.bin new file mode 100644 index 0000000000..423699d1f7 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/data/texture.bin @@ -0,0 +1 @@ +µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµ¬µ¬µÎ¹RÊrÎr嬱µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÂ1Æï½µµµµµµµµµµµî½RÊsÎ1Æî½µµµ0Â÷ÞœóÝûÝûÝû¼óXç1Ƶµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½“ΛïœïÖÚ´Ö”ÒQÊï½Î¹µµµÂµÖ´Òã¼÷½÷½÷œóãνRÊ›ï½÷ÞûþûþÿþÿþÿþÿöÞµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµµµµ¬µÍ¹1Æã½ó½ï½óÞ÷þûþÿÞûœórÎ͵RÊã½ó½÷½ó½ó½óÞ÷ÞûÞûÝû“Ò9çÿûÞûÞûÞûÞûÞûþÿþÿÞûÞûZëÖÚß”ÒÂιï½Î¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµÎ¹RÊzëÞ÷½ï½ïÞ÷½÷Þ÷ÿûÿÿÿÿ½÷´Ò8ß|çœç½ïÞ÷Þûþûþÿÿÿÿÿÿû½÷¾ó¾ïÞó½óÝóÞ÷Ý÷Þ÷Þ÷Þ÷ÞóÞóÞóÞ÷Þ÷½÷›ï½÷´Öî½µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µÌµ
¾pÊ-¾í¹¬µµµµµµµµµµµÍ¹”ÒÞ÷Þ÷¾ó½ó½ó½óÞ÷ÿûÿûþûÿûÞ÷ëœçÞ÷ÿÿÿÿÿÿÿÿÿûÿûß÷½ïœï÷Úß{ëÞ÷Þ÷Þ÷Þ÷ÞóÞóÞó¾ï¾ó½ï½ë½óÞ÷þûÿûÝûrÒµµµµµµµµµµ¬µ«±¬±¬µ¬µ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµìµôÖÛÒÒí¹¬µ¬µµµµµµµµµµµrʾ÷Þ÷›ïÖÖßÞ÷ÞûÞûÞ÷Þ÷Þ÷ÿû¾óÞóÞ÷Þ÷Þ÷ß÷ÿûÿûß÷ß÷¾÷0Ƭ¹Í¹Í¹RÊ{ë½ïœëœçëëëœç|ãœç½ïÝ÷Þ÷Þû¼÷Qʵµµµµµµµ¬µ¬µ.¾Êʺìµí¹í¹±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî½¶6Û7ÛÓÎ-¾µ±µµµµµµµµµÍµµÒ¾÷œó1Æι9ã¾ó½ó¾ó¾óÞ÷Þ÷Þ÷¾ó½ïë½ïÞ÷ÿûÿÿÿÿÿÿÿÿÿÿÞûÝûÝ÷YëÂ0ÂsÎ9ãë½ë½ë½ë½ï½ï½ïÝóÞ÷Þ÷Ý÷Þûãµµµµµµµµµ«±M¾òÒÒβʲÊoÆ-¾í¹î½Íµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµí¹ºôÎöÒôÒN¬µ±µµµµ¬±¬µ¬µµµï½:ã¾ózë͹Ûëëë¾óÞó¾óëëëë½ïÞ÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿû½÷zë÷ÞsÎœï½ï½ï½ïÝóÝóÞóÝó½ó½óÝ÷Zë0Ƶµµµµµµµµ¬µ-¾ÒαÊÓÊÓÊÓÎóÒ±ÎOÆ.¾͵¬µ¬µ¬µ¬µµµµµµµµµµµµµµµµµµµµµµµµµµ±±µµµµµµµµµµµµÍ¹ºÔÎõÎÓÊí¹¬±µµµÍµ¾Ìµ¬µ¬±µî¹ZçëZçµ:ßç¾ï¾ï½ïïëë½ï¾óÞûÿûÿÿÿÿßûÿûÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿÿÿÿÞû½÷Þ÷Þ÷½ó½ï½ó½ó½ï½ëÞóÞ÷ÞûÕÚιµµµµµµµµµ¬µ-ºÒÊÓÎÓÊÔÊÔÊÔÊôÒóÖóÖpÆ-¾ìµÍµµµµµµµµµµµµµµµµ¬µ¬µµµµ¬µµµµ¬µµµ¬µµ¬µ¬±¬µ¬µµµµµ¬µµµÍ¹í¹ëµôÒõÒ×±Îí¹¬±¬µµÍµ‘ÊÓβÎí¹µ¬µÍµrʼï»ó›óÞ÷Þó½ïë|çë¾óÞ÷Þ÷Þ÷þûÝûÝûÝ÷¾óßûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÞ÷Þ÷Þ÷Þ÷ÿ÷þûÿÿþÿ’Ò1Æî¹µµµµµµµµÌµoÂÒÊÓÊÓÎôÎôÎôÎôÎôÒÓ×óÒNÂì¹í¹µµ¬µµŒ±¬µ¬µ¬µµµµµµµµ¬±Œ±¬±¬µµµµµ¬µ«±¬±¬±¬µÌµÌ±¬±µµµµµÍµË±-¾NÂ
ºËµ×Ó×ÒÒí¹¬±¬µ¬µ.¾ÓÎÓÎÓÎì¹í¹
¾ì¹í¹³Ò
¾
ºqÊyç½ïëï¾óÞ÷Þ÷½ï›ë’ÎqÊpÆ/¾{ëÿÿÿûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿûÿûþûÿÿÿÿÿ÷ß÷ÞûÝ÷8ãrεµµµµµµÌµNÂÒÎÒÊÓÊôÎ××ôÒ×õÒôÎ××ÑÎN¾¬µµ¬µí¹í¹í¹ÍµÌµÍµ¬µÍµ¬µµ¬µNÂÎ
¾Œ±µ±µ¬µËµNÂÒÒì¹ëµ,¾ÒÒOƬµ¬µµµµÍ¹ì¹6ÛÓÎôÒO²Î××ÓÒí¹µ¬µ
¾ÓÎôÎ×pÆpÂôÒÔÒôÖôÖNÂpÆבÊ.¾YçÞ÷ÿûÞ÷¾ó¾ó½ó’γÊöÒõÎ
º7ãÿÿÿÿÿûÿ÷ÿûÿÿÿÿÿûÿûÿûÿÿÿÿÿÿÿÿÞû¼óÿûÿûþûþûþÿÿûÞó¾ïßóÿ÷ÿû›ï´Öµ±µµµµÌµNÂÓÎÓÎóÎôÎ×ß7ãxçÛ×ôÒôÒÛóÖoÆ.¬µî¹.¾ÛÛNÂì¹N²ÎÒÒpÊ
¾Ë±±ÊôÖÊ˵µ±µ¬µì¹óÖÔÎpÆ˵±ÊÛóÖî½µµµµÍµ-º6ÛôÎôÒÓÒOÂ7Û×ôÖ
¾Í¹ìµ²ÎÓÎôÒ±ÎNÂôÒ³ÊÓÎôÖÓÒÒÎ.ºõÎײξYëÿÿÿû¾ó¾ó½óOƳÎÓÕÎ
º³Òÿÿÿÿÿ÷ÿ÷ÿ÷ÿ÷ß÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿ÷âî½ÕÖÞûÿûÿûÿûÞ÷ß÷ß÷¾ï¾ïÿûÿÿœ÷±µµµµí¹OÂÒÎÓÎÓÎÒαÊpÆ.Â.¾O¾²ÊôÒôÒ×ÛÛoÆ.¾
¾OÂõÖõÒÓÒ
ºÓÎôÒõÒÛÓÒNÂOÂõÖôÒ-¾Íµ±µ¬µ
ºôÖÔÊôÒì¹ÒÎÛ6߲άµµµµÍ¹-ºxç×ÓÎÒÒ.¾õÖÛÛ
¾í¹O¾ôÒôÒ²Î
ºÊÓÒ²ÊÓÒÓҲΑÊ/¾õÎõÒ×pÊqÊÞûÿÿÞ÷Þ÷½ïpÊ‘Ê×ôξ²Îÿÿÿÿÿ÷ß÷ß÷¿ïß÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿßû{ëQÆ÷Úß÷ß÷ß÷ßó¾ï¾ëßïß÷ÿûÿû{ïî½±µµµµ¾OÂÒÎóÒÒÎÒÎNÂNÂíµí½
¾
ºº³ÊôÒôÒÛÛnÆ˵ºôÖÓ×ôÎôÒ×õÒôÒÓÎóÒ‘ÊpÊÛPÆ͵µµ¬µºÆõÎ6ß
¾ÓÒÛ5ÛóÖ
¾±¬µµ¬µ
ºÛôÒôÒóÒ
º×6Û6ß.¾õÒõÒóÒ
ºì¹M¾ôÖ‘Æ
ºí¹ì¹O¾öÒõÒõÒ×6ß¾ßÿÿÞûÞ÷œëqʲÎÛ×.¾NÂÝ÷ÿÿÿûÿûÿ÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿÿûßó¾ïµÒµÒÞóßóßóß÷ÿûßóßóÿûÿûÿûYçιµµµµµ¾NÂóÒóÒÒÎÓÒÓÒ
¾º¬µµÍµ-¾
º×ôÒ×ÛóÖNÂ˱ÒÎÓôÎÛ6ßÓÒpƑʲʑƱÎNÂבÊí¹µµ¬µº‘ÊõÎ7ã
¾óÖÛôÖ5ÛÊ̵µµ¬µí¹5ßôÒÓóÖìµôÒ6Û6ßÓÒõÖ7Û×oÆì¹ËµoÆ×ÒÎ̵¬µÌµ‘Ê×ôÒõÖÛ6Û’ÎO¼óÿÿÿû½ïrÊôÚÛôÒpÆO¼÷ÿÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿ÷ß÷ß÷zïsÎÞûÿûÿûÿ÷ß÷ÿûÿûÿûÿ÷ÿû›ïιµµµµµî¹OÂóÒÓÎôÎôÒÛÊ
¾¬±¬±±Íµì¹ÓÒ6ÛÓôÖ5ßÒÖN²Î7ÛõÒ×ó־͵í¹o±ÊÊOÂבÊ̵µµµ
¾±ÊôÒWã
ºÛÛóÒ6Û×O¬µ¬µ¬µì¹±ÎÒÎ×Û
¾6ß7ß6ß7ß7Û7ßÛ
ºÍµËµÆÛÒÒ«±µÍ¹pÊôÖôÒ×ÛÛÛ.ÂÔÖ½÷ÿÿÞ÷’ÎóÒôÎÒÊpƺzëÞûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûßûß÷ß÷9çÖÖÿûÿûÿÿÿÿÿûßóßóßóßóÞûrεµµµµµÍ¹.¾ôÒôÎôÎôÎÛÓÖ
ºÍµµ¬µ¬µËµoÆÓôÒ×6ß6ßÊPÆõÖÓÊÔÎPÂí¹¬µÍµìµ
ººÓÎבÊ̵µµµ.¾ÒÎôÒ6ß-¾ÓÖÒÒÒÎ××ÒÒ
ºµ¬µì¹ÒÒÒÎÓÎÛ-¾6ß6ß6ß6Û7Û7ß±Î쵵˵ÆôÖÒÎí¹Ìµí¹.¾qÊÛôÖ×ÛóÖ²Îìµ7ãþûÞû²Ò³ÎõÖôÒoÆëµ/µãÿÿÿÿÿûÿ÷ÿ÷ÿûÿÿÿÿÿûÿûß÷ßóÞó½ï¾óß÷ß÷ÿ÷ßûßûß÷¿ïßóÿûœïµµµµµµÍ¹.¾ôÒôÎÓÊôÎ×óÖ͹µµµµ«±²ÎôÒóÒóÒÛxç±ÎOÂÒγÊÔÎoÆ͵¬±µ¬µËµ.¾×ôÒ‘Î̹µµµ/ÂÒÎôÒÛ.ÂÛÛ±ÊóÒ6Û5ßoÆ칬µí¹ÓÒóÒÓÎÛ.ÂÛÛ×7ß7ÛÛoÆ̵µëµ±ÊôÖôÖóÖÓÒÓÒÊOÂ6ßÛôÖÛÛÛ.Â/½óÞ÷³ÖõÖ×ôÒ‘ÆëµôÚrÎ͹”Ò¾óÞïÿûÿûÿÿÿÿÿÿÿûÿûÿûÿûÿûÿûÿûÿûÿûÿÿÿûÿûÿ÷ßóß÷ÿÿãî½µ±µµµµÍµ.ÂôÖôÒÓÊÔÊ×Ûí¹µµ¬µí¹º×ÒÎÒÎóÒ×yçÒÒNÂÓÒÓÊõÒpÆŒµµµµÌµ-¾×בÎ̱µµµ.¾ÓÒôÒÛ.ÂßÛ±ÊóÖ6ã6ßÒÒº¾ì¹oÆôÒôÒôÖ-¾óÖÓÎ×7Û7ÛWãÛº.Â˵±ÊÓÒóұʱÊÒαÊ.¾×6ÛÛôÖÛ7ßÛ
ºöÚþû²ÒÛÓôΑÊëµßÞÿ{ïî½sʾïÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûßûÿûÿûÿûß÷ÿûß÷¿ï¾ë¾óßöÞιµµµµµÍµ-¾ôÖ×ÔÊÔÊôÒÛ
¾ÍµÍµ
¾ì¹ôÖ5ßóÒÒÎôÒÓ6ß±Î-¾ôÒôÎõÒpÆŒµµµµì¹N¾××óÖ«±µµµ
¾ÓÒôÒ×-¾ÛÛÆƱÊóÖ5ßNÆ
ºí¹N¾Ó×óÖ
ºÓÒõÒ××6ßWãôÖ±Î뵺ôÖÒÎÆƱʱαÎ
¾ôÖóÒÛôÖõÖÓÕÎÓÒ
¾›óÓÖÔÎÓ×oÆìµôÖÿÿÿÿ9닱ßß÷ßóÞïßóßó¾ï¿ï¿ï¾ïßóßóÞóß÷ß÷ßóßóßóßó¾ëžã¾ëß÷½÷µµµµµµ-¾ÓÒ×ÔÎôÎôÖÛÊ
¾
º
ºõÖ7ÛôÒÓÊÓÎÓÎ×5ßÆ.¾×ÓÎôÖpʵµµµÌµ‘ÊôÒÛ5ß̵µµµì¹±Î×6Û.ÂÓÒÛÒÎÒÎÒÎÒÒ۱κ.Â-ºÓÎ6ÛÛ¾Û7ÛÛ6ßÛÊÛ6ß/Â/ÂÛÆƱʑÊpÆOÆ.¾±ÊóÒÓÒoƲÎÓõÎ6Û.¾pƲΒÊõÒÛ±Îëµ’ÎÞûÞ÷½óÂÛžçžããããžã¾ëßïßóß÷ßóßó¿ï¾ë¾ë¾ë:ß÷ÖžçãßóÿûþÿµµµµµµN±Ê×ôÎõÒ×ÛÛ‘Ê’Ê×ÓÔβʲÊÓÎÒÎóÒÒÒ-¾pÆÓÒóÒôÒʬ±µµµÌµ²ÎÛÛÛ̵µµµí¹±Ê×6ã.±ÊôÖ6ßÛÊÒÒÛôÖìµëµ.¾ôÎ×ôÖ¾7ß××xç¾NÂÆ6ßóÖì¹ôÚóÖÒÎÊì¹ì¹
ºÓÒóÒ²ÎÊ/ÂpÊOÂÓõÎÓÎOº‘ÊÓÊõÒ’Îìµ8ãÿû¾ïç[ß|ß\ß\ß}ß}ãžç¾ëßïß÷Þ÷{çœë¾ï¿ï¾ë¾ï¾ïrÊRÆžç¾ëÿ÷ÿÿ¼÷͹µµµµµµ-¾/Â6ß×Û7ß7ß×õÒõÒôÒôÒôÎÓÊÓÎôÒ×ÒÒoÆìµpÆóÒÓÊÓΑʬ±µµµÌµÓÖWã×6ß-¾Ìµ¬±¬µ.ÂÒÒÛxëNÂÓÎ×5Û.ÂʱºÛ6Û‘Ê.¾±ÊÓÎײκÛôÒ6Û6ßì¹pÆ
º×ôÖpÆìµôÖóÖ-¾¬±î¹
ºÛôÖôÖ‘Î’Ê8ߺôÖõÒ6Û×ôÖõÒõÎôΒʺõÚœïë:ßÖÒ:ß}ã¾ëÞóßóßó¾ï¾óÞóßQÆ÷Úß÷ßóß÷ÿ÷œï1Æ:ß¾ë¿ïßûÝû”Ö¬µµµµµµ¬µ
¾-¾6ãWç6Û7Û7Û7Û×óÎôÒôÎôÒôÒôÒ×5ÛoÆ.¾.¾-¾ÒÊÒÊÓβά±µµµÌ¹ôÚ6ß×6ßÓÖëµÌµí¹²Î6ß6Û6ßNÂÓÎÓ6ß-¾-¾ËµôÖóұʱÊÒÊóÎ×ÒÒº²ÎôÒôÖôÖìµ¾
ºÓÒôÖÓÒ
ºpÆÒÒ
ºÍ¹Í¹¾ÓÖÒÎÒÒ²Ò¾Xã.¾qÊVßôÖÛ6ßôÒÔÊײҺ̵µï½Í¹‹±Íµ”ξ÷ÿû¾ï¾ï¾óœïÖÚî½Â8ãÞ÷ÿûÿûÿûÞ÷çžë¿ó½ó÷Þ0Æ͹µµµµµµµ
¾ºßxë6ß6Û×××ÓõÎõÎõÎõÒÓóÒÊ
ºëµ.¾oÆÒαÆÓÊÒÒ͵µµµí¹ôÚ5ß××ÛÛôÖÛ7ß7ß6߲κÔÎõÒÛ.Âí¹ì¹ÒÒÒÒ±ÆÓÊóÒ×±ÎëµÓÎôÒ×Û¾¾
¾±ÊôÖóÒ²Î
¾ÓÒOÂì¹OÆ.Â5ßÓÎÓαÎ
ºXã³ÎOÂWã×Û×ôÖôÒ5ۑκÔÒÖҔΔÎ÷ޔξrÊ8ã9ããÕÖ0Æ0ÆÂÖÚßûÿûÿûÿûß÷ßóßóÞ÷÷Þî½µµ¬µ±µµµµµµÍ¹º²Îšï6ß×××7Û8×Ó8×7ÛôÖÊ.¾.ÂôÖôÖ¾OÂóґƒƲʾµµµí¹ÓÒWã××ÛWßXã7ß7ß7Û6ÛoÆìµõÖÔÎôÒNÂ͵ì¹OÆôÖ²ÆÓÎôÎôÒ6ÛÊ˱ôÖ××ôÒ.¾í¹OÂpÆÛôÒÓÎOÂpÆóÒPÂpÆPÆOÂÓÎ×ôÖ.¾Zã8ßì¹ôÖ5Û××××ÛÒÒëµÛ|ã[ã9ß9ã¾ï[ã”Ò0Â0ÂQÆsεҔÎrÊÞ÷ÿûÿûß÷ßó¿ïß÷ÿû8笱µµµµµµµµµµµÍµ
ºoÆwçxç6Û7Û6ßÛõÖÓұΑÊoÆpÆÓÒôÖ×6ßóÖ.¾óÒÒÎÒÎÊì¹µµµî¹-¾Wã6ßÛXãXßWß7ßXß7ßÓκ˵ÓÎÒÎ×oÆí¹Í¹
¾×õÎõÎôÎ×ôÖ,¾Ë±²ÎôÖÓÊÔÎ.¾Íµ/ÂìµÓÎ7ßÓÒÓÖ
ºóÒÂÓÎôÖPƲÊõÎöÒ.¾zçœëpÆpÆ6ß×××ôÒôÒóÖì¹×}ã[ã9ß\ã~ß}ã[ã}çëœë[ç:ãQÆãÿÿÿûß÷ßó¿ïßóÿûßû’Ò¬µÎ¹µµµµµµµµµµµ¬µ
ºO‘ÎÊpÊpÆ.Â.¾qʲÎôÖ6ßXãWß6ß×5ß6ß.¾NÂNº̵µ±µµµÌµ
¾±ÎôÖXãXãWã6ßôÚʺí¹ìµÊÒÒÓÖì¹ÌµµÌµpÆôÒôÖÒÎÆNÂ˵칱ÎßÛʾ±Í¹
¾oÆ7ß×ôÖ.¾ÛÆ‘ÆÓÒpʳÎÛôÒºZßZçÔÖ
º6ßÛ×õÒÓ×ÒÎìµÛ|ãZç:ßÓ<×|ççžçç|ë{çµÒrʽóÿûÿûÿûÿ÷ß÷ÿûß÷ë0¬µÍµµµµµµµµµµµµ¬µµ¬µÍ¹¬µ¬µµí¹±ÎWã7ßXãzçÛÓÒõÖ6ß6ã6ßÛ.Â̵µ¬µµµµ¬µµ¬µ¬µ¬µí¹ìµìµ
¾ì¹Ìµ¬±µ¬µÌ¹Ë±ëµìµÌµµ±¬µËµìµì¹ëµËµÌµµÍµì¹-¾-¾
º/Â͹¬µí¹
¾-¾
¾
ºOÂÛôÒ²ÎpÊ
º-¾oÂ.¾PÂzç9ãYç’Î.¾²ÎÓÒÓÒ²ÊpÆìµ0º[ßZçZã;Û<×|ã|ç¾ë}ã}ç{ë|ëQÊãÿûÿûß÷ÿûÿûÿûÞ÷9ãSÆtÊrÊ͹±µµµµµµµµµµµµµµµµµì¹ôÖ7ß7ÛYãÛ
¾
¾.¾7ßXç5ß6ãÎ͵µ¬µ¬µ±±±µµµ¬µ¬µµ¬µµµµµ¬µµµ¬µÍ¹í¹í¹í¹ÍµÍ¹ÍµÌµì¹.¾.¾í¹Î¹µÍ¹.¾
º
¾
¾
¾/¾µÍ¹Í¹î¹0¾qÆqÆqʳÒÛµÎÕÒ÷ÖZßZã:ã[ßZß÷ִγγғÎÕÒÖÒ[Û|ç{ç\ß]Û}ã|ëçç|ã|ç|çÖÒsξ÷ÿûÿûÿûÿûÿûÞ÷µÒ¾¶Æ;×øÚ͹µ±µµµµµµµµµµµ¬µ¬µµµµ
¾6ßXã8ßYßqÆ̵±¾qÊ™ïxë6ãOƬ±Íµî½¾N¾¬µ¬µ«±Ëµì¹ì¹«±¬µ¬µ±µµ¬µí¹ì¹.¾OÂʲÎÊìµ
ºoƱÎÓÒpÆ
¾
º.¾N¾²Ê²Ê‘ÊÆNÂ.ÂιRÆøÎ[ß{çZë8ß\ß|ßçç{ë9ç{ã|ãçç{ç9ßç}ãã}ã|ã[ã\ã<Û}ß|ë|çã}ã}ç{çZã0Â:ã¾ïßóß÷ßóßóß÷œï¾–ÆùÎ\ß{çµµµµµµµµµµµµµµµµµµ
º×ÛXßYãºÍ¹µ¬µî½/ÂPÆí¹¬µ¬µ.¾pÆÓÒôÖÊ
¾ì¹¾Ìµ
ºôÒ×6ßÒÒ
¾ÌµÌµµµµìµôÖ×ôÎôÒÛÛO‘ÎôÒ‘ÆpÆÓұʺ.¾ÓβÊÓÒõÒÔαÊNÂ͹͹0Â×Ê:×{ã{ëYç{ã|ß}ã}ãëZë{ëœçžëççZç[ã}ß}ß}ß\Û\ã[ã\ß]ßçœëë¾ëžëë|ã”ÎQÆ}ç¾ë¾ë|ë|ëÞ÷ÞûãsÆ×\ßç¾ïrιµµµµµµµµµµµµµµµµ¬µ
º×7ÛXßXã-¾í¹µµ¬µµ¬µ¬µ¬µí¹ÓÒ6ÛXß7ßWã6ßÓÒ
¾.ÂOÂYã×ôÒôÒ5ßÛoÆì¹Íµ¬µËµ³ÎõÒõÒÛ6ã6ãNÂÓÒ
ºÌµÍ¹¾²ÎNÂO²ʑʺ
º³ÎÛoÆιï½tÆÏ|ã{ã{çZç|ã}ã}ß\Û{çZëëëžë½ë{ç[ç}ç}ß}ß]Û\ß;Û\Û]ßçœëë¾ë¾ï¾ï\çøÖï½ÕÖ½ïë[ç1Æ1ƵÖsÎÊ}ãžçžëžë÷Úιµµµµµµµµµµµµµµµµ¬µ/ÂÛ6ÛXãWçºÍµ¬µµµµµ¬µ¬µOÂÛÛyçXãWãyëXçÛºpÊšëXßôÒ³ÎôÒõÒôÖ²ÎìµÍµËµOÂ×õÖoÆ
¾
ººÓ¬µOÂpÆʺ²Ê.¾¾.Â.±ʾ×Ê[Û|ç{çZç{ççžç\Û|ãZëœïëç}ãœëzë|ç}ß}ß]ß}ß|ã;Û\Û}ãë|ë¾ï¾ë¾ï|ë:Û1Âî½Î¹0¾͹ι͵ιι¾•Êçžçžë}ãZãï½µµµµµµµµµµµµµµµµŒ±pÆXßXãšïšï
ºÍ¹µµµµµ¬µÍ¹ÓÒ7Û6ÛÓÒoÆpÆÛXãÛÊ-¾yë7ßõÖôÖÓÒ×Û6Û±Î칩pÆõÒ‘Æʱí¹ì¹oÂôÒ‘Æìµí¹OÂÒÒnÆ.ºÓÎ-¾¾µî¹Ì¹î¹î½RÂÓ\ß|ç{ç{ç|çã}ß}ãœë{ï½ïççœç{ëZç}ã}ß}ß]ß}ç:ß;×<×ç|ç¾ï¾ëžç½ó|ç۾ιµµµµµµµµQÆ×Ö¾ë¾ï¾ï}ã{ç¾µµµµµµµµµµµµµµµµŒ±pÆXßYãyç7ç.Â͹µµµµµÍµí¹õÚ6ß²Ê
ºî½OÆ-¾ôÖ6ÛóÖêµôÖXãÛ
¾OÆOƲÎ×6ßÎʱ³ÎõÒ²Îëµî½í¹ÊÓÎÒÎÓÎÓÒÓÒ,ººpÆÓÒOºOÂ/Âî½î¹ºÖÊ:×|ã{ëZç[ã|ã}ß<×}ç{ïœëëç}çœë{ë|ç}ã}ã\Û}ã|ç;ß<×[Û:ßçžë}ãžëœï{çsÊï½µµµµµ¬µµµµ0Âß¾óßó¾ïçZç͹µµµµµµµµµµµµµµµµ‹±¾Xãyç™ëxëÂ͹µµµµµÍ¹ìµ7ãxë.¾¾±µOƲÎXãÛ뵑ÊXã7ß.Âî¹î¹.¾²ÎWãßNÂ.¾õÖÓÖoÆ.¾.¾ºÓÒÓÎÓÎôÖ-¾ëµÊ±ÓÒôÖÓβÊpÂOƺ¾ÕÒ:ÛלëZçZã|ã\ß\Û\ß|ëœïëç}ãë{ë{ççžç}ß}ßë[ã;Û\Û{çZãçžçç¾ó{çÛï½Î¹¬µµµµµµµµÍ¹0Â\çßóß÷¾ëžë8ãî½µµµµµµµµµµµµµµµµ«±ìµ7ßxçxçyëÂ͵µµµµµí¹ëµôÖyç‘ʾ¬µµ.ÂPÆXçWã,¾oÆ7ß7ßPÆ͹µ¾PÆÛßoÆí¹××õÒ×ÛOÆpÂôÒôÒoÆNÂ-¾ìµ-¾‘ÊÓÒÛõÖÛõÖ.¾º9ß{ãœëZç|ç|ß]Û<×çœëœë}ã|ß}ãœë|ëç}ã}ß\Û|ç[ã;Û\Û|ç{ç|çžçžç¾óï{çrÊïÁ±µµµµµµµµÎ¹1Â\ã¾ï¿ïžç¾ïÕÚî¹µµµµµµµµµµµµµµµµÌµëµßšëyë»óOÆ͵µµµ¬µÌµì¹º
¾‘Ê7ÛÔÖ͵µ/ÂpÆXçWçnÆ
º6ÛÛOƵµµ.¾²ÎÛ±Îì¹ôÒ7ßÛ6ßWã²Î‘Ê×õÒ×ÛôÖOÂ
ºí¹.¾¾OÆõÖõÒóÖ-¾“ÎzçZç{ç|ã\ß<×}ß{çœëç|ß\ßœçœïëžç}ã\Û}ã[ç:ß|ß¾ç|ë|ë}çç¾ï½ó[ç÷ÚµµµµµµµµµÎµ¾¶Îžç¾ëžç}ãï0ÆιµµµµµµµµµµµµµµµµÍ¹ëµÓÒXãyëÜ÷ÓÖ͵µ±µÍ¹.ÂÒÒß6ã.³ÎX㾬µ¾.¾ÛÛ.Â
¾7ß6ßpÆ͵¬µµ/‘ÊóÒÒÒìµÓÎ6ãôÚNÂʵ˱6ßÛÛÛöÖ6ÛÓÒí¹µµÍµ.Â.¾õÒÔÒMÂ/¾Yã9ã{ç}ã\Û<×|ã{ëœï}ã}ã|ãœëœï¾ëžç\ß|ß|ç9ß;Ûç½ëœïœëçë¾ó|ë[ãQÆï½±µµµµµµµµ¾¾×žçžçžç}ãøÚ¬µµµµµµµµµµµµµµµµµµµÌµ³Ò™ëyë¼óßî½±±µí¹ÒÎ6ÛÛ6ßOƲÎ7ß.±Â.¾6ÛÛ.‘ÎXã7ßPÆµ.Â.²ÎôÖÓÖ
ºÓÎÛ.Âí¹Ìµ.¾šïßÒÒìµ/¾ÓÎôÒ¾¾Íµ¬±/Â-¾õÒôÒoƾ8ã9ã}ç}ß<Û\ß|çœï½ï}ã}ã|ë›ë½ëžç}ß\Û|çZãÛ\ßžë½ï¾ó¾ïç¾ï½÷{ãÖÖî½µµµµµµµµ±ÎµRÆØÒ\ß}ßžç~ã\ßQÆ͹µµµµµµµµµµµµµµµµµµ¬µ.™ïšëyë7ãOÆí¹î½í¹qÆôÒôÎôÖÛNÂÓÎÛOÆPÆpÊOÆ7ßôÖ
¾õÚzçÛOÆ/Â.ÂNÂqÆ7ßWãÓÖì¹ôÖóÖ
ºí¹Ì¹oÆxëß‘Î
¾ì¹pÂõÖ‘ÎOÂì¹ìµìµÓÒ8ßWãoÆqÆYç{ç}ã]ß]ß|çœï½óë\ß|çœïœï¾ë}ã<Û\ã|ç9ß;×ã¾ï½óÞóëë½óœë[ã1Âï½µµµµµµµµµRÆ•Ê<Û\Û~ã}ã\Û×Ö͹µµµµµµµµµµµµµµµµµµµµÌµõÚšë™ë»ó6ßOÂOƲÎÛ××6ßÒÒ-¾ôÖõÒÓÎpÆ‘ÎÛVã‘Î
º7ãyç×OÆ.¾N³Ò7ß7ßÛÊ/ÂÛ6ßOÆʱ˱ʱÓÒXãßí¹¬µpÆ6ßõÚOÂÔÖ³ÊÔÒXãyçôÚ
ºöÖzçç}ã]ß}ã|ç¼ó¾ï}ã}ßœë{ëïë\Û]ß}çZã×;מë¾ïÞó¾ë}ãçœë[ãßï½Î¹µµµµµµ±µ1ÂsÆ;Û}ß}ãžç~ç:ßÂ͹µµµµµµµµµµµµµµµµµµµµ¬µ.Â7ãšëšïšëXçXã7Û6Û7Û6ÛÛpÊ.¾ÛÛõÎÓ7Û6ßÛ
¾ì¹ôÖ7ß6ßÛôÖÛ6ß6ßÛóÖì¹³ÒÛ×ÒÒNÂN¾oÆ
ºöÖ7Û¾µ
ºôÖXçN²ÎôÖõÖ7ã5ßpÆ“ÎZç|ç|ß}ã]ßçï½óë<Û\ßœïœï¾ï}ß;×|ã[ç:ß;×]ß¾ï¾ó¿ï}ã}ãë{ç:ã1Æï½±µµµµµµµ0ÂRÆ×}ãžçžçç|ç´Ò͵µµµµµµµµµµµµµµµµµµµµµ¬µî¹PÆWãyçXãXß7Û7Û6Û6ßôÖ‘Êí¹Í¹pÊxç×ÕÊ×ôÖOÆpÆ6ÛÓÒôÖÛÛÛ±ÎNÂìµÌµÛ7ß×7ÛÛ6ÛÛ
¾ß7ã
¾µí¹±Î7ãÊ˱-¾‘ΑÊpƳÒ8ã{ç}ã}ß]Û]ßëœï½ï\ß<Ûëœï½ïžë\Û;Û|ç:ß:×\Ûçï¾ëžç}ãçœë[ãÖÖιµµµµµ±µÎ¹¾”Ê;Ûžç¿ë¾ë¾ë¾ï÷Úιµ±µµµµµµµµµµµµµµµµµµµµµµµ¾²ÎÛ6Û6Û×ÒÎÊ.¾Íµ¬µµ.¾pÆõÖ³Îqʾ͵¬µí¹-¾±ÊÒÒÓÒÊOÆ.¾Ìµ¬µµ«±³ÒXã×YßXãÛÒÒì¹.Â
ºÌµ¬±Íµ-¾Û²Ò¾’ΓÊõÖYçzë8ã|ç}ß]ß]ßçœï½ïë]ßç{ëœïï}ã\Û|ãZã:Û;×\ßëëã~ãçë{ã[ã1Æ鱬µ±µµÎ¹ï¹¾¶Î\ãžë¾ï¾ï¿ïÞóZçî½µµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±í¹í¹¾í¹Ìµ¬µ¬µµµµÍµí¹í¹¾î¹µŒ±µ¬±¬±¬µÌµÌµ¬µµµ¬±¬µµÌµì¹.¾
¾¾í¹ì¹ËµÌµ«±¬µ¬±±µ
ºôÚ7ãOÂrÂ×{ãZç9ã[ç|ã}ß\ß}ãëïžë}ß|ß½ï{ïœïç}ãç{ë:ß;Û<×}ãë}ç}ß}ãë|ç[ß÷Öî½µµµÍ¹î¹ï¹¾–Ê<Û}ã¿ë¿ï¿ï¿óßóYçµµµµµµµµµµµµµµµµµµµµµµµµµµµ±µµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµ±µµµµµµ±¬µÌµ‘ÊXã²Î
º×ZßYã9ã|ã}ß|ß}ßçœë½ï}ç\Ûžë½óœïë}ãçœëZã:Û<×\ßëç\ß\Ûçœï[ã[ß1Æï½Î¹Î¹ï½1Æ•ÊùÖ<Û~ãžãžçžç¾ë¿ïÞ÷ãµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµÍµ
ºõÖ7ÛpÆOÂ8ßYç{ç|ß\ß\ß|ãœëœëë\Û}ã½ó½ó½ëç}çë[ç:ß;×<×|ãë}ã}ß}çë{ç[ßÖÒ”Î:ßß:ãœï¾ïžëžçžçžã~ã}ßžã¾ï½ó´Öî¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÌµpÆ7ÛõÒOÂpÆ8ã|ç|ã\ß}ßë{ëë}ã\ßïœïëç}ãç|ëZã[ß<×\Û}ë}ç}ãžç¾ïœë[ã:Û1¾<Ûžç¾ëžë¿ë¿ëžë¿ë¾ëžã~ç\ß:ßÖÖ0Â͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹’ʺÓÎÓôÎOÂ.¾Ûzã[ß\ãœë|ëç\Û|ãœóœïëççëZã[ß\ß\ß}çëã}ãžëï{ç;Û”ÊuÆžë¿ó¾ï¾ï¿ï¿ïžç~ã}ã;ß×ÒRÆï½µµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Æ9ßÆ
ºôÒÔÎ×pʾ8ß[ß|ç{ëœç|ß\Û|ë›ïëç}ã|ç{ë[ã\ß|ß|çïžë}ãžç¾ï|ë;Û×RÂ;Û~ççžçžçç[ãÛµÎRÂï¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹ÖÒ\ãyç.Â-ºôÎÓ6Û‘ÊrÆ[ß|ç|ç}ç;Û|ã{ëœëç}ã|ã{ë[ç\ã}ßç½ïëžã~ãžë¾ï[ãÓ•ÎsÆÛøֶΔÊRÆÂï¹Í¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Â×\Û{ã8Û.¾NÂôÒÛ±ÎqÂ[ã{ç|ç|ã[Û{ç{ëœë}ç\ß|çZã[ã|ß|ãëëžç}ã}ãžëœë×øÎî¹ï½Î¹Î¹µµµµ¬µµµµ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ØÒ<×}ã|ßZßßOÂ.ºoÆqÆ×{ã{çë|ã{ã{ëœëç\ß[ßZçZã|ã}ãœë½ëç}ß]ßçœë[ç:×R±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï¹Ó;×\ß[ßZã9ßZß××[ß|ã[ß{ã|ã[ß{ã{ç|ç|ã[ß[ç:ã[ß|ß|çïç}ß\Û}ßë{ç[ß÷Ö͵µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±ºÓ\Û\ã[ß9Û:Û;Û[Û|ß}ã[ß[ß|ã[Û:Û:ß[ß[ß\ß|ãYãZã\ß|çïë}ã\Û\Û}ã|ç:Û9×1µµ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬±ð¹ùÎÓ|ãç{ç:ß[Û\Û|ß|ã[ß{ã}ã|ã[ã[ã[ß;Û;Û:ß:ß|ç|ãœëœï}ã}ß<Û}ß|ç[ãϵÎ͵±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹sÂØÊ;Û[ß{ãZã[ã[ß[ã[ã{ã|ß|ãç{ã[ã\ß;Û:Û×:Û|ã{ãœëœë|ã\Û\ß|ã|ç×øÎï¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹1¾×Ò:Û;Ûëë}ç|ã|ß\ß\Û|ß|ç{ã[ß:Û:×9Û:ß|ã[ß[ã|çë}ã\ß|ã|ã[ß:×sÊ͵¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½1µÎ[ã|ãç¾ëžç}ã\Û\ß\ß\ß[ß:Û:Û;ß[ß[ã|ã[ã|ã|ã|ß}ß|ã[ã;×øÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½sÊøÖ\ã}ççççç}ã\ß;Û;Û[Û\ß[ß[ß\ß\Û\Û\ß}ã[ã[ß:ÛrÊιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µ¬µµ¬µÍµ0ƵÒZãëë|çç|ç|ã|ß|ã\ß\ß;Û;Û\Û\ß|ã[ã[ß;Û÷Öï½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹RÆß{ç{ç|ç|ã|ãç|ã|ã[ß:Û[ß[ßZß[ã[ß;ßRÊ͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµÎ¹QÆÖÖöÚ{ç|ç|ã|ß}ã|ã:ß:ßZãZã|ç;ÛÖÒî½±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ±±µ¹î¹1ƵÖß[ã|ã|ß\Û|ß|çë\ßøÒ0Âι±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½î¹tÊøÖ×\ßžç}ã[ßµÎιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹î½ÂRʵÒ×ÒÖÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµ±µµµÍ¹Î¹ï½î½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµŒ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/main.pp new file mode 100644 index 0000000000..0f4b096414 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Cube/main.pp @@ -0,0 +1,196 @@ +program main; +{$L texture.o} + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +//texture_bin.h is created automagicaly from the texture.bin placed in arm9/resources +//texture.bin is a raw 128x128 16 bit image. I will release a tool for texture conversion +//later +var + texture_bin_end: array [0..0] of u8; cvar; external; + texture_bin: array [0..0] of u16; cvar; external; + texture_bin_size: u32; cvar; external; + +var + CubeVectors: array [0..23] of v16; + CubeFaces: array [0..23] of u8; + uv: array [0..3] of u32; + normals: array [0..5] of u32; + + +procedure Initialize(); +begin +//verticies for the cube + CubeVectors[0] := floattov16(-0.5); CubeVectors[1] := floattov16(-0.5); CubeVectors[2] := floattov16(0.5); + CubeVectors[3] := floattov16(0.5); CubeVectors[4] := floattov16(-0.5); CubeVectors[5] := floattov16(0.5); + CubeVectors[6] := floattov16(0.5); CubeVectors[7] := floattov16(-0.5); CubeVectors[8] := floattov16(-0.5); + CubeVectors[9] := floattov16(-0.5); CubeVectors[10] := floattov16(-0.5); CubeVectors[11] := floattov16(-0.5); + CubeVectors[12] := floattov16(-0.5); CubeVectors[13] := floattov16(0.5); CubeVectors[14] := floattov16(0.5); + CubeVectors[15] := floattov16(0.5); CubeVectors[16] := floattov16(0.5); CubeVectors[17] := floattov16(0.5); + CubeVectors[18] := floattov16(0.5); CubeVectors[19] := floattov16(0.5); CubeVectors[20] := floattov16(-0.5); + CubeVectors[21] := floattov16(-0.5); CubeVectors[22] := floattov16(0.5); CubeVectors[23] := floattov16(-0.5); + +//polys + CubeFaces[0] := 3; CubeFaces[1] := 2; CubeFaces[2] := 1; CubeFaces[3] := 0; + CubeFaces[4] := 0; CubeFaces[5] := 1; CubeFaces[6] := 5; CubeFaces[7] := 4; + CubeFaces[8] := 1; CubeFaces[9] := 2; CubeFaces[10] := 6; CubeFaces[11] := 5; + CubeFaces[12] := 2; CubeFaces[13] := 3; CubeFaces[14] := 7; CubeFaces[15] := 6; + CubeFaces[16] := 3; CubeFaces[17] := 0; CubeFaces[18] := 4; CubeFaces[19] := 7; + CubeFaces[20] := 5; CubeFaces[21] := 6; CubeFaces[22] := 7; CubeFaces[23] := 4; + + //texture coordinates + uv[0] := TEXTURE_PACK(inttot16(128), 0); + uv[1] := TEXTURE_PACK(inttot16(128),inttot16(128)); + uv[2] := TEXTURE_PACK(0, inttot16(128)); + uv[3] := TEXTURE_PACK(0,0); + + normals[0] := NORMAL_PACK(0,floattov10(-0.97),0); + normals[1] := NORMAL_PACK(0,0,floattov10(0.97)); + normals[2] := NORMAL_PACK(floattov10(0.97),0,0); + normals[3] := NORMAL_PACK(0,0,floattov10(-0.97)); + normals[4] := NORMAL_PACK(floattov10(-0.97),0,0); + normals[5] := NORMAL_PACK(0,floattov10(0.97),0); + +end; + +//draw a cube face at the specified color +procedure drawQuad(poly: integer); +var + f1, f2, f3, f4: u32; +begin + f1 := CubeFaces[poly * 4] ; + f2 := CubeFaces[poly * 4 + 1] ; + f3 := CubeFaces[poly * 4 + 2] ; + f4 := CubeFaces[poly * 4 + 3] ; + + + glNormal(normals[poly]); + + GFX_TEX_COORD^ := (uv[0]); + glVertex3v16(CubeVectors[f1*3], CubeVectors[f1*3 + 1], CubeVectors[f1*3 + 2] ); + + GFX_TEX_COORD^ := (uv[1]); + glVertex3v16(CubeVectors[f2*3], CubeVectors[f2*3 + 1], CubeVectors[f2*3 + 2] ); + + GFX_TEX_COORD^ := (uv[2]); + glVertex3v16(CubeVectors[f3*3], CubeVectors[f3*3 + 1], CubeVectors[f3*3 + 2] ); + + GFX_TEX_COORD^ := (uv[3]); + glVertex3v16(CubeVectors[f4*3], CubeVectors[f4*3 + 1], CubeVectors[f4*3 + 2] ); +end; + + +var + textureID: integer; + i: integer; + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: u16; + +begin + Initialize(); + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + //enable textures + glEnable(GL_TEXTURE_2D); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + vramSetBankA(VRAM_A_TEXTURE); + + glGenTextures(1, @textureID); + glBindTexture(0, textureID); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture_bin)); + + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + while true do + begin + + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + glLight(1, RGB15(31,0,31), 0, floattov10(1) - 1, 0); + glLight(2, RGB15(0,31,0) , floattov10(-1.0), 0, 0); + glLight(3, RGB15(0,0,31) , floattov10(1.0) - 1, 0, 0); + + glPushMatrix(); + + //move it away from the camera + glTranslate3f32(0, 0, floattof32(-1)); + + glRotateX(rotateX); + glRotateY(rotateY); + + glMatrixMode(GL_TEXTURE); + glIdentity(); + + glMatrixMode(GL_MODELVIEW); + + glMaterialf(GL_AMBIENT, RGB15(8,8,8)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(5,5,5)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or + POLY_FORMAT_LIGHT2 or POLY_FORMAT_LIGHT3 ) ; + + scanKeys(); + + keys := keysHeld(); + + if((keys and KEY_UP)) <> 0 then rotateX := rotateX +3; + if((keys and KEY_DOWN)) <> 0 then rotateX := rotateX -3; + if((keys and KEY_LEFT)) <> 0 then rotateY := rotateY +3; + if((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY -3; + + glBindTexture(0, textureID); + + //draw the obj + glBegin(GL_QUAD); + for i := 0 to 5 do + drawQuad(i); + glEnd(); + + glPopMatrix(1); + + glFlush(0); + + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/data/texture.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/data/texture.bin new file mode 100644 index 0000000000..423699d1f7 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/data/texture.bin @@ -0,0 +1 @@ +µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµµµµµµµµµµµµµ¬µ¬µÎ¹RÊrÎr嬱µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÂ1Æï½µµµµµµµµµµµî½RÊsÎ1Æî½µµµ0Â÷ÞœóÝûÝûÝû¼óXç1Ƶµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½“ΛïœïÖÚ´Ö”ÒQÊï½Î¹µµµÂµÖ´Òã¼÷½÷½÷œóãνRÊ›ï½÷ÞûþûþÿþÿþÿþÿöÞµµµµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµµµµ¬µÍ¹1Æã½ó½ï½óÞ÷þûþÿÞûœórÎ͵RÊã½ó½÷½ó½ó½óÞ÷ÞûÞûÝû“Ò9çÿûÞûÞûÞûÞûÞûþÿþÿÞûÞûZëÖÚß”ÒÂιï½Î¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµµµµµµÎ¹RÊzëÞ÷½ï½ïÞ÷½÷Þ÷ÿûÿÿÿÿ½÷´Ò8ß|çœç½ïÞ÷Þûþûþÿÿÿÿÿÿû½÷¾ó¾ïÞó½óÝóÞ÷Ý÷Þ÷Þ÷Þ÷ÞóÞóÞóÞ÷Þ÷½÷›ï½÷´Öî½µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µÌµ
¾pÊ-¾í¹¬µµµµµµµµµµµÍ¹”ÒÞ÷Þ÷¾ó½ó½ó½óÞ÷ÿûÿûþûÿûÞ÷ëœçÞ÷ÿÿÿÿÿÿÿÿÿûÿûß÷½ïœï÷Úß{ëÞ÷Þ÷Þ÷Þ÷ÞóÞóÞó¾ï¾ó½ï½ë½óÞ÷þûÿûÝûrÒµµµµµµµµµµ¬µ«±¬±¬µ¬µ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµìµôÖÛÒÒí¹¬µ¬µµµµµµµµµµµrʾ÷Þ÷›ïÖÖßÞ÷ÞûÞûÞ÷Þ÷Þ÷ÿû¾óÞóÞ÷Þ÷Þ÷ß÷ÿûÿûß÷ß÷¾÷0Ƭ¹Í¹Í¹RÊ{ë½ïœëœçëëëœç|ãœç½ïÝ÷Þ÷Þû¼÷Qʵµµµµµµµ¬µ¬µ.¾Êʺìµí¹í¹±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî½¶6Û7ÛÓÎ-¾µ±µµµµµµµµµÍµµÒ¾÷œó1Æι9ã¾ó½ó¾ó¾óÞ÷Þ÷Þ÷¾ó½ïë½ïÞ÷ÿûÿÿÿÿÿÿÿÿÿÿÞûÝûÝ÷YëÂ0ÂsÎ9ãë½ë½ë½ë½ï½ï½ïÝóÞ÷Þ÷Ý÷Þûãµµµµµµµµµ«±M¾òÒÒβʲÊoÆ-¾í¹î½Íµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµí¹ºôÎöÒôÒN¬µ±µµµµ¬±¬µ¬µµµï½:ã¾ózë͹Ûëëë¾óÞó¾óëëëë½ïÞ÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿû½÷zë÷ÞsÎœï½ï½ï½ïÝóÝóÞóÝó½ó½óÝ÷Zë0Ƶµµµµµµµµ¬µ-¾ÒαÊÓÊÓÊÓÎóÒ±ÎOÆ.¾͵¬µ¬µ¬µ¬µµµµµµµµµµµµµµµµµµµµµµµµµµ±±µµµµµµµµµµµµÍ¹ºÔÎõÎÓÊí¹¬±µµµÍµ¾Ìµ¬µ¬±µî¹ZçëZçµ:ßç¾ï¾ï½ïïëë½ï¾óÞûÿûÿÿÿÿßûÿûÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿÿÿÿÞû½÷Þ÷Þ÷½ó½ï½ó½ó½ï½ëÞóÞ÷ÞûÕÚιµµµµµµµµµ¬µ-ºÒÊÓÎÓÊÔÊÔÊÔÊôÒóÖóÖpÆ-¾ìµÍµµµµµµµµµµµµµµµµ¬µ¬µµµµ¬µµµµ¬µµµ¬µµ¬µ¬±¬µ¬µµµµµ¬µµµÍ¹í¹ëµôÒõÒ×±Îí¹¬±¬µµÍµ‘ÊÓβÎí¹µ¬µÍµrʼï»ó›óÞ÷Þó½ïë|çë¾óÞ÷Þ÷Þ÷þûÝûÝûÝ÷¾óßûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÞ÷Þ÷Þ÷Þ÷ÿ÷þûÿÿþÿ’Ò1Æî¹µµµµµµµµÌµoÂÒÊÓÊÓÎôÎôÎôÎôÎôÒÓ×óÒNÂì¹í¹µµ¬µµŒ±¬µ¬µ¬µµµµµµµµ¬±Œ±¬±¬µµµµµ¬µ«±¬±¬±¬µÌµÌ±¬±µµµµµÍµË±-¾NÂ
ºËµ×Ó×ÒÒí¹¬±¬µ¬µ.¾ÓÎÓÎÓÎì¹í¹
¾ì¹í¹³Ò
¾
ºqÊyç½ïëï¾óÞ÷Þ÷½ï›ë’ÎqÊpÆ/¾{ëÿÿÿûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûÿûÿûÿûþûÿÿÿÿÿ÷ß÷ÞûÝ÷8ãrεµµµµµµÌµNÂÒÎÒÊÓÊôÎ××ôÒ×õÒôÎ××ÑÎN¾¬µµ¬µí¹í¹í¹ÍµÌµÍµ¬µÍµ¬µµ¬µNÂÎ
¾Œ±µ±µ¬µËµNÂÒÒì¹ëµ,¾ÒÒOƬµ¬µµµµÍ¹ì¹6ÛÓÎôÒO²Î××ÓÒí¹µ¬µ
¾ÓÎôÎ×pÆpÂôÒÔÒôÖôÖNÂpÆבÊ.¾YçÞ÷ÿûÞ÷¾ó¾ó½ó’γÊöÒõÎ
º7ãÿÿÿÿÿûÿ÷ÿûÿÿÿÿÿûÿûÿûÿÿÿÿÿÿÿÿÞû¼óÿûÿûþûþûþÿÿûÞó¾ïßóÿ÷ÿû›ï´Öµ±µµµµÌµNÂÓÎÓÎóÎôÎ×ß7ãxçÛ×ôÒôÒÛóÖoÆ.¬µî¹.¾ÛÛNÂì¹N²ÎÒÒpÊ
¾Ë±±ÊôÖÊ˵µ±µ¬µì¹óÖÔÎpÆ˵±ÊÛóÖî½µµµµÍµ-º6ÛôÎôÒÓÒOÂ7Û×ôÖ
¾Í¹ìµ²ÎÓÎôÒ±ÎNÂôÒ³ÊÓÎôÖÓÒÒÎ.ºõÎײξYëÿÿÿû¾ó¾ó½óOƳÎÓÕÎ
º³Òÿÿÿÿÿ÷ÿ÷ÿ÷ÿ÷ß÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿ÷âî½ÕÖÞûÿûÿûÿûÞ÷ß÷ß÷¾ï¾ïÿûÿÿœ÷±µµµµí¹OÂÒÎÓÎÓÎÒαÊpÆ.Â.¾O¾²ÊôÒôÒ×ÛÛoÆ.¾
¾OÂõÖõÒÓÒ
ºÓÎôÒõÒÛÓÒNÂOÂõÖôÒ-¾Íµ±µ¬µ
ºôÖÔÊôÒì¹ÒÎÛ6߲άµµµµÍ¹-ºxç×ÓÎÒÒ.¾õÖÛÛ
¾í¹O¾ôÒôÒ²Î
ºÊÓÒ²ÊÓÒÓҲΑÊ/¾õÎõÒ×pÊqÊÞûÿÿÞ÷Þ÷½ïpÊ‘Ê×ôξ²Îÿÿÿÿÿ÷ß÷ß÷¿ïß÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿßû{ëQÆ÷Úß÷ß÷ß÷ßó¾ï¾ëßïß÷ÿûÿû{ïî½±µµµµ¾OÂÒÎóÒÒÎÒÎNÂNÂíµí½
¾
ºº³ÊôÒôÒÛÛnÆ˵ºôÖÓ×ôÎôÒ×õÒôÒÓÎóÒ‘ÊpÊÛPÆ͵µµ¬µºÆõÎ6ß
¾ÓÒÛ5ÛóÖ
¾±¬µµ¬µ
ºÛôÒôÒóÒ
º×6Û6ß.¾õÒõÒóÒ
ºì¹M¾ôÖ‘Æ
ºí¹ì¹O¾öÒõÒõÒ×6ß¾ßÿÿÞûÞ÷œëqʲÎÛ×.¾NÂÝ÷ÿÿÿûÿûÿ÷ÿ÷ÿûÿÿÿÿÿÿÿÿÿÿÿÿÿûßó¾ïµÒµÒÞóßóßóß÷ÿûßóßóÿûÿûÿûYçιµµµµµ¾NÂóÒóÒÒÎÓÒÓÒ
¾º¬µµÍµ-¾
º×ôÒ×ÛóÖNÂ˱ÒÎÓôÎÛ6ßÓÒpƑʲʑƱÎNÂבÊí¹µµ¬µº‘ÊõÎ7ã
¾óÖÛôÖ5ÛÊ̵µµ¬µí¹5ßôÒÓóÖìµôÒ6Û6ßÓÒõÖ7Û×oÆì¹ËµoÆ×ÒÎ̵¬µÌµ‘Ê×ôÒõÖÛ6Û’ÎO¼óÿÿÿû½ïrÊôÚÛôÒpÆO¼÷ÿÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿ÷ß÷ß÷zïsÎÞûÿûÿûÿ÷ß÷ÿûÿûÿûÿ÷ÿû›ïιµµµµµî¹OÂóÒÓÎôÎôÒÛÊ
¾¬±¬±±Íµì¹ÓÒ6ÛÓôÖ5ßÒÖN²Î7ÛõÒ×ó־͵í¹o±ÊÊOÂבÊ̵µµµ
¾±ÊôÒWã
ºÛÛóÒ6Û×O¬µ¬µ¬µì¹±ÎÒÎ×Û
¾6ß7ß6ß7ß7Û7ßÛ
ºÍµËµÆÛÒÒ«±µÍ¹pÊôÖôÒ×ÛÛÛ.ÂÔÖ½÷ÿÿÞ÷’ÎóÒôÎÒÊpƺzëÞûÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûÿûßûß÷ß÷9çÖÖÿûÿûÿÿÿÿÿûßóßóßóßóÞûrεµµµµµÍ¹.¾ôÒôÎôÎôÎÛÓÖ
ºÍµµ¬µ¬µËµoÆÓôÒ×6ß6ßÊPÆõÖÓÊÔÎPÂí¹¬µÍµìµ
ººÓÎבÊ̵µµµ.¾ÒÎôÒ6ß-¾ÓÖÒÒÒÎ××ÒÒ
ºµ¬µì¹ÒÒÒÎÓÎÛ-¾6ß6ß6ß6Û7Û7ß±Î쵵˵ÆôÖÒÎí¹Ìµí¹.¾qÊÛôÖ×ÛóÖ²Îìµ7ãþûÞû²Ò³ÎõÖôÒoÆëµ/µãÿÿÿÿÿûÿ÷ÿ÷ÿûÿÿÿÿÿûÿûß÷ßóÞó½ï¾óß÷ß÷ÿ÷ßûßûß÷¿ïßóÿûœïµµµµµµÍ¹.¾ôÒôÎÓÊôÎ×óÖ͹µµµµ«±²ÎôÒóÒóÒÛxç±ÎOÂÒγÊÔÎoÆ͵¬±µ¬µËµ.¾×ôÒ‘Î̹µµµ/ÂÒÎôÒÛ.ÂÛÛ±ÊóÒ6Û5ßoÆ칬µí¹ÓÒóÒÓÎÛ.ÂÛÛ×7ß7ÛÛoÆ̵µëµ±ÊôÖôÖóÖÓÒÓÒÊOÂ6ßÛôÖÛÛÛ.Â/½óÞ÷³ÖõÖ×ôÒ‘ÆëµôÚrÎ͹”Ò¾óÞïÿûÿûÿÿÿÿÿÿÿûÿûÿûÿûÿûÿûÿûÿûÿûÿÿÿûÿûÿ÷ßóß÷ÿÿãî½µ±µµµµÍµ.ÂôÖôÒÓÊÔÊ×Ûí¹µµ¬µí¹º×ÒÎÒÎóÒ×yçÒÒNÂÓÒÓÊõÒpÆŒµµµµÌµ-¾×בÎ̱µµµ.¾ÓÒôÒÛ.ÂßÛ±ÊóÖ6ã6ßÒÒº¾ì¹oÆôÒôÒôÖ-¾óÖÓÎ×7Û7ÛWãÛº.Â˵±ÊÓÒóұʱÊÒαÊ.¾×6ÛÛôÖÛ7ßÛ
ºöÚþû²ÒÛÓôΑÊëµßÞÿ{ïî½sʾïÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûÿûßûÿûÿûÿûß÷ÿûß÷¿ï¾ë¾óßöÞιµµµµµÍµ-¾ôÖ×ÔÊÔÊôÒÛ
¾ÍµÍµ
¾ì¹ôÖ5ßóÒÒÎôÒÓ6ß±Î-¾ôÒôÎõÒpÆŒµµµµì¹N¾××óÖ«±µµµ
¾ÓÒôÒ×-¾ÛÛÆƱÊóÖ5ßNÆ
ºí¹N¾Ó×óÖ
ºÓÒõÒ××6ßWãôÖ±Î뵺ôÖÒÎÆƱʱαÎ
¾ôÖóÒÛôÖõÖÓÕÎÓÒ
¾›óÓÖÔÎÓ×oÆìµôÖÿÿÿÿ9닱ßß÷ßóÞïßóßó¾ï¿ï¿ï¾ïßóßóÞóß÷ß÷ßóßóßóßó¾ëžã¾ëß÷½÷µµµµµµ-¾ÓÒ×ÔÎôÎôÖÛÊ
¾
º
ºõÖ7ÛôÒÓÊÓÎÓÎ×5ßÆ.¾×ÓÎôÖpʵµµµÌµ‘ÊôÒÛ5ß̵µµµì¹±Î×6Û.ÂÓÒÛÒÎÒÎÒÎÒÒ۱κ.Â-ºÓÎ6ÛÛ¾Û7ÛÛ6ßÛÊÛ6ß/Â/ÂÛÆƱʑÊpÆOÆ.¾±ÊóÒÓÒoƲÎÓõÎ6Û.¾pƲΒÊõÒÛ±Îëµ’ÎÞûÞ÷½óÂÛžçžããããžã¾ëßïßóß÷ßóßó¿ï¾ë¾ë¾ë:ß÷ÖžçãßóÿûþÿµµµµµµN±Ê×ôÎõÒ×ÛÛ‘Ê’Ê×ÓÔβʲÊÓÎÒÎóÒÒÒ-¾pÆÓÒóÒôÒʬ±µµµÌµ²ÎÛÛÛ̵µµµí¹±Ê×6ã.±ÊôÖ6ßÛÊÒÒÛôÖìµëµ.¾ôÎ×ôÖ¾7ß××xç¾NÂÆ6ßóÖì¹ôÚóÖÒÎÊì¹ì¹
ºÓÒóÒ²ÎÊ/ÂpÊOÂÓõÎÓÎOº‘ÊÓÊõÒ’Îìµ8ãÿû¾ïç[ß|ß\ß\ß}ß}ãžç¾ëßïß÷Þ÷{çœë¾ï¿ï¾ë¾ï¾ïrÊRÆžç¾ëÿ÷ÿÿ¼÷͹µµµµµµ-¾/Â6ß×Û7ß7ß×õÒõÒôÒôÒôÎÓÊÓÎôÒ×ÒÒoÆìµpÆóÒÓÊÓΑʬ±µµµÌµÓÖWã×6ß-¾Ìµ¬±¬µ.ÂÒÒÛxëNÂÓÎ×5Û.ÂʱºÛ6Û‘Ê.¾±ÊÓÎײκÛôÒ6Û6ßì¹pÆ
º×ôÖpÆìµôÖóÖ-¾¬±î¹
ºÛôÖôÖ‘Î’Ê8ߺôÖõÒ6Û×ôÖõÒõÎôΒʺõÚœïë:ßÖÒ:ß}ã¾ëÞóßóßó¾ï¾óÞóßQÆ÷Úß÷ßóß÷ÿ÷œï1Æ:ß¾ë¿ïßûÝû”Ö¬µµµµµµ¬µ
¾-¾6ãWç6Û7Û7Û7Û×óÎôÒôÎôÒôÒôÒ×5ÛoÆ.¾.¾-¾ÒÊÒÊÓβά±µµµÌ¹ôÚ6ß×6ßÓÖëµÌµí¹²Î6ß6Û6ßNÂÓÎÓ6ß-¾-¾ËµôÖóұʱÊÒÊóÎ×ÒÒº²ÎôÒôÖôÖìµ¾
ºÓÒôÖÓÒ
ºpÆÒÒ
ºÍ¹Í¹¾ÓÖÒÎÒÒ²Ò¾Xã.¾qÊVßôÖÛ6ßôÒÔÊײҺ̵µï½Í¹‹±Íµ”ξ÷ÿû¾ï¾ï¾óœïÖÚî½Â8ãÞ÷ÿûÿûÿûÞ÷çžë¿ó½ó÷Þ0Æ͹µµµµµµµ
¾ºßxë6ß6Û×××ÓõÎõÎõÎõÒÓóÒÊ
ºëµ.¾oÆÒαÆÓÊÒÒ͵µµµí¹ôÚ5ß××ÛÛôÖÛ7ß7ß6߲κÔÎõÒÛ.Âí¹ì¹ÒÒÒÒ±ÆÓÊóÒ×±ÎëµÓÎôÒ×Û¾¾
¾±ÊôÖóÒ²Î
¾ÓÒOÂì¹OÆ.Â5ßÓÎÓαÎ
ºXã³ÎOÂWã×Û×ôÖôÒ5ۑκÔÒÖҔΔÎ÷ޔξrÊ8ã9ããÕÖ0Æ0ÆÂÖÚßûÿûÿûÿûß÷ßóßóÞ÷÷Þî½µµ¬µ±µµµµµµÍ¹º²Îšï6ß×××7Û8×Ó8×7ÛôÖÊ.¾.ÂôÖôÖ¾OÂóґƒƲʾµµµí¹ÓÒWã××ÛWßXã7ß7ß7Û6ÛoÆìµõÖÔÎôÒNÂ͵ì¹OÆôÖ²ÆÓÎôÎôÒ6ÛÊ˱ôÖ××ôÒ.¾í¹OÂpÆÛôÒÓÎOÂpÆóÒPÂpÆPÆOÂÓÎ×ôÖ.¾Zã8ßì¹ôÖ5Û××××ÛÒÒëµÛ|ã[ã9ß9ã¾ï[ã”Ò0Â0ÂQÆsεҔÎrÊÞ÷ÿûÿûß÷ßó¿ïß÷ÿû8笱µµµµµµµµµµµÍµ
ºoÆwçxç6Û7Û6ßÛõÖÓұΑÊoÆpÆÓÒôÖ×6ßóÖ.¾óÒÒÎÒÎÊì¹µµµî¹-¾Wã6ßÛXãXßWß7ßXß7ßÓκ˵ÓÎÒÎ×oÆí¹Í¹
¾×õÎõÎôÎ×ôÖ,¾Ë±²ÎôÖÓÊÔÎ.¾Íµ/ÂìµÓÎ7ßÓÒÓÖ
ºóÒÂÓÎôÖPƲÊõÎöÒ.¾zçœëpÆpÆ6ß×××ôÒôÒóÖì¹×}ã[ã9ß\ã~ß}ã[ã}çëœë[ç:ãQÆãÿÿÿûß÷ßó¿ïßóÿûßû’Ò¬µÎ¹µµµµµµµµµµµ¬µ
ºO‘ÎÊpÊpÆ.Â.¾qʲÎôÖ6ßXãWß6ß×5ß6ß.¾NÂNº̵µ±µµµÌµ
¾±ÎôÖXãXãWã6ßôÚʺí¹ìµÊÒÒÓÖì¹ÌµµÌµpÆôÒôÖÒÎÆNÂ˵칱ÎßÛʾ±Í¹
¾oÆ7ß×ôÖ.¾ÛÆ‘ÆÓÒpʳÎÛôÒºZßZçÔÖ
º6ßÛ×õÒÓ×ÒÎìµÛ|ãZç:ßÓ<×|ççžçç|ë{çµÒrʽóÿûÿûÿûÿ÷ß÷ÿûß÷ë0¬µÍµµµµµµµµµµµµ¬µµ¬µÍ¹¬µ¬µµí¹±ÎWã7ßXãzçÛÓÒõÖ6ß6ã6ßÛ.Â̵µ¬µµµµ¬µµ¬µ¬µ¬µí¹ìµìµ
¾ì¹Ìµ¬±µ¬µÌ¹Ë±ëµìµÌµµ±¬µËµìµì¹ëµËµÌµµÍµì¹-¾-¾
º/Â͹¬µí¹
¾-¾
¾
ºOÂÛôÒ²ÎpÊ
º-¾oÂ.¾PÂzç9ãYç’Î.¾²ÎÓÒÓÒ²ÊpÆìµ0º[ßZçZã;Û<×|ã|ç¾ë}ã}ç{ë|ëQÊãÿûÿûß÷ÿûÿûÿûÞ÷9ãSÆtÊrÊ͹±µµµµµµµµµµµµµµµµµì¹ôÖ7ß7ÛYãÛ
¾
¾.¾7ßXç5ß6ãÎ͵µ¬µ¬µ±±±µµµ¬µ¬µµ¬µµµµµ¬µµµ¬µÍ¹í¹í¹í¹ÍµÍ¹ÍµÌµì¹.¾.¾í¹Î¹µÍ¹.¾
º
¾
¾
¾/¾µÍ¹Í¹î¹0¾qÆqÆqʳÒÛµÎÕÒ÷ÖZßZã:ã[ßZß÷ִγγғÎÕÒÖÒ[Û|ç{ç\ß]Û}ã|ëçç|ã|ç|çÖÒsξ÷ÿûÿûÿûÿûÿûÞ÷µÒ¾¶Æ;×øÚ͹µ±µµµµµµµµµµµ¬µ¬µµµµ
¾6ßXã8ßYßqÆ̵±¾qÊ™ïxë6ãOƬ±Íµî½¾N¾¬µ¬µ«±Ëµì¹ì¹«±¬µ¬µ±µµ¬µí¹ì¹.¾OÂʲÎÊìµ
ºoƱÎÓÒpÆ
¾
º.¾N¾²Ê²Ê‘ÊÆNÂ.ÂιRÆøÎ[ß{çZë8ß\ß|ßçç{ë9ç{ã|ãçç{ç9ßç}ãã}ã|ã[ã\ã<Û}ß|ë|çã}ã}ç{çZã0Â:ã¾ïßóß÷ßóßóß÷œï¾–ÆùÎ\ß{çµµµµµµµµµµµµµµµµµµ
º×ÛXßYãºÍ¹µ¬µî½/ÂPÆí¹¬µ¬µ.¾pÆÓÒôÖÊ
¾ì¹¾Ìµ
ºôÒ×6ßÒÒ
¾ÌµÌµµµµìµôÖ×ôÎôÒÛÛO‘ÎôÒ‘ÆpÆÓұʺ.¾ÓβÊÓÒõÒÔαÊNÂ͹͹0Â×Ê:×{ã{ëYç{ã|ß}ã}ãëZë{ëœçžëççZç[ã}ß}ß}ß\Û\ã[ã\ß]ßçœëë¾ëžëë|ã”ÎQÆ}ç¾ë¾ë|ë|ëÞ÷ÞûãsÆ×\ßç¾ïrιµµµµµµµµµµµµµµµµ¬µ
º×7ÛXßXã-¾í¹µµ¬µµ¬µ¬µ¬µí¹ÓÒ6ÛXß7ßWã6ßÓÒ
¾.ÂOÂYã×ôÒôÒ5ßÛoÆì¹Íµ¬µËµ³ÎõÒõÒÛ6ã6ãNÂÓÒ
ºÌµÍ¹¾²ÎNÂO²ʑʺ
º³ÎÛoÆιï½tÆÏ|ã{ã{çZç|ã}ã}ß\Û{çZëëëžë½ë{ç[ç}ç}ß}ß]Û\ß;Û\Û]ßçœëë¾ë¾ï¾ï\çøÖï½ÕÖ½ïë[ç1Æ1ƵÖsÎÊ}ãžçžëžë÷Úιµµµµµµµµµµµµµµµµ¬µ/ÂÛ6ÛXãWçºÍµ¬µµµµµ¬µ¬µOÂÛÛyçXãWãyëXçÛºpÊšëXßôÒ³ÎôÒõÒôÖ²ÎìµÍµËµOÂ×õÖoÆ
¾
ººÓ¬µOÂpÆʺ²Ê.¾¾.Â.±ʾ×Ê[Û|ç{çZç{ççžç\Û|ãZëœïëç}ãœëzë|ç}ß}ß]ß}ß|ã;Û\Û}ãë|ë¾ï¾ë¾ï|ë:Û1Âî½Î¹0¾͹ι͵ιι¾•Êçžçžë}ãZãï½µµµµµµµµµµµµµµµµŒ±pÆXßXãšïšï
ºÍ¹µµµµµ¬µÍ¹ÓÒ7Û6ÛÓÒoÆpÆÛXãÛÊ-¾yë7ßõÖôÖÓÒ×Û6Û±Î칩pÆõÒ‘Æʱí¹ì¹oÂôÒ‘Æìµí¹OÂÒÒnÆ.ºÓÎ-¾¾µî¹Ì¹î¹î½RÂÓ\ß|ç{ç{ç|çã}ß}ãœë{ï½ïççœç{ëZç}ã}ß}ß]ß}ç:ß;×<×ç|ç¾ï¾ëžç½ó|ç۾ιµµµµµµµµQÆ×Ö¾ë¾ï¾ï}ã{ç¾µµµµµµµµµµµµµµµµŒ±pÆXßYãyç7ç.Â͹µµµµµÍµí¹õÚ6ß²Ê
ºî½OÆ-¾ôÖ6ÛóÖêµôÖXãÛ
¾OÆOƲÎ×6ßÎʱ³ÎõÒ²Îëµî½í¹ÊÓÎÒÎÓÎÓÒÓÒ,ººpÆÓÒOºOÂ/Âî½î¹ºÖÊ:×|ã{ëZç[ã|ã}ß<×}ç{ïœëëç}çœë{ë|ç}ã}ã\Û}ã|ç;ß<×[Û:ßçžë}ãžëœï{çsÊï½µµµµµ¬µµµµ0Âß¾óßó¾ïçZç͹µµµµµµµµµµµµµµµµ‹±¾Xãyç™ëxëÂ͹µµµµµÍ¹ìµ7ãxë.¾¾±µOƲÎXãÛ뵑ÊXã7ß.Âî¹î¹.¾²ÎWãßNÂ.¾õÖÓÖoÆ.¾.¾ºÓÒÓÎÓÎôÖ-¾ëµÊ±ÓÒôÖÓβÊpÂOƺ¾ÕÒ:ÛלëZçZã|ã\ß\Û\ß|ëœïëç}ãë{ë{ççžç}ß}ßë[ã;Û\Û{çZãçžçç¾ó{çÛï½Î¹¬µµµµµµµµÍ¹0Â\çßóß÷¾ëžë8ãî½µµµµµµµµµµµµµµµµ«±ìµ7ßxçxçyëÂ͵µµµµµí¹ëµôÖyç‘ʾ¬µµ.ÂPÆXçWã,¾oÆ7ß7ßPÆ͹µ¾PÆÛßoÆí¹××õÒ×ÛOÆpÂôÒôÒoÆNÂ-¾ìµ-¾‘ÊÓÒÛõÖÛõÖ.¾º9ß{ãœëZç|ç|ß]Û<×çœëœë}ã|ß}ãœë|ëç}ã}ß\Û|ç[ã;Û\Û|ç{ç|çžçžç¾óï{çrÊïÁ±µµµµµµµµÎ¹1Â\ã¾ï¿ïžç¾ïÕÚî¹µµµµµµµµµµµµµµµµÌµëµßšëyë»óOÆ͵µµµ¬µÌµì¹º
¾‘Ê7ÛÔÖ͵µ/ÂpÆXçWçnÆ
º6ÛÛOƵµµ.¾²ÎÛ±Îì¹ôÒ7ßÛ6ßWã²Î‘Ê×õÒ×ÛôÖOÂ
ºí¹.¾¾OÆõÖõÒóÖ-¾“ÎzçZç{ç|ã\ß<×}ß{çœëç|ß\ßœçœïëžç}ã\Û}ã[ç:ß|ß¾ç|ë|ë}çç¾ï½ó[ç÷ÚµµµµµµµµµÎµ¾¶Îžç¾ëžç}ãï0ÆιµµµµµµµµµµµµµµµµÍ¹ëµÓÒXãyëÜ÷ÓÖ͵µ±µÍ¹.ÂÒÒß6ã.³ÎX㾬µ¾.¾ÛÛ.Â
¾7ß6ßpÆ͵¬µµ/‘ÊóÒÒÒìµÓÎ6ãôÚNÂʵ˱6ßÛÛÛöÖ6ÛÓÒí¹µµÍµ.Â.¾õÒÔÒMÂ/¾Yã9ã{ç}ã\Û<×|ã{ëœï}ã}ã|ãœëœï¾ëžç\ß|ß|ç9ß;Ûç½ëœïœëçë¾ó|ë[ãQÆï½±µµµµµµµµ¾¾×žçžçžç}ãøÚ¬µµµµµµµµµµµµµµµµµµµÌµ³Ò™ëyë¼óßî½±±µí¹ÒÎ6ÛÛ6ßOƲÎ7ß.±Â.¾6ÛÛ.‘ÎXã7ßPÆµ.Â.²ÎôÖÓÖ
ºÓÎÛ.Âí¹Ìµ.¾šïßÒÒìµ/¾ÓÎôÒ¾¾Íµ¬±/Â-¾õÒôÒoƾ8ã9ã}ç}ß<Û\ß|çœï½ï}ã}ã|ë›ë½ëžç}ß\Û|çZãÛ\ßžë½ï¾ó¾ïç¾ï½÷{ãÖÖî½µµµµµµµµ±ÎµRÆØÒ\ß}ßžç~ã\ßQÆ͹µµµµµµµµµµµµµµµµµµ¬µ.™ïšëyë7ãOÆí¹î½í¹qÆôÒôÎôÖÛNÂÓÎÛOÆPÆpÊOÆ7ßôÖ
¾õÚzçÛOÆ/Â.ÂNÂqÆ7ßWãÓÖì¹ôÖóÖ
ºí¹Ì¹oÆxëß‘Î
¾ì¹pÂõÖ‘ÎOÂì¹ìµìµÓÒ8ßWãoÆqÆYç{ç}ã]ß]ß|çœï½óë\ß|çœïœï¾ë}ã<Û\ã|ç9ß;×ã¾ï½óÞóëë½óœë[ã1Âï½µµµµµµµµµRÆ•Ê<Û\Û~ã}ã\Û×Ö͹µµµµµµµµµµµµµµµµµµµµÌµõÚšë™ë»ó6ßOÂOƲÎÛ××6ßÒÒ-¾ôÖõÒÓÎpÆ‘ÎÛVã‘Î
º7ãyç×OÆ.¾N³Ò7ß7ßÛÊ/ÂÛ6ßOÆʱ˱ʱÓÒXãßí¹¬µpÆ6ßõÚOÂÔÖ³ÊÔÒXãyçôÚ
ºöÖzçç}ã]ß}ã|ç¼ó¾ï}ã}ßœë{ëïë\Û]ß}çZã×;מë¾ïÞó¾ë}ãçœë[ãßï½Î¹µµµµµµ±µ1ÂsÆ;Û}ß}ãžç~ç:ßÂ͹µµµµµµµµµµµµµµµµµµµµ¬µ.Â7ãšëšïšëXçXã7Û6Û7Û6ÛÛpÊ.¾ÛÛõÎÓ7Û6ßÛ
¾ì¹ôÖ7ß6ßÛôÖÛ6ß6ßÛóÖì¹³ÒÛ×ÒÒNÂN¾oÆ
ºöÖ7Û¾µ
ºôÖXçN²ÎôÖõÖ7ã5ßpÆ“ÎZç|ç|ß}ã]ßçï½óë<Û\ßœïœï¾ï}ß;×|ã[ç:ß;×]ß¾ï¾ó¿ï}ã}ãë{ç:ã1Æï½±µµµµµµµ0ÂRÆ×}ãžçžçç|ç´Ò͵µµµµµµµµµµµµµµµµµµµµµ¬µî¹PÆWãyçXãXß7Û7Û6Û6ßôÖ‘Êí¹Í¹pÊxç×ÕÊ×ôÖOÆpÆ6ÛÓÒôÖÛÛÛ±ÎNÂìµÌµÛ7ß×7ÛÛ6ÛÛ
¾ß7ã
¾µí¹±Î7ãÊ˱-¾‘ΑÊpƳÒ8ã{ç}ã}ß]Û]ßëœï½ï\ß<Ûëœï½ïžë\Û;Û|ç:ß:×\Ûçï¾ëžç}ãçœë[ãÖÖιµµµµµ±µÎ¹¾”Ê;Ûžç¿ë¾ë¾ë¾ï÷Úιµ±µµµµµµµµµµµµµµµµµµµµµµµ¾²ÎÛ6Û6Û×ÒÎÊ.¾Íµ¬µµ.¾pÆõÖ³Îqʾ͵¬µí¹-¾±ÊÒÒÓÒÊOÆ.¾Ìµ¬µµ«±³ÒXã×YßXãÛÒÒì¹.Â
ºÌµ¬±Íµ-¾Û²Ò¾’ΓÊõÖYçzë8ã|ç}ß]ß]ßçœï½ïë]ßç{ëœïï}ã\Û|ãZã:Û;×\ßëëã~ãçë{ã[ã1Æ鱬µ±µµÎ¹ï¹¾¶Î\ãžë¾ï¾ï¿ïÞóZçî½µµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±í¹í¹¾í¹Ìµ¬µ¬µµµµÍµí¹í¹¾î¹µŒ±µ¬±¬±¬µÌµÌµ¬µµµ¬±¬µµÌµì¹.¾
¾¾í¹ì¹ËµÌµ«±¬µ¬±±µ
ºôÚ7ãOÂrÂ×{ãZç9ã[ç|ã}ß\ß}ãëïžë}ß|ß½ï{ïœïç}ãç{ë:ß;Û<×}ãë}ç}ß}ãë|ç[ß÷Öî½µµµÍ¹î¹ï¹¾–Ê<Û}ã¿ë¿ï¿ï¿óßóYçµµµµµµµµµµµµµµµµµµµµµµµµµµµ±µµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµµµµµµ±µµµµµµ±¬µÌµ‘ÊXã²Î
º×ZßYã9ã|ã}ß|ß}ßçœë½ï}ç\Ûžë½óœïë}ãçœëZã:Û<×\ßëç\ß\Ûçœï[ã[ß1Æï½Î¹Î¹ï½1Æ•ÊùÖ<Û~ãžãžçžç¾ë¿ïÞ÷ãµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµµµµµµµµÍµ
ºõÖ7ÛpÆOÂ8ßYç{ç|ß\ß\ß|ãœëœëë\Û}ã½ó½ó½ëç}çë[ç:ß;×<×|ãë}ã}ß}çë{ç[ßÖÒ”Î:ßß:ãœï¾ïžëžçžçžã~ã}ßžã¾ï½ó´Öî¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÌµpÆ7ÛõÒOÂpÆ8ã|ç|ã\ß}ßë{ëë}ã\ßïœïëç}ãç|ëZã[ß<×\Û}ë}ç}ãžç¾ïœë[ã:Û1¾<Ûžç¾ëžë¿ë¿ëžë¿ë¾ëžã~ç\ß:ßÖÖ0Â͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹’ʺÓÎÓôÎOÂ.¾Ûzã[ß\ãœë|ëç\Û|ãœóœïëççëZã[ß\ß\ß}çëã}ãžëï{ç;Û”ÊuÆžë¿ó¾ï¾ï¿ï¿ïžç~ã}ã;ß×ÒRÆï½µµµ¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Æ9ßÆ
ºôÒÔÎ×pʾ8ß[ß|ç{ëœç|ß\Û|ë›ïëç}ã|ç{ë[ã\ß|ß|çïžë}ãžç¾ï|ë;Û×RÂ;Û~ççžçžçç[ãÛµÎRÂï¹µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹ÖÒ\ãyç.Â-ºôÎÓ6Û‘ÊrÆ[ß|ç|ç}ç;Û|ã{ëœëç}ã|ã{ë[ç\ã}ßç½ïëžã~ãžë¾ï[ãÓ•ÎsÆÛøֶΔÊRÆÂï¹Í¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ1Â×\Û{ã8Û.¾NÂôÒÛ±ÎqÂ[ã{ç|ç|ã[Û{ç{ëœë}ç\ß|çZã[ã|ß|ãëëžç}ã}ãžëœë×øÎî¹ï½Î¹Î¹µµµµ¬µµµµ±±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ØÒ<×}ã|ßZßßOÂ.ºoÆqÆ×{ã{çë|ã{ã{ëœëç\ß[ßZçZã|ã}ãœë½ëç}ß]ßçœë[ç:×R±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï¹Ó;×\ß[ßZã9ßZß××[ß|ã[ß{ã|ã[ß{ã{ç|ç|ã[ß[ç:ã[ß|ß|çïç}ß\Û}ßë{ç[ß÷Ö͵µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬±ºÓ\Û\ã[ß9Û:Û;Û[Û|ß}ã[ß[ß|ã[Û:Û:ß[ß[ß\ß|ãYãZã\ß|çïë}ã\Û\Û}ã|ç:Û9×1µµ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬±ð¹ùÎÓ|ãç{ç:ß[Û\Û|ß|ã[ß{ã}ã|ã[ã[ã[ß;Û;Û:ß:ß|ç|ãœëœï}ã}ß<Û}ß|ç[ãϵÎ͵±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµî¹sÂØÊ;Û[ß{ãZã[ã[ß[ã[ã{ã|ß|ãç{ã[ã\ß;Û:Û×:Û|ã{ãœëœë|ã\Û\ß|ã|ç×øÎï¹µ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹1¾×Ò:Û;Ûëë}ç|ã|ß\ß\Û|ß|ç{ã[ß:Û:×9Û:ß|ã[ß[ã|çë}ã\ß|ã|ã[ß:×sÊ͵¬µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµï½1µÎ[ã|ãç¾ëžç}ã\Û\ß\ß\ß[ß:Û:Û;ß[ß[ã|ã[ã|ã|ã|ß}ß|ã[ã;×øÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½sÊøÖ\ã}ççççç}ã\ß;Û;Û[Û\ß[ß[ß\ß\Û\Û\ß}ã[ã[ß:ÛrÊιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µ¬µµ¬µÍµ0ƵÒZãëë|çç|ç|ã|ß|ã\ß\ß;Û;Û\Û\ß|ã[ã[ß;Û÷Öï½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹RÆß{ç{ç|ç|ã|ãç|ã|ã[ß:Û[ß[ßZß[ã[ß;ßRÊ͵µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µ¬µµµÎ¹QÆÖÖöÚ{ç|ç|ã|ß}ã|ã:ß:ßZãZã|ç;ÛÖÒî½±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ±±µ¹î¹1ƵÖß[ã|ã|ß\Û|ß|çë\ßøÒ0Âι±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÎ¹ï½î¹tÊøÖ×\ßžç}ã[ßµÎιµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµÍ¹î½ÂRʵÒ×ÒÖÒµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ¬µµ±µµµÍ¹Î¹ï½î½µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµŒ±µµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµµ
\ No newline at end of file diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/main.pp new file mode 100644 index 0000000000..5875b83967 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Textured_Quad/main.pp @@ -0,0 +1,130 @@ +program main; +{$L texture.o} + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +//texture_bin.h is created automagicaly from the texture.bin placed in arm9/resources +//texture.bin is a raw 128x128 16 bit image. I will release a tool for texture conversion +//later +var + texture_bin_end: array [0..0] of u8; cvar; external; + texture_bin: array [0..0] of u16; cvar; external; + texture_bin_size: u32; cvar; external; + textureID: integer; + + rotateX: cfloat = 0.0; + rotateY: cfloat = 0.0; + keys: u16; + + +begin + + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + //enable textures + glEnable(GL_TEXTURE_2D); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + vramSetBankA(VRAM_A_TEXTURE); + + glGenTextures(1, @textureID); + glBindTexture(0, textureID); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pu8(@texture_bin)); + + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + gluLookAt( 0.0, 0.0, 1.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + while true do + begin + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + //move it away from the camera + glTranslate3f32(0, 0, floattof32(-1)); + + glRotateX(rotateX); + glRotateY(rotateY); + + + + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + //not a real gl function and will likely change + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK); + + scanKeys(); + + keys := keysHeld(); + + if((keys and KEY_UP)) <> 0 then rotateX := rotateX +3; + if((keys and KEY_DOWN)) <> 0 then rotateX := rotateX -3; + if((keys and KEY_LEFT)) <> 0 then rotateY := rotateY +3; + if((keys and KEY_RIGHT)) <> 0 then rotateY := rotateY -3; + + glBindTexture(0, textureID); + + //draw the obj + glBegin(GL_QUAD); + glNormal(NORMAL_PACK(0,inttov10(-1),0)); + + GFX_TEX_COORD^ := (TEXTURE_PACK(0, inttot16(128))); + glVertex3v16(floattov16(-0.5), floattov16(-0.5), 0 ); + + GFX_TEX_COORD^ := (TEXTURE_PACK(inttot16(128),inttot16(128))); + glVertex3v16(floattov16(0.5), floattov16(-0.5), 0 ); + + GFX_TEX_COORD^ := (TEXTURE_PACK(inttot16(128), 0)); + glVertex3v16(floattov16(0.5), floattov16(0.5), 0 ); + + GFX_TEX_COORD^ := (TEXTURE_PACK(0,0)); + glVertex3v16(floattov16(-0.5), floattov16(0.5), 0 ); + + glEnd(); + + glPopMatrix(1); + + glFlush(0); + + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/data/statue.bin b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/data/statue.bin Binary files differnew file mode 100644 index 0000000000..3c5bba2c5e --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/data/statue.bin diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/main.pp new file mode 100644 index 0000000000..c684925071 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/Misc/Toon_Shading/main.pp @@ -0,0 +1,133 @@ +program main; +{$L statue.o} + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +var + statue_bin_end: array [0..0] of u8; cvar; external; + statue_bin: array [0..0] of u16; cvar; external; + statue_bin_size: u32; cvar; external; + + prev_pen: array [0..1] of cint = ( $7FFFFFFF, $7FFFFFFF ); + +procedure get_pen_delta(var dx, dy: cint); +var + keys: u32; + touchXY: touchPosition; +begin + keys := keysHeld(); + + if( keys and KEY_TOUCH ) <> 0 then + begin + touchXY := touchReadXY(); + + if ( prev_pen[0] <> $7FFFFFFF ) then + begin + dx := (prev_pen[0] - touchXY.x); + dy := (prev_pen[1] - touchXY.y); + end; + + prev_pen[0] := touchXY.x; + prev_pen[1] := touchXY.y; + end else + begin + prev_pen[0] := $7FFFFFFF; + prev_pen[1] := $7FFFFFFF; + dx := 0; + dy := 0; + end; +end; + +var + rotateX: integer = 0; + rotateY: integer = 0; + keys: u32; + pen_delta: array [0..1] of cint; + +begin + powerON(POWER_ALL); + + //set mode 0, enable BG0 and set it to 3D + videoSetMode(MODE_0_3D); + + //irqs are nice + irqInit(); + irqEnable(IRQ_VBLANK); + + // initialize gl + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + //this should work the same as the normal gl call + glViewPort(0,0,255,191); + + //toon-table entry 0 is for completely unlit pixels, going up to entry 31 for completely lit + //We block-fill it in two halves, we get cartoony 2-tone lighting + glSetToonTableRange( 0, 15, RGB15(8,8,8) ); + glSetToonTableRange( 16, 31, RGB15(24,24,24) ); + + //any floating point gl call is being converted to fixed prior to being implemented + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 40); + + //NB: When toon-shading, the hw ignores lights 2 and 3 + //Also note that the hw uses the RED component of the lit vertex to index the toon-table + glLight(0, RGB15(16,16,16) , 0, floattov10(-1.0), 0); + glLight(1, RGB15(16,16,16), floattov10(-1.0), 0, 0); + + gluLookAt( 0.0, 0.0, -3.0, //camera possition + 0.0, 0.0, 0.0, //look at + 0.0, 1.0, 0.0); //up + + while true do + begin + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glRotateXi(rotateX); + glRotateYi(rotateY); + + + glMaterialf(GL_AMBIENT, RGB15(8,8,8)); + glMaterialf(GL_DIFFUSE, RGB15(24,24,24)); + glMaterialf(GL_SPECULAR, RGB15(0,0,0)); + glMaterialf(GL_EMISSION, RGB15(0,0,0)); + + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or POLY_TOON_SHADING); + + + scanKeys(); + keys := keysHeld(); + + if( keys and KEY_UP ) <> 0 then rotateX := rotateX +1; + if( keys and KEY_DOWN ) <> 0 then rotateX := rotateX -1; + if( keys and KEY_LEFT ) <> 0 then rotateY := rotateY +1; + if( keys and KEY_RIGHT ) <> 0 then rotateY := rotateY -1; + + get_pen_delta( pen_delta[0], pen_delta[1] ); + rotateY := rotateY - pen_delta[0]; + rotateX := rotateY - pen_delta[1]; + + + glCallList(@statue_bin); + glPopMatrix(1); + + glFlush(0); + + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson01/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson01/main.pp new file mode 100644 index 0000000000..d54c23d0cd --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson01/main.pp @@ -0,0 +1,81 @@ +(**************************************** + * NDS NeHe Lesson 01 * + * Author: Dovoto * + ****************************************) + +program main; + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +function DrawGLScene(): boolean; +begin + //we are going to use floating point for the tutorial...keep in mind the DS has no + //floating point hardware. For real life use the built in fixed point types. + //this is where the magic happens + glLoadIdentity(); + DrawGLScene := TRUE; +end; + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup (not strickly required but nice + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0, 0, 0, 31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0, 0, 255, 191); + + // setup the view + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + + while true do + begin + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + glColor3f(1, 1, 1); // Set the color..not in nehe source...ds gl default will be black + + //Push our original Matrix onto the stack (save state) + glPushMatrix(); + + DrawGLScene(); + + // Pop our Matrix from the stack (restore state) + glPopMatrix(1); + + //a handy little built in function to wait for a screen refresh + swiWaitForVBlank(); + + // flush to screen + glFlush(0); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson02/main1.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson02/main1.pp new file mode 100644 index 0000000000..53030bf443 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson02/main1.pp @@ -0,0 +1,91 @@ +(**************************************** + * NDS NeHe Lesson 02 * + * Author: Dovoto * + ****************************************) + +program main1; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +function DrawGLScene(): boolean; +begin + glLoadIdentity(); // Reset The Current Modelview Matrix + glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0 + glBegin(GL_TRIANGLES); // Drawing Using Triangles + glVertex3f( 0.0, 1.0, 0.0); // Top + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glEnd(); // Finished Drawing The Triangle + + glTranslatef(3.0,0.0,0.0); // Move Right 3 Units + glBegin(GL_QUADS); // Draw A Quad + glVertex3f(-1.0, 1.0, 0.0); // Top Left + glVertex3f( 1.0, 1.0, 0.0); // Top Right + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glEnd(); // Done Drawing The Quad + + DrawGLScene := TRUE; // Keep Going +end; + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(70, 256.0 / 192.0, 0.1, 100); + // Set the color of the vertices + glColor3f(1, 1, 1); + + while true do + begin + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + //Push our original Matrix onto the stack (save state) + glPushMatrix(); + + DrawGLScene(); + + // Pop our Matrix from the stack (restore state) + glPopMatrix(1); + + //a handy little built in function to wait for a screen refresh + swiWaitForVBlank(); + + // flush to screen + glFlush(0); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson03/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson03/main.pp new file mode 100644 index 0000000000..99b33da711 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson03/main.pp @@ -0,0 +1,86 @@ +(**************************************** + * NDS NeHe Lesson 03 * + * Author: Dovoto * + ****************************************) + +program main; + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +function DrawGLScene(): boolean; +begin + + glLoadIdentity(); // Reset The Current Modelview Matrix + glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0 + glBegin(GL_TRIANGLES); // Drawing Using Triangles + glColor3f(1.0,0.0,0.0); // Set The Color To Red + glVertex3f( 0.0, 1.0, 0.0); // Top + glColor3f(0.0,1.0,0.0); // Set The Color To Green + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glColor3f(0.0,0.0,1.0); // Set The Color To Blue + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glEnd(); // Finished Drawing The Triangle + glTranslatef(3.0,0.0,0.0); // Move Right 3 Units + glColor3f(0.5,0.5,1.0); // Set The Color To Blue One Time Only + glBegin(GL_QUADS); // Draw A Quad + glVertex3f(-1.0, 1.0, 0.0); // Top Left + glVertex3f( 1.0, 1.0, 0.0); // Top Right + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glEnd(); // Done Drawing The Quad + DrawGLScene := TRUE; // Keep Going +end; + + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + glInit(); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + // Specify the Clear Color and Depth + glClearColor(0,0,0,31); + glClearDepth($7FFF); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + glColor3f(1, 1, 1); // Set the color..not in nehe source...ds gl default will be black + + while true do + begin + + DrawGLScene(); + + // flush to screen + glFlush(0); + + //a handy little built in function to wait for a screen refresh + swiWaitForVBlank(); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson04/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson04/main.pp new file mode 100644 index 0000000000..cd1dc0fd1d --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson04/main.pp @@ -0,0 +1,101 @@ +(**************************************** + * NDS NeHe Lesson 04 * + * Author: Dovoto * + ****************************************) + +program main; + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +var + rtri: cfloat = 0.0; // Angle For The Triangle ( NEW ) + rquad: cfloat = 0.0; // Angle For The Quad ( NEW ) + + +function DrawGLScene(): boolean; +begin + glIdentity(); // Reset The Current Modelview Matrix + glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0 + glRotatef(rtri,0.0,1.0,0.0); // Rotate The Triangle On The Y axis ( NEW ) + glColor3f(1, 1, 1); // set the vertex color + glBegin(GL_TRIANGLES); // Drawing Using Triangles + glColor3f(1.0,0.0,0.0); // Set The Color To Red + glVertex3f( 0.0, 1.0, 0.0); // Top + glColor3f(0.0,1.0,0.0); // Set The Color To Green + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glColor3f(0.0,0.0,1.0); // Set The Color To Blue + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glEnd(); // Finished Drawing The Triangle + glIdentity(); // Reset The Current Modelview Matrix + glTranslatef(1.5,0.0,-6.0); // Move Right 3 Units + glRotatef(rquad,1.0,0.0,0.0); // Rotate The Quad On The X axis ( NEW ) + glColor3f(0.5,0.5,1.0); // Set The Color To Blue One Time Only + glBegin(GL_QUADS); // Draw A Quad + glVertex3f(-1.0, 1.0, 0.0); // Top Left + glVertex3f( 1.0, 1.0, 0.0); // Top Right + glVertex3f( 1.0,-1.0, 0.0); // Bottom Right + glVertex3f(-1.0,-1.0, 0.0); // Bottom Left + glEnd(); // Done Drawing The Quad + rtri := rtri + 0.9; // Increase The Rotation Variable For The Triangle ( NEW ) + rquad := rquad - 0.75; // Decrease The Rotation Variable For The Quad ( NEW ) + DrawGLScene := True; // Keep Going +end; + + + +begin +// rtri := 0; // Increase The Rotation Variable For The Triangle ( NEW ) +// rquad := 0; // Decrease The Rotation Variable For The Quad ( NEW ) + + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + while true do + begin + DrawGLScene(); + //a handy little built in function to wait for a screen refresh + swiWaitForVBlank(); + // flush to screen + glFlush(0); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson05/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson05/main.pp new file mode 100644 index 0000000000..4f14b1d674 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson05/main.pp @@ -0,0 +1,145 @@ +(**************************************** + * NDS NeHe Lesson 05 * + * Author: Dovoto * + ****************************************) + +program main; + +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +var + rtri: cfloat = 0.0; // Angle For The Triangle ( NEW ) + rquad: cfloat = 0.0; // Angle For The Quad ( NEW ) + + +function DrawGLScene(): boolean; +begin + glLoadIdentity(); // Reset The Current Modelview Matrix + glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0 + glRotatef(rtri,0.0,1.0,0.0); // Rotate The Triangle On The Y axis ( NEW ) + glBegin(GL_TRIANGLES); // Start Drawing A Triangle + glColor3f(1.0,0.0,0.0); // Red + glVertex3f( 0.0, 1.0, 0.0); // Top Of Triangle (Front) + glColor3f(0.0,1.0,0.0); // Green + glVertex3f(-1.0,-1.0, 1.0); // Left Of Triangle (Front) + glColor3f(0.0,0.0,1.0); // Blue + glVertex3f( 1.0,-1.0, 1.0); // Right Of Triangle (Front) + glColor3f(1.0,0.0,0.0); // Red + glVertex3f( 0.0, 1.0, 0.0); // Top Of Triangle (Right) + glColor3f(0.0,0.0,1.0); // Blue + glVertex3f( 1.0,-1.0, 1.0); // Left Of Triangle (Right) + glColor3f(0.0,1.0,0.0); // Green + glVertex3f( 1.0,-1.0, -1.0); // Right Of Triangle (Right) + glColor3f(1.0,0.0,0.0); // Red + glVertex3f( 0.0, 1.0, 0.0); // Top Of Triangle (Back) + glColor3f(0.0,1.0,0.0); // Green + glVertex3f( 1.0,-1.0, -1.0); // Left Of Triangle (Back) + glColor3f(0.0,0.0,1.0); // Blue + glVertex3f(-1.0,-1.0, -1.0); // Right Of Triangle (Back) + glColor3f(1.0,0.0,0.0); // Red + glVertex3f( 0.0, 1.0, 0.0); // Top Of Triangle (Left) + glColor3f(0.0,0.0,1.0); // Blue + glVertex3f(-1.0,-1.0,-1.0); // Left Of Triangle (Left) + glColor3f(0.0,1.0,0.0); // Green + glVertex3f(-1.0,-1.0, 1.0); // Right Of Triangle (Left) + glEnd(); // Done Drawing The Pyramid + + glLoadIdentity(); // Reset The Current Modelview Matrix + glTranslatef(1.5,0.0,-7.0); // Move Right 1.5 Units And Into The Screen 7.0 + glRotatef(rquad,1.0,1.0,1.0); // Rotate The Quad On The X axis ( NEW ) + glBegin(GL_QUADS); // Draw A Quad + glColor3f(0.0,1.0,0.0); // Set The Color To Green + glVertex3f( 1.0, 1.0,-1.0); // Top Right Of The Quad (Top) + glVertex3f(-1.0, 1.0,-1.0); // Top Left Of The Quad (Top) + glVertex3f(-1.0, 1.0, 1.0); // Bottom Left Of The Quad (Top) + glVertex3f( 1.0, 1.0, 1.0); // Bottom Right Of The Quad (Top) + glColor3f(1.0,0.5,0.0); // Set The Color To Orange + glVertex3f( 1.0,-1.0, 1.0); // Top Right Of The Quad (Bottom) + glVertex3f(-1.0,-1.0, 1.0); // Top Left Of The Quad (Bottom) + glVertex3f(-1.0,-1.0,-1.0); // Bottom Left Of The Quad (Bottom) + glVertex3f( 1.0,-1.0,-1.0); // Bottom Right Of The Quad (Bottom) + glColor3f(1.0,0.0,0.0); // Set The Color To Red + glVertex3f( 1.0, 1.0, 1.0); // Top Right Of The Quad (Front) + glVertex3f(-1.0, 1.0, 1.0); // Top Left Of The Quad (Front) + glVertex3f(-1.0,-1.0, 1.0); // Bottom Left Of The Quad (Front) + glVertex3f( 1.0,-1.0, 1.0); // Bottom Right Of The Quad (Front) + glColor3f(1.0,1.0,0.0); // Set The Color To Yellow + glVertex3f( 1.0,-1.0,-1.0); // Top Right Of The Quad (Back) + glVertex3f(-1.0,-1.0,-1.0); // Top Left Of The Quad (Back) + glVertex3f(-1.0, 1.0,-1.0); // Bottom Left Of The Quad (Back) + glVertex3f( 1.0, 1.0,-1.0); // Bottom Right Of The Quad (Back) + glColor3f(0.0,0.0,1.0); // Set The Color To Blue + glVertex3f(-1.0, 1.0, 1.0); // Top Right Of The Quad (Left) + glVertex3f(-1.0, 1.0,-1.0); // Top Left Of The Quad (Left) + glVertex3f(-1.0,-1.0,-1.0); // Bottom Left Of The Quad (Left) + glVertex3f(-1.0,-1.0, 1.0); // Bottom Right Of The Quad (Left) + glColor3f(1.0,0.0,1.0); // Set The Color To Violet + glVertex3f( 1.0, 1.0,-1.0); // Top Right Of The Quad (Right) + glVertex3f( 1.0, 1.0, 1.0); // Top Left Of The Quad (Right) + glVertex3f( 1.0,-1.0, 1.0); // Bottom Left Of The Quad (Right) + glVertex3f( 1.0,-1.0,-1.0); // Bottom Right Of The Quad (Right) + glEnd(); // Done Drawing The Quad + + rtri:=rtri+0.2; // Increase The Rotation Variable For The Triangle ( NEW ) + rquad:=rquad-0.15; // Decrease The Rotation Variable For The Quad ( NEW ) + DrawGLScene := TRUE; // Keep Going +end; + + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // Specify the Clear Color and Depth + glClearColor(0,0,0,31); + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE); + + while true do + begin + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + //Push our original Matrix onto the stack (save state) + glPushMatrix(); + + DrawGLScene(); + + // Pop our Matrix from the stack (restore state) + glPopMatrix(1); + + // flush to screen + glFlush(0); + + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/drunkenlogo.pcx.o b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/drunkenlogo.pcx.o Binary files differnew file mode 100644 index 0000000000..f24743fd17 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/drunkenlogo.pcx.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/main.pp new file mode 100644 index 0000000000..e11b1826e2 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson06/main.pp @@ -0,0 +1,164 @@ +(**************************************** + * NDS NeHe Lesson 06 * + * Author: Dovoto * + ****************************************) +program main; +{$L drunkenlogo.pcx.o} +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + drunkenlogo_pcx_end: array [0..0] of u8; cvar; external; + drunkenlogo_pcx: array [0..0] of u8; cvar; external; + drunkenlogo_pcx_size: u32; cvar; external; + + xrot: cfloat; // X Rotation ( NEW ) + yrot: cfloat; // Y Rotation ( NEW ) + zrot: cfloat; // Z Rotation ( NEW ) + + texture: array [0..0] of integer; // Storage For One Texture ( NEW ) + + + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +begin + glLoadIdentity(); // Reset The View + glTranslatef(0.0,0.0,-5.0); + + glRotatef(xrot,1.0,0.0,0.0); + glRotatef(yrot,0.0,1.0,0.0); + glRotatef(zrot,0.0,0.0,1.0); + + glBindTexture(GL_TEXTURE_2D, texture[0]); + + glBegin(GL_QUADS); + // Front Face + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + // Back Face + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + // Top Face + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + // Bottom Face + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + // Right face + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + // Left Face + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glEnd(); + + xrot:=xrot+0.3; + yrot:=yrot+0.2; + zrot:=zrot+0.4; + DrawGLScene := TRUE; +end; + + +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pu8(drunkenlogo_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + imageDestroy(@pcx); + + result := TRUE; +end; + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable textures + glEnable(GL_TEXTURE_2D); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + LoadGLTextures(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + //need to set up some material properties since DS does not have them set by default + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE or POLY_FORMAT_LIGHT0 or POLY_FORMAT_LIGHT1 or POLY_FORMAT_LIGHT2); + + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + glLight(1, RGB15(31,31,31) , 0, 0, floattov10(-1.0)); + glLight(2, RGB15(31,31,31) , 0, 0, floattov10(1.0)); + + while true do + begin + + glColor3f(1,1,1); + + DrawGLScene(); + + // flush to screen + glFlush(0); + + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/drunkenlogo.pcx.o b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/drunkenlogo.pcx.o Binary files differnew file mode 100644 index 0000000000..f24743fd17 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/drunkenlogo.pcx.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/main.pp new file mode 100644 index 0000000000..c0b5b08e88 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson07/main.pp @@ -0,0 +1,210 @@ +(**************************************** + * NDS NeHe Lesson 04 * + * Author: Ethos * + ****************************************) + +program main; +{$L drunkenlogo.pcx.o} +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +var + drunkenlogo_pcx_end: array [0..0] of u8; cvar; external; + drunkenlogo_pcx: array [0..0] of u8; cvar; external; + drunkenlogo_pcx_size: u32; cvar; external; + + light: boolean; // Lighting ON/OFF ( NEW ) + lp: boolean; // L Pressed? ( NEW ) + + xrot: GLfloat; // X Rotation + yrot: GLfloat; // Y Rotation + xspeed: GLfloat; // X Rotation Speed + yspeed: GLfloat; // Y Rotation Speed + z: GLfloat = -5.0; // Depth Into The Screen + + texture: array [0..2] of integer; // Storage For 3 Textures (only going to use 1 on the DS for this demo) + +const + LightAmbient: array [0..3] of GLfloat = ( 0.5, 0.5, 0.5, 1.0 ); + LightDiffuse: array [0..3] of GLfloat = ( 1.0, 1.0, 1.0, 1.0 ); + LightPosition: array [0..3] of GLfloat = ( 0.0, 0.0, 2.0, 1.0 ); + + + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +begin + glLoadIdentity(); // Reset The View + glTranslatef(0.0,0.0,z); + + glRotatef(xrot,1.0,0.0,0.0); + glRotatef(yrot,0.0,1.0,0.0); + + glBindTexture(GL_TEXTURE_2D, texture[0]); //no filters to swtich between + + glBegin(GL_QUADS); + // Front Face + glNormal3f( 0.0, 0.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + // Back Face + glNormal3f( 0.0, 0.0,-1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + // Top Face + glNormal3f( 0.0, 1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + // Bottom Face + glNormal3f( 0.0,-1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + // Right face + glNormal3f( 1.0, 0.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + // Left Face + glNormal3f(-1.0, 0.0, 0.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glEnd(); + + xrot:=xrot+xspeed; + yrot:=yrot+yspeed; + + + DrawGLScene := TRUE; +end; + + +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pu8(drunkenlogo_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + imageDestroy(@pcx); + + result := TRUE; +end; + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable textures + glEnable(GL_TEXTURE_2D); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + LoadGLTextures(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //set up a directional light arguments are light number (0-3), light color, + //and an x,y,z vector that points in the direction of the light, the direction must be normalized + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + + //need to set up some material properties since DS does not have them set by default + glMaterialf(GL_AMBIENT, RGB15(8,8,8)); + glMaterialf(GL_DIFFUSE, RGB15(8,8,8)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + + while true do + begin + //these little button functions are pretty handy + scanKeys(); + + + if ((keysDown() and KEY_A)) <> 0 then + light := not light; + + if (keysHeld() and KEY_R) <> 0 then + z := z -0.02; + if (keysHeld() and KEY_L) <> 0 then + z := z+0.02; + if (keysHeld() and KEY_LEFT) <> 0 then + xspeed := xspeed-0.01; + if (keysHeld() and KEY_RIGHT) <> 0 then + xspeed := xspeed+0.01; + if (keysHeld() and KEY_UP) <> 0 then + yspeed := yspeed+0.01; + if (keysHeld() and KEY_DOWN) <> 0 then + yspeed := yspeed-0.01; + + + glColor3f(1,1,1); + + if (not light) then + begin + //ds specific, several attributes can be set here including turning on our light + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK); + end else + begin + //ds specific, several attributes can be set here including turning on our light + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0); + end; + + DrawGLScene(); + + // flush to screen + glFlush(0); + + // wait for the screen to refresh + swiWaitForVBlank(); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/drunkenlogo.pcx.o b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/drunkenlogo.pcx.o Binary files differnew file mode 100644 index 0000000000..f24743fd17 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/drunkenlogo.pcx.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/main.pp new file mode 100644 index 0000000000..84841f1146 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson08/main.pp @@ -0,0 +1,206 @@ +(**************************************** + * NDS NeHe Lesson 04 * + * Author: Ethos * + ****************************************) + +program main; +{$L drunkenlogo.pcx.o} +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + +var + drunkenlogo_pcx_end: array [0..0] of u8; cvar; external; + drunkenlogo_pcx: array [0..0] of u8; cvar; external; + drunkenlogo_pcx_size: u32; cvar; external; + + light: boolean; // Lighting ON/OFF ( NEW ) + lp: boolean; // L Pressed? ( NEW ) + + xrot: GLfloat; // X Rotation + yrot: GLfloat; // Y Rotation + xspeed: GLfloat; // X Rotation Speed + yspeed: GLfloat; // Y Rotation Speed + z: GLfloat = -5.0; // Depth Into The Screen + + texture: array [0..2] of integer; // Storage For 3 Textures (only going to use 1 on the DS for this demo) + +const + LightAmbient: array [0..3] of GLfloat = ( 0.5, 0.5, 0.5, 1.0 ); + LightDiffuse: array [0..3] of GLfloat = ( 1.0, 1.0, 1.0, 1.0 ); + LightPosition: array [0..3] of GLfloat = ( 0.0, 0.0, 2.0, 1.0 ); + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +begin + glLoadIdentity(); // Reset The View + glTranslatef(0.0,0.0,z); + + glRotatef(xrot,1.0,0.0,0.0); + glRotatef(yrot,0.0,1.0,0.0); + + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE or POLY_FORMAT_LIGHT0); + + glBindTexture(GL_TEXTURE_2D, texture[0]); //no filters to swtich between + + glBegin(GL_QUADS); + // Front Face + glNormal3f( 0.0, 0.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + // Back Face + glNormal3f( 0.0, 0.0,-1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + // Top Face + glNormal3f( 0.0, 1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + // Bottom Face + glNormal3f( 0.0,-1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + // Right face + glNormal3f( 1.0, 0.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0); + glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0); + glEnd(); + + glPolyFmt(POLY_ALPHA(15) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0); + + glBegin(GL_QUADS); + + // Left Face + glNormal3f(-1.0, 0.0, 0.0); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); + glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); + glEnd(); + + xrot := xrot+xspeed; + yrot := yrot+yspeed; + + DrawGLScene := TRUE; +end; + + +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pu8(drunkenlogo_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + imageDestroy(@pcx); + + result := TRUE; +end; + + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable textures + glEnable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + LoadGLTextures(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //set up a directional ligth arguments are light number (0-3), light color, + //and an x,y,z vector that points in the direction of the light + glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); + + + glColor3f(1,1,1); + + glMatrixMode(GL_MODELVIEW); + + //need to set up some material properties since DS does not have them set by default + + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + // Set the current matrix to be the model matrix + glMatrixMode(GL_MODELVIEW); + while true do + begin + //these little button functions are pretty handy + scanKeys(); + + if (keysHeld() and KEY_R) <> 0 then + z := z -0.02; + if (keysHeld() and KEY_L) <> 0 then + z := z+0.02; + if (keysHeld() and KEY_LEFT) <> 0 then + xspeed := xspeed-0.01; + if (keysHeld() and KEY_RIGHT) <> 0 then + xspeed := xspeed+0.01; + if (keysHeld() and KEY_UP) <> 0 then + yspeed := yspeed+0.01; + if (keysHeld() and KEY_DOWN) <> 0 then + yspeed := yspeed-0.01; + + DrawGLScene(); + + // flush to screen + glFlush(0); + + // wait for the screen to refresh + swiWaitForVBlank(); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/Star.pcx.o b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/Star.pcx.o Binary files differnew file mode 100644 index 0000000000..2f8299a83b --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/Star.pcx.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/main.pp new file mode 100644 index 0000000000..2fb3dcefd7 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson09/main.pp @@ -0,0 +1,188 @@ +(**************************************** + * NDS NeHe Lesson 09 * + * Author: dovoto + * DS does not appear to support + the features needed for this demo + ****************************************) + +program main; +{$L Star.pcx.o} +{$apptype arm9} //...or arm7 +{$define ARM9} //...or arm7, according to apptype + +{$mode objfpc} // required for some libc funcs implementation + +uses + ctypes, nds9; // required by nds headers! + + +type + TStars = record // Create A Structure For Star + r, g, b: integer; // Stars Color + dist: cfloat; // Stars Distance From Center + angle: cfloat; // Stars Current Angle + end; + + +var + Star_pcx_end: array [0..0] of u8; cvar; external; + Star_pcx: array [0..0] of u8; cvar; external; + Star_pcx_size: u32; cvar; external; + + twinkle: boolean; // Twinkling Stars + tp: boolean; // 'T' Key Pressed? + +const + num = 50; // Number Of Stars To Draw + + +var + star: array [0..num-1] of TStars; // Need To Keep Track Of 'num' Stars + zoom: double = -15.0; // Distance Away From Stars + tilt: double = 90.0; // Tilt The View + spin: double; // Spin Stars + + loop: integer; // General Loop Variable + texture: array [0..0] of integer; // Storage For One textures + + + +// Load PCX files And Convert To Textures +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pu8(Star_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + imageDestroy(@pcx); + + result := TRUE; +end; + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +var + loop: integer; +begin + glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Our Texture + + for loop := 0 to num - 1 do // Loop Through All The Stars + begin + glLoadIdentity(); // Reset The View Before We Draw Each Star + glTranslatef(0.0, 0.0, zoom); // Zoom Into The Screen (Using The Value In 'zoom') + glRotatef(tilt, 1.0, 0.0, 0.0); // Tilt The View (Using The Value In 'tilt') + glRotatef(star[loop].angle, 0.0, 1.0, 0.0); // Rotate To The Current Stars Angle + glTranslatef(star[loop].dist, 0.0, 0.0); // Move Forward On The X Plane + glRotatef(-star[loop].angle, 0.0, 1.0, 0.0); // Cancel The Current Stars Angle + glRotatef(-tilt, 1.0, 0.0, 0.0); // Cancel The Screen Tilt + + if (twinkle) then + begin + glColor3b(star[(num-loop)-1].r,star[(num-loop)-1].g,star[(num-loop)-1].b); ///different + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0,-1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0,-1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 0.0); + glEnd(); + end; + + glRotatef(spin, 0.0, 0.0, 1.0); + glColor3b(star[loop].r,star[loop].g,star[loop].b); //different + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0,-1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 1.0,-1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 0.0); + glEnd(); + + spin := spin + 0.01; + star[loop].angle := star[loop].angle + (loop / num); + star[loop].dist := star[loop].dist - 0.01; + if (star[loop].dist < 0.0) then + begin + star[loop].dist := star[loop].dist + 5.0; + star[loop].r :=rand(256); + star[loop].g :=rand(256); + star[loop].b :=rand(256); + end; + end; + result := TRUE; // Keep Going + +end; + + +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + // initialize the geometry engine + glInit(); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + // enable textures + glEnable(GL_TEXTURE_2D); + + // enable alpha blending + glEnable(GL_BLEND); + + // Set our viewport to be the same size as the screen + glViewport(0,0,255,191); + + LoadGLTextures(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(70, 256.0 / 192.0, 0.1, 100); + glColor3f(1,1,1); + + //set up a directional ligth arguments are light number (0-3), light color, + //and an x,y,z vector that points in the direction of the light + glLight(0, RGB15(31,31,31) , 0, 0,floattov10(-1.0)); + + //need to set up some material properties since DS does not have them set by default + glMaterialf(GL_AMBIENT, RGB15(16,16,16)); + glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(8,8,8)); + glMaterialf(GL_EMISSION, RGB15(16,16,16)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + glPolyFmt(POLY_ALPHA(15) or POLY_CULL_BACK or POLY_FORMAT_LIGHT0); + + glMatrixMode(GL_MODELVIEW); + + while true do + begin + DrawGLScene(); + + // flush to screen + glFlush(0); + + // wait for the screen to refresh + swiWaitForVBlank(); + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/drunkenlogo.pcx.o b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/drunkenlogo.pcx.o Binary files differnew file mode 100644 index 0000000000..f24743fd17 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/drunkenlogo.pcx.o diff --git a/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/main.pp b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/main.pp new file mode 100644 index 0000000000..5db0e790e9 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/Graphics/3D/nehe/lesson11/main.pp @@ -0,0 +1,195 @@ +(**************************************** + * NDS NeHe Lesson 11 * + * Author: Dovoto * + ****************************************) +program main; +{$L drunkenlogo.pcx.o} +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + drunkenlogo_pcx_end: array [0..0] of u8; cvar; external; + drunkenlogo_pcx: array [0..0] of u8; cvar; external; + drunkenlogo_pcx_size: u32; cvar; external; + + points: array [0..63, 0..31, 0..2] of v16; // The Array For The Points On The Grid Of Our "Wave" + wiggle_count: integer = 0; // Counter Used To Control How Fast Flag Waves + + xrot: GLfloat; // X Rotation ( NEW ) + yrot: GLfloat; // Y Rotation ( NEW ) + zrot: GLfloat; // Z Rotation ( NEW ) + hold: v16; // Temporarily Holds A Floating Point Value + + texture: array [0..0] of integer; // Storage For 3 Textures (only going to use 1 on the DS for this demo) + +function DrawGLScene(): boolean; // Here's Where We Do All The Drawing +var + x, y: integer; + float_x, float_y, float_xb, float_yb: t16; +begin + + glColor3b(255,255,255); // set the vertex color + + glLoadIdentity(); // Reset The View + + glTranslatef(0.0,0.0,-12.0); + + glRotatef(xrot,1.0,0.0,0.0); + glRotatef(yrot,0.0,1.0,0.0); + glRotatef(zrot,0.0,0.0,1.0); + + glBindTexture(GL_TEXTURE_2D, texture[0]); + + glBegin(GL_QUADS); + for x := 0 to 30 do + begin + for y := 0 to 30 do + begin + float_x := inttot16(x) shl 2; + float_y := inttot16(y) shl 2; + float_xb := inttot16(x+1) shl 2; + float_yb := inttot16(y+1) shl 2; + + glTexCoord2t16( float_x, float_y); + glVertex3v16( points[x][y][0], points[x][y][1], points[x][y][2] ); + + glTexCoord2t16( float_x, float_yb ); + glVertex3v16( points[x][y+1][0], points[x][y+1][1], points[x][y+1][2] ); + + glTexCoord2t16( float_xb, float_yb ); + glVertex3v16( points[x+1][y+1][0], points[x+1][y+1][1], points[x+1][y+1][2] ); + + glTexCoord2t16( float_xb, float_y ); + glVertex3v16( points[x+1][y][0], points[x+1][y][1], points[x+1][y][2] ); + end; + end; + glEnd(); + + if ( wiggle_count = 2 ) then + begin + for y := 0 to 31 do + begin + hold := points[0][y][2]; + for x := 0 to 31 do + begin + points[x][y][2] := points[x+1][y][2]; + end; + points[31][y][2]:=hold; + end; + wiggle_count := 0; + end; + + inc(wiggle_count); + + xrot:=xrot+0.3; + yrot:=yrot+0.2; + zrot:=zrot+0.4; + + drawGLScene := TRUE; // Everything Went OK + +end; + + + +function LoadGLTextures(): boolean; // Load PCX files And Convert To Textures +var + pcx: sImage; //////////////(NEW) and different from nehe. +begin + //load our texture + loadPCX(pu8(drunkenlogo_pcx), @pcx); + + image8to16(@pcx); + + glGenTextures(1, @texture[0]); + glBindTexture(0, texture[0]); + glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); + + //imageDestroy(@pcx); + result := TRUE; +end; + +procedure InitGL(); +var + x, y:integer; +begin + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures + + // IRQ basic setup + irqInit(); + irqSet(IRQ_VBLANK, nil); + + + // initialize the geometry engine + glInit(); + + // enable textures + glEnable(GL_TEXTURE_2D); + + // Set our viewport to be the same size as the screen + glViewPort(0,0,255,191); + + // enable antialiasing + glEnable(GL_ANTIALIAS); + + // setup the rear plane + glClearColor(0,0,0,31); // BG must be opaque for AA to work + glClearPolyID(63); // BG must have a unique polygon ID for AA to work + glClearDepth($7FFF); + + LoadGLTextures(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(35, 256.0 / 192.0, 0.1, 100); + + //need to set up some material properties since DS does not have them set by default + glMaterialf(GL_AMBIENT, RGB15(31,31,31)); + glMaterialf(GL_DIFFUSE, RGB15(31,31,31)); + glMaterialf(GL_SPECULAR, BIT(15) or RGB15(16,16,16)); + glMaterialf(GL_EMISSION, RGB15(31,31,31)); + + //ds uses a table for shinyness..this generates a half-ass one + glMaterialShinyness(); + + //ds specific, several attributes can be set here + glPolyFmt(POLY_ALPHA(31) or POLY_CULL_NONE ); + + + for x:=0 to 31 do + begin + for y:=0 to 31 do + begin + points[x][y][0] := (inttov16(x) div 4); + points[x][y][1] := (inttov16(y) div 4); + points[x][y][2] := SIN_bin[ (x * 16) and LUT_MASK]; + end; + end; +end; + + +begin + InitGL(); + + glMatrixMode(GL_MODELVIEW); + + while true do + begin + DrawGLScene(); + + // flush to screen + glFlush(0); + + // wait for the screen to refresh + swiWaitForVBlank(); + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/debugging/exceptionTest/main.pp b/packages/libndsfpc/examples/devkitPro/debugging/exceptionTest/main.pp new file mode 100644 index 0000000000..957e4f2dca --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/debugging/exceptionTest/main.pp @@ -0,0 +1,29 @@ +program main; +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +// The default exception handler displays the exception type - data abort or undefined instruction +// you can relate the exception to your code using arm-eabi-addr2line -e <elf file> <address> +// assuming you built with debug info this will display a source file and a line number +// The address of the instruction is shown as pc, beside the address which faulted +// the rest of the screen is a dump of the registers. + +begin + // install the default exception handler + defaultExceptionHandler(); + + irqInit(); + irqEnable(IRQ_VBLANK); + + // generate an exception + pu32(250)^ := 100; + + while true do + swiWaitForVBlank(); + +end. diff --git a/packages/libndsfpc/examples/devkitPro/input/TouchTest/balldata.bin.o b/packages/libndsfpc/examples/devkitPro/input/TouchTest/balldata.bin.o Binary files differnew file mode 100644 index 0000000000..50fc3aba31 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/input/TouchTest/balldata.bin.o diff --git a/packages/libndsfpc/examples/devkitPro/input/TouchTest/ballpalette.bin.o b/packages/libndsfpc/examples/devkitPro/input/TouchTest/ballpalette.bin.o Binary files differnew file mode 100644 index 0000000000..5a8f857c0f --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/input/TouchTest/ballpalette.bin.o diff --git a/packages/libndsfpc/examples/devkitPro/input/TouchTest/main.pp b/packages/libndsfpc/examples/devkitPro/input/TouchTest/main.pp new file mode 100644 index 0000000000..bec3a00376 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/input/TouchTest/main.pp @@ -0,0 +1,174 @@ +program main; +{$L ballpalette.bin.o} +{$L balldata.bin.o} +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + +var + OAMCopy: array [0..127] of SpriteEntry; + ballpalette_bin_end: array [0..0] of u8; cvar; external; + ballpalette_bin: array [0..0] of u16; cvar; external; + ballpalette_bin_size: u32; cvar; external; + balldata_bin_end: array [0..0] of u8; cvar; external; + balldata_bin: array [0..0] of u16; cvar; external; + balldata_bin_size: u32; cvar; external; + + +procedure initOAM(); +var + i: integer; +begin + for i := 0 to 127 do + OAMCopy[i].st.attribute[0] := ATTR0_DISABLED; +end; + +//--------------------------------------------------------------------------------- +procedure updateOAM(); +begin + dmaCopy(@OAMCopy, OAM, sizeof(OAMCopy)); +end; + + +type + TTouchType = (ttContinuous, ttSingle); + +var + frame: integer; + TouchType: TTouchType = ttContinuous; + + +//--------------------------------------------------------------------------------- +function Vblank(): pointer; +begin +//--------------------------------------------------------------------------------- + inc(frame); +end; + + +var + min_x, min_y, max_x, max_y: integer; + min_px, min_py, max_px, max_py: integer; + touch: touchPosition; + i: integer; + pressed, held: integer; + +begin + min_x := 4096; + min_y := 4096; + max_x := 0; + max_y := 0; + min_px := 4096; + min_py := 4096; + max_px := 0; + max_py := 0; + + + powerON(POWER_ALL_2D); + + // put the main screen on the bottom lcd + lcdMainOnBottom(); + + // Initialise the interrupt system + irqInit(); + // install our simple vblank handler + irqSet(IRQ_VBLANK, @Vblank); + // enable the interrupt + irqEnable(IRQ_VBLANK); + initOAM(); + //enable vram and map it to the right places + vramSetMainBanks( VRAM_A_MAIN_SPRITE, //A and B maped consecutivly as sprite memory + VRAM_B_MAIN_SPRITE, //this gives us 256KB which is the max + VRAM_C_MAIN_BG_0x06000000, //map C to background memory + VRAM_D_LCD //not using D + ); + + //set the video mode + videoSetMode( MODE_0_2D or + DISPLAY_SPR_ACTIVE or //turn on sprites + DISPLAY_BG0_ACTIVE or //turn on background 0 + DISPLAY_SPR_1D //this is used when in tile mode + ); + + // Sprite initialisation + for i := 0 to 255 do + SPRITE_PALETTE[i] := u32(ballpalette_bin[i]); + + for i := 0 to 32*16 - 1 do + SPRITE_GFX[i] := u32(balldata_bin[i]); + + // black backdrop + BG_PALETTE[0] := (RGB15(0,0,0)); + + BG0_CR^ := BG_MAP_BASE(31);//use bg0 for the text + + BG_PALETTE[255] := (RGB15(31,31,31));//by default font rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK(31)), pu16(CHAR_BASE_BLOCK(0)), 16); + + + printf(#27 + '[4;8H' + 'Touch Screen Test'); + printf(#27 + '[15;4H' + 'Right Shoulder toggles'); + + while true do + begin + swiWaitForVBlank(); + updateOAM(); + + // read the button states + scanKeys(); + + // read the touchscreen coordinates + touch := touchReadXY(); + + pressed := keysDown(); // buttons pressed this loop + held := keysHeld(); // buttons currently held + + // Right Shoulder button toggles the mode + if ( pressed and KEY_R) <> 0 then Inc(TouchType); + + if TouchType = ttContinuous then + printf(#27 + '[14;4H' + 'Touch mode: CONTINUOUS ') + else + printf(#27 + '[14;4H' + 'Touch mode: SINGLE SHOT'); + + iprintf(#27 + '[6;5H' + 'Touch x = %04X, %04X' + #10, [touch.x, touch.px]); + iprintf(#27 + '[7;5H' + 'Touch x = %04X, %04X' + #10, [touch.x, touch.px]); + + + iprintf(#27 + '[0;18H' + 'keys: %08X' + #10, [keysHeld()]); + iprintf(#27 + '[9;10H' + 'Frame %d' + #10, [frame]); + + if (TouchType = ttSingle) and not ( (pressed and KEY_TOUCH) <> 0) then continue; + + if ((held and KEY_TOUCH)<0) or (touch.x = 0) or (touch.y = 0) then continue; + + iprintf(#27 + '[12;12H' + '(%d,%d) ', [touch.px,touch.py]); + + if ( touch.x > max_x) then max_x := touch.x; + if ( touch.y > max_y) then max_y := touch.y; + if ( touch.px > max_px) then max_px := touch.px; + if ( touch.py > max_py) then max_py := touch.py; + + if ( touch.x < min_x) then min_x := touch.x; + if ( touch.y < min_y) then min_y := touch.y; + if ( touch.px < min_px) then min_px := touch.px; + if ( touch.py < min_py) then min_py := touch.py; + + iprintf(#27 + '[0;0H' + '(%d,%d) ',[min_px,min_py]); + iprintf(#27 + '[1;0H' + '(%d,%d) ',[min_x,min_y]); + iprintf(#27 + '[22;21H' + '(%d,%d)',[max_x,max_y]); + iprintf(#27 + '[23;23H' + '(%d,%d)',[max_px,max_py]); + + OAMCopy[0].st.attribute[2] := 0; + OAMCopy[0].st.attribute[1] := ATTR1_SIZE_32 or ((touch.px - 16) and $01FF); + OAMCopy[0].st.attribute[0] := ATTR0_COLOR_256 or ATTR0_SQUARE or ((touch.py -16) and $00FF); + + end; + +end. diff --git a/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/blaster.raw.o b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/blaster.raw.o Binary files differnew file mode 100644 index 0000000000..edc8f9b82f --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/blaster.raw.o diff --git a/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/ion.raw.o b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/ion.raw.o Binary files differnew file mode 100644 index 0000000000..656d0ba6fb --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/ion.raw.o diff --git a/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/main.pp b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/main.pp new file mode 100644 index 0000000000..1ac73f6c34 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/main.pp @@ -0,0 +1,89 @@ +program main; +{$L blaster.raw.o} +{$L saberoff.raw.o} +{$L ion.raw.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + ctypes, nds9; + + +var + blaster_raw_end: array [0..0] of u8; cvar; external; + blaster_raw: array [0..0] of u8; cvar; external; + blaster_raw_size: u32; cvar; external; + ion_raw_end: array [0..0] of u8; cvar; external; + ion_raw: array [0..0] of u8; cvar; external; + ion_raw_size: u32; cvar; external; + saberoff_raw_end: array [0..0] of u8; cvar; external; + saberoff_raw: array [0..0] of u8; cvar; external; + saberoff_raw_size: u32; cvar; external; + + blaster: TransferSoundData; + keys: u16; + +begin + + powerON( POWER_LCD or POWER_2D_B ); + + // initialise the irq dispatcher + irqInit(); + // a vblank interrupt is needed to use swiWaitForVBlank() + // since the dispatcher handles the flags no handler is required + irqSet(IRQ_VBLANK, nil); + irqEnable(IRQ_VBLANK); + + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR^ := BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] := (RGB15(31,31,31)); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pu16(SCREEN_BASE_BLOCK_SUB(31)), pu16(CHAR_BASE_BLOCK_SUB(0)), 16); + + printf(#10#10 + 'Simple Sound Demo' + #10 + + 'Press A for SaberOff' + #10 + + ' L for ion' + #10 + + ' R for blaster' + #10); + + // set the generic sound parameters + setGenericSound( 11025, (* sample rate *) + 127, (* volume *) + 64, (* panning *) + 1 ); (* sound format*) + + + with blaster do + begin + data := @blaster_raw; + len := blaster_raw_size; + rate := 11025; + vol := 127; + pan := 64; + format := 1; + PADDING := 0; + end; + + + while true do + begin + swiWaitForVBlank(); + scanKeys(); + + keys := keysDown(); + + if ( keys and KEY_L) <> 0 then playGenericSound(@ion_raw, ion_raw_size); + + if ( keys and KEY_A) <> 0 then playGenericSound(@saberoff_raw, saberoff_raw_size); + + if ( keys and KEY_R) <> 0 then playSound(@blaster); + + end; +end. diff --git a/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/saberoff.raw.o b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/saberoff.raw.o Binary files differnew file mode 100644 index 0000000000..65ca2b4773 --- /dev/null +++ b/packages/libndsfpc/examples/devkitPro/sound/SimpleSound/saberoff.raw.o diff --git a/packages/libndsfpc/examples/dswifi/main7.pp b/packages/libndsfpc/examples/dswifi/main7.pp new file mode 100644 index 0000000000..342d24cf01 --- /dev/null +++ b/packages/libndsfpc/examples/dswifi/main7.pp @@ -0,0 +1,183 @@ +program main7; + +{$apptype arm7} +{$define ARM7} + +{$mode objfpc} + +uses + ctypes, nds7, dswifi7; + +{ $include dswifi7.inc} + + +procedure startSound(sampleRate: cint; const data: pointer; bytes: cuint32; channel, vol, pan, format: cuint8); +var + snd_format: integer; +begin + if format = 1 then + snd_format := SOUND_8BIT + else + snd_format := SOUND_16BIT; + SCHANNEL_TIMER(channel)^ := SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel)^ := cuint32(data^); + SCHANNEL_LENGTH(channel)^ := bytes shr 2; + SCHANNEL_CR(channel)^ := SCHANNEL_ENABLE or SOUND_ONE_SHOT or SOUND_VOL(vol) or SOUND_PAN(pan) or (snd_format); +end; + +function getFreeSoundChannel(): csint; +var + i: integer; +begin + for i := 0 to 15 do + if ((SCHANNEL_CR(i)^ and SCHANNEL_ENABLE)) = 0 then + result := i; + result := -1; +end; + +var + vcount: integer; + first, tempPos: touchPosition; + lastbut: integer = -1; + +procedure VcountHandler(); +var + but: integer; + x, y, xpx, ypx, z1, z2: cuint16; +begin + but := REG_KEYXY^; + if (( (but xor lastbut) and (1 shl 6))) = 0 then + begin + tempPos := touchReadXY(); + x := tempPos.x; + y := tempPos.y; + xpx := tempPos.px; + ypx := tempPos.py; + z1 := tempPos.z1; + z2 := tempPos.z2; + end else + begin + lastbut := but; + but := but or (1 shl 6); + end; + + if ( vcount = 80 ) then + begin + first := tempPos; + end else + begin + if (abs(xpx - first.px) > 10) or (abs(ypx - first.py) > 10) or ((but and (1 shl 6)) <> 0) then + begin + but := but or (1 shl 6); + lastbut := but; + end else + begin + IPC.mailBusy := 1; + IPC.touchX := x; + IPC.touchY := y; + IPC.touchXpx := xpx; + IPC.touchYpx := ypx; + IPC.touchZ1 := z1; + IPC.touchZ2 := z2; + IPC.mailBusy := 0; + end; + end; + IPC.buttons := but; + vcount := vcount xor (80 xor 130); + SetYtrigger(vcount); +end; + +procedure VblankHandler(); +var + i: integer; + snd: PTransferSound; + chan: csint; +begin + //sound code :) + snd := IPC.soundData; + IPC.soundData := nil; + + if (snd <> nil) then + begin + for i := 0 to snd^.count - 1 do + begin + chan := getFreeSoundChannel(); + if (chan >= 0) then + begin + 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); + end; + end; + end; + Wifi_Update(); +end; + +procedure arm7_synctoarm9(); +begin + // send fifo message + REG_IPC_FIFO_TX^ := $87654321; +end; + +procedure arm7_fifo(); +var + msg: cuint32; +begin + // check incoming fifo messages + msg := REG_IPC_FIFO_RX^; + if (msg = $87654321) then + Wifi_Sync(); +end; + +var + fifo_temp: cuint32; + +begin + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_SEND_CLEAR; + + // Reset the clock if needed + rtcReset(); + + //enable sound + powerON(POWER_SOUND); + SOUND_CR^ := SOUND_ENABLE or SOUND_VOL($7F); + IPC.soundData := nil; + IPC.mailBusy := 0; + + irqInit(); + irqSet(IRQ_VBLANK, @VblankHandler); + SetYtrigger(80); + vcount := 80; + + irqSet(IRQ_VCOUNT, @VcountHandler); + irqEnable(IRQ_VBLANK or IRQ_VCOUNT); + + irqSet(IRQ_WIFI, @Wifi_Interrupt); + irqEnable(IRQ_WIFI); + + // trade some mail, to get a pointer from arm9 + while fifo_temp <> $12345678 do + begin + while (REG_IPC_FIFO_CR^ and IPC_FIFO_RECV_EMPTY) <> 0 do + swiWaitForVBlank(); + fifo_temp := REG_IPC_FIFO_RX^; + end; + + while (REG_IPC_FIFO_CR^ and IPC_FIFO_RECV_EMPTY) <> 0 do + swiWaitForVBlank(); + + fifo_temp := REG_IPC_FIFO_RX^; + + Wifi_Init(fifo_temp); + + irqSet(IRQ_FIFO_NOT_EMPTY, @arm7_fifo); + irqEnable(IRQ_FIFO_NOT_EMPTY); + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_RECV_IRQ; + + Wifi_SetSyncHandler(@arm7_synctoarm9); + + + // Keep the ARM7 idle + while true do + swiWaitForVBlank(); +end. + + diff --git a/packages/libndsfpc/examples/dswifi/main9.pp b/packages/libndsfpc/examples/dswifi/main9.pp new file mode 100644 index 0000000000..fb11077416 --- /dev/null +++ b/packages/libndsfpc/examples/dswifi/main9.pp @@ -0,0 +1,202 @@ +(*--------------------------------------------------------------------------------- + $Id: template.c,v 1.4 2005/09/17 23:15:13 wntrmute Exp $ + + Basic Hello World + + $Log: template.c,v $ + Revision 1.4 2005/09/17 23:15:13 wntrmute + corrected iprintAt in templates + + Revision 1.3 2005/09/05 00:32:20 wntrmute + removed references to IPC struct + replaced with API functions + + Revision 1.2 2005/08/31 01:24:21 wntrmute + updated for new stdio support + + Revision 1.1 2005/08/03 06:29:56 wntrmute + added templates + + +---------------------------------------------------------------------------------*) +program main9; + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + + +uses + ctypes, nds9, dswifi9; + +{ $include dswifi9.inc} +{ $include socket.inc} +{ $include in.inc} +{ $include netdb.inc} + +//--------------------------------------------------------------------------------- +// Dswifi helper functions + +// wifi timer function, to update internals of sgIP +procedure Timer_50ms(); +begin + Wifi_Timer(50); +end; + +// notification function to send fifo message to arm7 +procedure arm9_synctoarm7(); +begin +// send fifo message + REG_IPC_FIFO_TX^ := $87654321; +end; + +// interrupt handler to receive fifo messages from arm7 +procedure arm9_fifo(); +var + value: cuint32; +begin + // check incoming fifo messages + value := REG_IPC_FIFO_RX^; + if value = $87654321 then + Wifi_Sync(); +end; + +procedure vblank_irq_handler(); +begin + Wifi_Update(); +end; + +var + Wifi_pass: cuint32; + i: integer; + myhost: PHostent; + my_socket: cint; + sain: sockaddr_in; + recvd_len: cint; + incoming_buffer: array [0..255] of char; + +const + request_text = + 'GET /dswifi/example1.php HTTP/1.1'#13#10 + + 'Host: www.akkit.org'#13#10 + + 'User-Agent: Nintendo DS'#13#10 +#13#10; + + +begin + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D or DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR^ := BG_MAP_BASE(31); + BG_PALETTE_SUB[255] := RGB15(31,31,31); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault(pcuint16(SCREEN_BASE_BLOCK_SUB(31)), pcuint16(CHAR_BASE_BLOCK_SUB(0)), 16); + iprintf(#10+#10+#9+'Hello World!' + #10); + + // send fifo message to initialize the arm7 wifi + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_SEND_CLEAR; // enable & clear FIFO + + Wifi_pass := Wifi_Init(WIFIINIT_OPTION_USELED); + REG_IPC_FIFO_TX^ := $12345678; + REG_IPC_FIFO_TX^ := Wifi_pass; + + TIMER3_CR^ := 0; // disable timer3 + + irqInit(); + irqSet(IRQ_VBLANK, @vblank_irq_handler); + irqSet(IRQ_TIMER3, @Timer_50ms); // setup timer IRQ + irqEnable(IRQ_VBLANK or IRQ_TIMER3); + + irqSet(IRQ_FIFO_NOT_EMPTY, @arm9_fifo); // setup fifo IRQ + irqEnable(IRQ_FIFO_NOT_EMPTY); + + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_RECV_IRQ; // enable FIFO IRQ + + Wifi_SetSyncHandler(@arm9_synctoarm7); // tell wifi lib to use our handler to notify arm7 + + // set timer3 + //TIMER3_DATA^ := -6553; // 6553.1 * 256 cycles = ~50ms; + TIMER3_DATA^ := TIMER_FREQ_256(1000 div 50); + TIMER0_CR^ := TIMER_ENABLE or TIMER_DIV_256 or TIMER_IRQ_REQ; // enable, irq, 1/256 clock + + while (Wifi_CheckInit() = 0) do // wait for arm7 to be initted successfully + begin + // wait for vblank + swiWaitForVBlank(); + end; + // wifi init complete - wifi lib can now be used! + + iprintf('Connecting via WFC data' + #10); + + // simple WFC connect: + Wifi_AutoConnect(); // request connect + + while true do + begin + i := Wifi_AssocStatus(); // check status + if (i = cint(ASSOCSTATUS_ASSOCIATED)) then + begin + iprintf('Connected successfully!' + #10); + break; + end; + if (i = cint(ASSOCSTATUS_CANNOTCONNECT)) then + begin + iprintf('Could not connect!' +#10); + while true do; + break; + end; + end; + // if connected, you can now use the berkley sockets interface to connect to the internet! + + ////////////////////////////////////////////////////////////////////////// + // Let's send a simple HTTP request to a server and print the results! + // store the HTTP request for later + // Find the IP address of the server, with gethostbyname + myhost := gethostbyname('www.akkit.org'); + iprintf('Found IP Address!' + #10); + + // Create a TCP socket + my_socket := socket( AF_INET, SOCK_STREAM, 0 ); + iprintf('Created Socket!' + #10); + + // Tell the socket to connect to the IP address we found, on port 80 (HTTP) + sain.sin_family := AF_INET; + sain.sin_port := htons(80); + + sain.sin_addr.s_addr := culong(Pointer(myhost^.h_addr_list^)^); + + iprintf(#10 + 'Accepted %d.%d.%d.%d:%d' + #10, [sain.sin_addr.s_addr and $FF, + (sain.sin_addr.s_addr shr 8) and $FF, + (sain.sin_addr.s_addr shr 16) and $FF, + (sain.sin_addr.s_addr shr 24) and $FF, + ntohs(sain.sin_port)]); + + connect(my_socket, psockaddr(@sain), sizeof(sain)); + iprintf('Connected to server!' + #10); + + // send our request + send(my_socket, pchar(request_text), strlen(request_text), 0); + iprintf('Sent our request!' + #10); + + // Print incoming data + iprintf('Printing incoming data:' + #10); + + + repeat + recvd_len := recv( my_socket, @incoming_buffer, 255, 0 ) ; + // if recv returns 0, the socket has been closed. + if (recvd_len > 0) then // data was received! + begin + incoming_buffer[recvd_len] := #0; // null-terminate + iprintf(incoming_buffer); + end; + until recvd_len <= 0; + + iprintf('Other side closed connection!' + #10); + shutdown(my_socket, 0); // good practice to shutdown the socket. + closesocket(my_socket); // remove the socket. + + while true do; +end. diff --git a/packages/libndsfpc/examples/libfat/main.pp b/packages/libndsfpc/examples/libfat/main.pp new file mode 100644 index 0000000000..5c1babc3a7 --- /dev/null +++ b/packages/libndsfpc/examples/libfat/main.pp @@ -0,0 +1,47 @@ +program main; +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +uses + nds9, fat; + +var + i: integer; + size: u32; + text: string; + handle: P_FILE; +begin + consoleDemoInit(); + videoSetMode(MODE_FB0); + vramSetBankA(VRAM_A_LCD); + + printf('fatInit()...'); + if fatInit(4, true) then + begin + printf(#9 + 'Success' + #10); + + handle := fopen('/test1.txt', 'r'); + if handle = nil then + begin + printf('Cannot open file' + #10); + end else + begin + fseek(handle, 0, SEEK_END); // Go to end of file + size := ftell(handle); // Get current position in file, because it is the end it will be the size + fseek(handle, 0, SEEK_SET); // Go to begining of file + fread(@text, size, 1, handle); // Read all of file into memory + printf(@text); + fclose(handle); // Close file + end; + end else + printf(#9 + 'Failure' + #10); + + for i := 0 to (256 * 192) - 1 do + VRAM_A[i] := RGB15(31,0,0); + + while true do; + + +end. diff --git a/packages/libndsfpc/examples/libfat/test1.txt b/packages/libndsfpc/examples/libfat/test1.txt new file mode 100644 index 0000000000..845b08fe32 --- /dev/null +++ b/packages/libndsfpc/examples/libfat/test1.txt @@ -0,0 +1,2 @@ +Hello world from test1.txt. +More text! diff --git a/packages/libndsfpc/examples/libmikmod/data/module.bin.o b/packages/libndsfpc/examples/libmikmod/data/module.bin.o Binary files differnew file mode 100644 index 0000000000..881d268ee4 --- /dev/null +++ b/packages/libndsfpc/examples/libmikmod/data/module.bin.o diff --git a/packages/libndsfpc/examples/libmikmod/main7.pp b/packages/libndsfpc/examples/libmikmod/main7.pp new file mode 100644 index 0000000000..68e8f36570 --- /dev/null +++ b/packages/libndsfpc/examples/libmikmod/main7.pp @@ -0,0 +1,157 @@ +program main7; + +{$apptype arm7} +{$define ARM7} + +{$mode objfpc} + +uses + ctypes, nds7, mikmod7; + +{ $include nds.inc} +{ $include mikmod.inc} + +procedure FIFOHandler(); +var + command: cuint32; +begin + while (REG_IPC_FIFO_CR^ and IPC_FIFO_RECV_EMPTY) = 0 do + begin + command := REG_IPC_FIFO_RX^; + if command >= (1 shl 28) then + MikMod7_ProcessCommand(command); + // process your own fifo messages here + end; +end; + +procedure startSound(sampleRate: cint; const data: pointer; bytes: cuint32; channel, vol, pan, format: cuint8); +var + snd_format: integer; +begin + if format = 1 then + snd_format := SOUND_8BIT + else + snd_format := SOUND_16BIT; + SCHANNEL_TIMER(channel)^ := SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel)^ := cuint32(data^); + SCHANNEL_LENGTH(channel)^ := bytes shr 2; + SCHANNEL_CR(channel)^ := SCHANNEL_ENABLE or SOUND_ONE_SHOT or SOUND_VOL(vol) or SOUND_PAN(pan) or (snd_format); +end; + + +function getFreeSoundChannel(): csint; +var + i: integer; +begin + for i := 0 to 15 do + if ((SCHANNEL_CR(i)^ and SCHANNEL_ENABLE)) = 0 then + result := i; + result := -1; +end; + +var + vcount: integer; + first, tempPos: touchPosition; + lastbut: integer = -1; + +procedure VcountHandler(); +var + but: integer; + x, y, xpx, ypx, z1, z2: cuint16; +begin + but := REG_KEYXY^; + + if (( (but xor lastbut) and (1 shl 6))) = 0 then + begin + tempPos := touchReadXY(); + + x := tempPos.x; + y := tempPos.y; + xpx := tempPos.px; + ypx := tempPos.py; + z1 := tempPos.z1; + z2 := tempPos.z2; + + end else + begin + lastbut := but; + but := but or (1 shl 6); + end; + + if ( vcount = 80 ) then + begin + first := tempPos; + end else + begin + if (abs(xpx - first.px) > 10) or (abs(ypx - first.py) > 10) or ((but and (1 shl 6)) <> 0) then + begin + but := but or (1 shl 6); + lastbut := but; + end else + begin + IPC.mailBusy := 1; + IPC.touchX := x; + IPC.touchY := y; + IPC.touchXpx := xpx; + IPC.touchYpx := ypx; + IPC.touchZ1 := z1; + IPC.touchZ2 := z2; + IPC.mailBusy := 0; + end; + end; + IPC.buttons := but; + vcount := vcount xor (80 xor 130); + SetYtrigger(vcount); +end; + +procedure VblankHandler(); +var + i: integer; + snd: PTransferSound; + chan: csint; +begin + //sound code :) + snd := IPC.soundData; + IPC.soundData := nil; + + if (snd <> nil) then + begin + for i := 0 to snd^.count - 1 do + begin + chan := getFreeSoundChannel(); + if (chan >= 0) then + begin + 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); + end; + end; + end; +end; + +begin + // init fifo + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_SEND_CLEAR; + + // Reset the clock if needed + rtcReset(); + + //enable sound + powerON(POWER_SOUND); + SOUND_CR^ := SOUND_ENABLE or SOUND_VOL($7F); + IPC.soundData := nil; + + irqInit(); + irqSet(IRQ_VBLANK, @VblankHandler); + irqEnable(IRQ_VBLANK); + SetYtrigger(80); + vcount := 80; + irqSet(IRQ_VCOUNT, @VcountHandler); + irqEnable(IRQ_VCOUNT); + + // Keep the ARM7 idle + while true do + begin + FIFOHandler(); + swiWaitForVBlank(); + end; +end. + diff --git a/packages/libndsfpc/examples/libmikmod/main9.pp b/packages/libndsfpc/examples/libmikmod/main9.pp new file mode 100644 index 0000000000..7abaad91d8 --- /dev/null +++ b/packages/libndsfpc/examples/libmikmod/main9.pp @@ -0,0 +1,121 @@ +program main9; + +{$L data/module.bin.o} + +{$apptype arm9} +{$define ARM9} + +{$mode objfpc} + +{$define HW_MIXER} // It works fine on hardware, but on no$gba sound is distorted +{ $define SW_MIXER} // It works fine both on hardware and no$gba +{ $define NO_MIXER} // No mixer, no sound :) + +uses + ctypes, nds9, mikmod9; +{ $include nds.inc} + +{ $include mikmod.inc} + +var + module_bin_end: array [0..0] of cuint8; cvar; external; + module_bin: array [0..0] of cuint8; cvar; external; + module_bin_size: cuint32; cvar; external; + +// called by the drivers in mikmod library +procedure MikMod9_SendCommand(command: cuint); cdecl; export; +begin + while (REG_IPC_FIFO_CR^ and IPC_FIFO_SEND_FULL) <> 0 do; + REG_IPC_FIFO_TX^ := command; +end; + +procedure TimerInterrupt(); +begin + // player tick + MikMod_Update(); + // the bpm can change in the middle of the song + TIMER0_DATA^ := TIMER_FREQ_256((md_bpm * 50) div 125); +end; + +var + song: PModule; + +begin + REG_IPC_FIFO_CR^ := IPC_FIFO_ENABLE or IPC_FIFO_SEND_CLEAR; + + consoleDemoInit(); + irqInit(); + + irqEnable(IRQ_VBLANK); + +{$ifdef HW_MIXER} + MikMod_RegisterDriver(@drv_nds_hw); +{$endif HW_MIXER} + +{$ifdef SW_MIXER} + MikMod_RegisterDriver(@drv_nds_sw); +{$endif HW_MIXER} + +{$ifdef NO_MIXER} + MikMod_RegisterDriver(@drv_nos); +{$endif NO_MIXER} + + // if we don't know what kind of module we're going to load we can register + // all loaders, but that will result in a larger binary + //MikMod_RegisterAllLoaders(); + MikMod_RegisterLoader(@load_it); + + printf('Initializing library' + #10); + if (MikMod_Init('') <> 0) then + begin + printf('Could not initialize sound, reason: ' + #10 + '%s' + #10, MikMod_strerror(MikMod_errno)); + exit; + end; + + printf(#10 + 'Loading module' + #10); + // Player_LoadMemory() loads a module directly from memory + // it could be possible to use Player_Load() to load from FAT, + // but I've never tried this + song := Player_LoadMemory(@module_bin, module_bin_size, 64, 0); + if assigned(song) then + begin + printf('Title: %s' + #10, song^.songname); + printf('Channels: %u' + #10, song^.numchn); + printf('bpm: %u' + #10, md_bpm); + + printf(#10 + 'Starting module' + #10); + + Player_Start(song); + + irqSet(IRQ_TIMER0, @TimerInterrupt); + // call update with correct timing + TIMER0_CR^ := TIMER0_CR^ and not TIMER_ENABLE; + TIMER0_DATA^ := TIMER_FREQ_256(md_bpm * 50 div 125); + TIMER0_CR^ := TIMER_ENABLE or TIMER_DIV_256 or TIMER_IRQ_REQ; + irqEnable(IRQ_TIMER0); + + // save cursor position + printf(#27 + '[s'); + + while (Player_Active() <> 0) do + begin + // when using the software driver we could call update + // here instead + //MikMod_Update(); + + // I need to fix this part, because I get crap values :P + //printf('Time: %i : %02i : %02i' + #27 + '[u', (song^.sngtime div 60000),(song^.sngtime div 1000) mod 60,(song^.sngtime div 10) mod 100); + //printf(#10 + 'Time: %u' + #27 + '[u', [(song^.sngtime div 1000) mod 60]); + + swiWaitForVBlank(); + end; + + printf(#10 + 'Stopping module' + #10); + Player_Stop(); + Player_Free(song); + end else + printf('Could not load module, reason: ' + #10 + '%s' + #10, MikMod_strerror(MikMod_errno)); + + printf(#10 + 'Exit library' + #10); + MikMod_Exit(); +end. diff --git a/packages/libndsfpc/fpmake.pp b/packages/libndsfpc/fpmake.pp new file mode 100644 index 0000000000..86501349d4 --- /dev/null +++ b/packages/libndsfpc/fpmake.pp @@ -0,0 +1,29 @@ +{$ifndef ALLPACKAGES} +{$mode objfpc}{$H+} +program fpmake; + +uses fpmkunit; + +Var + P : TPackage; + T : TTarget; +begin + With Installer do + begin +{$endif ALLPACKAGES} + + P:=AddPackage('libndsfpc'); +{$ifdef ALLPACKAGES} + P.Directory:='libndsfpc'; +{$endif ALLPACKAGES} + P.Version:='2.0.0'; + P.SourcePath.Add('src'); +// P.Dependencies.Add('x11'); + + // not linux compilable, skip + +{$ifndef ALLPACKAGES} + Run; + end; +end. +{$endif ALLPACKAGES} diff --git a/packages/libndsfpc/src/dswifi/dswifi7.inc b/packages/libndsfpc/src/dswifi/dswifi7.inc new file mode 100644 index 0000000000..9a7e1ed445 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/dswifi7.inc @@ -0,0 +1,60 @@ +(* + $Id: dswifi7.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - Arm7 Library Header file (dswifi7.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + +{$include dswifi_version.inc} + +{$ifdef NDS_INTERFACE} + +type + WifiSyncHandler = procedure; + +procedure Read_Flash(address: cint; destination: pcchar; length: cint); cdecl; external; +function PowerChip_ReadWrite(cmd, data: cint): cint; cdecl; external; +procedure Wifi_Interrupt(); cdecl; external; +procedure Wifi_Update(); cdecl; external; +procedure Wifi_Init(WifiData: culong); cdecl; external; +procedure Wifi_Deinit(); cdecl; external; +procedure Wifi_Sync(); cdecl; external; +procedure Wifi_SetSyncHandler(sh: WifiSyncHandler); cdecl; external; +//procedure Wifi_SetSyncHandler(sh: pointer); cdecl; external; + +{$endif NDS_INTERFACE} + diff --git a/packages/libndsfpc/src/dswifi/dswifi7.pp b/packages/libndsfpc/src/dswifi/dswifi7.pp new file mode 100644 index 0000000000..635142b1a5 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/dswifi7.pp @@ -0,0 +1,32 @@ +unit dswifi7; +{$mode objfpc} +{$apptype arm7} +{$define arm7} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds7; + +{$linklib nds7} +{$linklib dswifi7} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include dswifi7.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include dswifi7.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/dswifi/dswifi9.inc b/packages/libndsfpc/src/dswifi/dswifi9.inc new file mode 100644 index 0000000000..2fdec8a9d8 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/dswifi9.inc @@ -0,0 +1,220 @@ +(* + $Id: dswifi9.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - Arm9 Library Header File (dswifi9.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + + +{$include dswifi_version.inc} + +{$include sys/socket.inc} +{$include netinet/in.inc} +{$include netdb.inc} + +{$ifdef NDS_INTERFACE} + +const + WIFIINIT_OPTION_USELED = $0002; + + WIFIINIT_OPTION_USEHEAP_128 = $0000; + WIFIINIT_OPTION_USEHEAP_64 = $1000; + WIFIINIT_OPTION_USEHEAP_256 = $2000; + WIFIINIT_OPTION_USEHEAP_512 = $3000; + WIFIINIT_OPTION_USECUSTOMALLOC = $4000; + WIFIINIT_OPTION_HEAPMASK = $F000; + + WFLAG_PACKET_DATA = $0001; + WFLAG_PACKET_MGT = $0002; + WFLAG_PACKET_BEACON = $0004; + WFLAG_PACKET_CTRL = $0008; + + WFLAG_PACKET_ALL = $FFFF; + + + WFLAG_APDATA_ADHOC = $0001; + WFLAG_APDATA_WEP = $0002; + WFLAG_APDATA_WPA = $0004; + WFLAG_APDATA_COMPATIBLE = $0008; + WFLAG_APDATA_EXTCOMPATIBLE = $0010; + WFLAG_APDATA_SHORTPREAMBLE = $0020; + WFLAG_APDATA_ACTIVE = $8000; + +type + TWIFI_RETURN = ( + WIFI_RETURN_OK = 0, + WIFI_RETURN_LOCKFAILED = 1, + WIFI_RETURN_ERROR = 2, + WIFI_RETURN_PARAMERROR = 3 + ); + + TWIFI_STATS = ( + WSTAT_RXQUEUEDPACKETS, + WSTAT_TXQUEUEDPACKETS, + WSTAT_RXQUEUEDBYTES, + WSTAT_TXQUEUEDBYTES, + WSTAT_RXQUEUEDLOST, + WSTAT_TXQUEUEDREJECTED, + WSTAT_RXPACKETS, + WSTAT_RXBYTES, + WSTAT_RXDATABYTES, + WSTAT_TXPACKETS, + WSTAT_TXBYTES, + WSTAT_TXDATABYTES, + + WSTAT_HW_1B0,WSTAT_HW_1B1,WSTAT_HW_1B2,WSTAT_HW_1B3,WSTAT_HW_1B4,WSTAT_HW_1B5,WSTAT_HW_1B6,WSTAT_HW_1B7, + WSTAT_HW_1B8,WSTAT_HW_1B9,WSTAT_HW_1BA,WSTAT_HW_1BB,WSTAT_HW_1BC,WSTAT_HW_1BD,WSTAT_HW_1BE,WSTAT_HW_1BF, + WSTAT_HW_1C0,WSTAT_HW_1C1,WSTAT_HW_1C4,WSTAT_HW_1C5, + WSTAT_HW_1D0,WSTAT_HW_1D1,WSTAT_HW_1D2,WSTAT_HW_1D3,WSTAT_HW_1D4,WSTAT_HW_1D5,WSTAT_HW_1D6,WSTAT_HW_1D7, + WSTAT_HW_1D8,WSTAT_HW_1D9,WSTAT_HW_1DA,WSTAT_HW_1DB,WSTAT_HW_1DC,WSTAT_HW_1DD,WSTAT_HW_1DE,WSTAT_HW_1DF, + + NUM_WIFI_STATS + ); + + TWIFI_MODE = ( + WIFIMODE_DISABLED, + WIFIMODE_NORMAL, + WIFIMODE_SCAN, + WIFIMODE_ASSOCIATE, + WIFIMODE_ASSOCIATED, + WIFIMODE_DISASSOCIATE, + WIFIMODE_CANNOTASSOCIATE + ); + + TWIFI_AUTHLEVEL = ( + WIFI_AUTHLEVEL_DISCONNECTED, + WIFI_AUTHLEVEL_AUTHENTICATED, + WIFI_AUTHLEVEL_ASSOCIATED, + WIFI_AUTHLEVEL_DEASSOCIATED + ); + + TWIFIGETDATA = ( + WIFIGETDATA_MACADDRESS, + WIFIGETDATA_NUMWFCAPS, + MAX_WIFIGETDATA + ); + + + TWEPMODES = ( + WEPMODE_NONE = 0, + WEPMODE_40BIT = 1, + WEPMODE_128BIT = 2 + ); + + TWIFI_ASSOCSTATUS = ( + ASSOCSTATUS_DISCONNECTED, + ASSOCSTATUS_SEARCHING, + ASSOCSTATUS_AUTHENTICATING, + ASSOCSTATUS_ASSOCIATING, + ASSOCSTATUS_ACQUIRINGDHCP, + ASSOCSTATUS_ASSOCIATED, + ASSOCSTATUS_CANNOTCONNECT + ); + + WIFI_TXHEADER = record + enable_flags: cuint16; + unknown: cuint16; + countup: cuint16; + beaconfreq: cuint16; + tx_rate: cuint16; + tx_length: cuint16; + end; + TWIFI_TXHEADER = WIFI_TXHEADER; + PWIFI_TXHEADER = ^WIFI_TXHEADER; + + WIFI_RXHEADER = record + a: cuint16; + b: cuint16; + c: cuint16; + d: cuint16; + byteLength: cuint16; + rssi_: cuint16; + end; + TWIFI_RXHEADER = WIFI_RXHEADER; + PWIFI_RXHEADER = ^WIFI_RXHEADER; + + WIFI_ACCESSPOINT = packed record + ssid: array [0..32] of cchar; + ssid_len: cchar; + bssid: array [0..5] of cuint8; + macaddr: array [0..5] of cuint8; + maxrate: cuint16; + timectr: cuint32; + rssi: cuint16; + flags: cuint16; + spinlock: cuint32; + channel: cuint8; + rssi_past: array [0..7] of cuint8; + base_rates: array [0..15] of cuint8; + end; + TWIFI_ACCESSPOINT = WIFI_ACCESSPOINT; + PWIFI_ACCESSPOINT = ^WIFI_ACCESSPOINT; + + WifiPacketHandler = procedure(packetID, packetlength: cint); + + WifiSyncHandler = procedure; + + +function Wifi_Init(initflags: cint): culong; cdecl; external; +function Wifi_CheckInit(): cint; cdecl; external; +procedure Wifi_DisableWifi(); cdecl; external; +procedure Wifi_EnableWifi(); cdecl; external; +procedure Wifi_SetPromiscuousMode(enable: cint); cdecl; external; +procedure Wifi_ScanMode(); cdecl; external; +procedure Wifi_SetChannel(channel: cint); cdecl; external; +function Wifi_GetNumAP(): cint; cdecl; external; +function Wifi_GetAPData(apnum: cint; apdata: PWifi_AccessPoint): cint; cdecl; external; +function Wifi_FindMatchingAP(numaps: cint; apdata: PWifi_AccessPoint; match_dest: PWifi_AccessPoint): cint; cdecl; external; +function Wifi_ConnectAP(apdata: PWifi_AccessPoint; wepmode, wepkeyid: cint; wepkey: pcuchar): cint; cdecl; external; +procedure Wifi_AutoConnect(); cdecl; external; +function Wifi_AssocStatus(): cint; cdecl; external; +function Wifi_DisconnectAP(): cint; cdecl; external; +procedure Wifi_Timer(num_ms: cint); cdecl; external; +function Wifi_GetIP(): cuint32; cdecl; external; +function Wifi_GetIPInfo(pGateway, pSnmask, pDns1, pDns2: pcuint32): cuint32; cdecl; external; +procedure Wifi_SetIP(IPaddr, gateway, subnetmask, dns1, dns2: u32); cdecl; external; +function Wifi_GetData(datatype, bufferlen: cint; buffer: pcuchar): cint; cdecl; external; +function Wifi_GetStats(statnum: cint): cuint32; cdecl; external; +function Wifi_RawTxFrame(datalen, rate: cuint16; data: pcuint16): cint; cdecl; external; +procedure Wifi_RawSetPacketHandler(wphfunc: WifiPacketHandler); cdecl; external; +function Wifi_RxRawReadPacket(packetID, readlength: cint32; data: pcuint16): cint; cdecl; external; +procedure Wifi_Update(); cdecl; external; +procedure Wifi_Sync(); cdecl; external; +procedure Wifi_SetSyncHandler(sh: WifiSyncHandler); cdecl; external; +//procedure Wifi_SetSyncHandler(sh: pointer); cdecl; external; + +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/dswifi/dswifi9.pp b/packages/libndsfpc/src/dswifi/dswifi9.pp new file mode 100644 index 0000000000..dca1b60719 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/dswifi9.pp @@ -0,0 +1,32 @@ +unit dswifi9; +{$mode objfpc} +{$apptype arm9} +{$define arm9} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds9; + +{$linklib nds9} +{$linklib dswifi9} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include dswifi9.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include dswifi9.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/dswifi/dswifi_version.inc b/packages/libndsfpc/src/dswifi/dswifi_version.inc new file mode 100644 index 0000000000..5515bb84c0 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/dswifi_version.inc @@ -0,0 +1,7 @@ +{$ifdef NDS_INTERFACE} +const + DSWIFI_MAJOR = 0; + DSWIFI_MINOR = 3; + DSWIFI_REVISION = 4; + DSWIFI_VERSION = '0.3.4'; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/dswifi/netdb.inc b/packages/libndsfpc/src/dswifi/netdb.inc new file mode 100644 index 0000000000..0041ecadd5 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/netdb.inc @@ -0,0 +1,57 @@ +(* + $Id: netdb.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - socket emulation layer defines/prototypes (netdb.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + +{$ifdef NDS_INTERFACE} + +type + ppcchar = ^pcchar; + hostent = record + h_name: pcchar; + h_aliases: ppcchar; + h_addrtype: cint; + h_length: cint; + h_addr_list: ppcchar; + end; + phostent = ^hostent; + +function gethostbyname(const name: pchar): phostent; cdecl; external; + +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/dswifi/netinet/in.inc b/packages/libndsfpc/src/dswifi/netinet/in.inc new file mode 100644 index 0000000000..a43a1367fc --- /dev/null +++ b/packages/libndsfpc/src/dswifi/netinet/in.inc @@ -0,0 +1,65 @@ +(* + $Id: in.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - socket emulation layer defines/prototypes (netinet/in.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + +{$ifdef NDS_INTERFACE} +const + INADDR_ANY = $00000000; + INADDR_BROADCAST = $FFFFFFFF; + INADDR_NONE = $FFFFFFFF; + +type + in_addr = packed record + s_addr: culong; + end; + pin_addr = ^in_addr; + + sockaddr_in = packed record + sin_family: cushort; + sin_port: cushort; + sin_addr: in_addr; + sin_zero: array [0..7] of cuchar; + end; + + +function inet_addr(const cp: pchar): culong; cdecl; external; +function inet_aton(const cp: pchar; inp: pin_addr): cint; cdecl; external; +function inet_ntoa(_in: in_addr): pcchar; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/dswifi/sgIP_errno.inc b/packages/libndsfpc/src/dswifi/sgIP_errno.inc new file mode 100644 index 0000000000..14cefe7cac --- /dev/null +++ b/packages/libndsfpc/src/dswifi/sgIP_errno.inc @@ -0,0 +1,183 @@ +(* + $Id: sgIP_errno.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - socket emulation layer defines/prototypes (sgIP_errno.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + + +(**** Note: This file is unused unless you need to build in an environment without newlib ****) + +{$ifdef NDS_INTERFACE} + +const + EPERM = 1; (* Operation not permitted *) + ENOENT = 2; (* No such file or directory *) + ESRCH = 3; (* No such process *) + EINTR = 4; (* Interrupted system call *) + EIO = 5; (* I/O error *) + ENXIO = 6; (* No such device or address *) + E2BIG = 7; (* Arg list too long *) + ENOEXEC = 8; (* Exec format error *) + EBADF = 9; (* Bad file number *) + ECHILD = 10; (* No child processes *) + EAGAIN = 11; (* Try again *) + ENOMEM = 12; (* Out of memory *) + EACCES = 13; (* Permission denied *) + EFAULT = 14; (* Bad address *) + ENOTBLK = 15; (* Block device required *) + EBUSY = 16; (* Device or resource busy *) + EEXIST = 17; (* File exists *) + EXDEV = 18; (* Cross-device link *) + ENODEV = 19; (* No such device *) + ENOTDIR = 20; (* Not a directory *) + EISDIR = 21; (* Is a directory *) + EINVAL = 22; (* Invalid argument *) + ENFILE = 23; (* File table overflow *) + EMFILE = 24; (* Too many open files *) + ENOTTY = 25; (* Not a typewriter *) + ETXTBSY = 26; (* Text file busy *) + EFBIG = 27; (* File too large *) + ENOSPC = 28; (* No space left on device *) + ESPIPE = 29; (* Illegal seek *) + EROFS = 30; (* Read-only file system *) + EMLINK = 31; (* Too many links *) + EPIPE = 32; (* Broken pipe *) + EDOM = 33; (* Math argument out of domain of func *) + ERANGE = 34; (* Math result not representable *) + EDEADLK = 35; (* Resource deadlock would occur *) + ENAMETOOLONG = 36; (* File name too long *) + ENOLCK = 37; (* No record locks available *) + ENOSYS = 38; (* Function not implemented *) + ENOTEMPTY = 39; (* Directory not empty *) + ELOOP = 40; (* Too many symbolic links encountered *) + EWOULDBLOCK = EAGAIN; (* Operation would block *) + ENOMSG = 42; (* No message of desired type *) + EIDRM = 43; (* Identifier removed *) + ECHRNG = 44; (* Channel number out of range *) + EL2NSYNC = 45; (* Level 2 not synchronized *) + EL3HLT = 46; (* Level 3 halted *) + EL3RST = 47; (* Level 3 reset *) + ELNRNG = 48; (* Link number out of range *) + EUNATCH = 49; (* Protocol driver not attached *) + ENOCSI = 50; (* No CSI structure available *) + EL2HLT = 51; (* Level 2 halted *) + EBADE = 52; (* Invalid exchange *) + EBADR = 53; (* Invalid request descriptor *) + EXFULL = 54; (* Exchange full *) + ENOANO = 55; (* No anode *) + EBADRQC = 56; (* Invalid request code *) + EBADSLT = 57; (* Invalid slot *) + + EDEADLOCK = EDEADLK; + + EBFONT = 59; (* Bad font file format *) + ENOSTR = 60; (* Device not a stream *) + ENODATA = 61; (* No data available *) + ETIME = 62; (* Timer expired *) + ENOSR = 63; (* Out of streams resources *) + ENONET = 64; (* Machine is not on the network *) + ENOPKG = 65; (* Package not installed *) + EREMOTE = 66; (* Object is remote *) + ENOLINK = 67; (* Link has been severed *) + EADV = 68; (* Advertise error *) + ESRMNT = 69; (* Srmount error *) + ECOMM = 70; (* Communication error on send *) + EPROTO = 71; (* Protocol error *) + EMULTIHOP = 72; (* Multihop attempted *) + EDOTDOT = 73; (* RFS specific error *) + EBADMSG = 74; (* Not a data message *) + EOVERFLOW = 75; (* Value too large for defined data type *) + ENOTUNIQ = 76; (* Name not unique on network *) + EBADFD = 77; (* File descriptor in bad state *) + EREMCHG = 78; (* Remote address changed *) + ELIBACC = 79; (* Can not access a needed shared library *) + ELIBBAD = 80; (* Accessing a corrupted shared library *) + ELIBSCN = 81; (* .lib section in a.out corrupted *) + ELIBMAX = 82; (* Attempting to link in too many shared libraries *) + ELIBEXEC = 83; (* Cannot exec a shared library directly *) + EILSEQ = 84; (* Illegal byte sequence *) + ERESTART = 85; (* Interrupted system call should be restarted *) + ESTRPIPE = 86; (* Streams pipe error *) + EUSERS = 87; (* Too many users *) + ENOTSOCK = 88; (* Socket operation on non-socket *) + EDESTADDRREQ = 89; (* Destination address required *) + EMSGSIZE = 90; (* Message too long *) + EPROTOTYPE = 91; (* Protocol wrong type for socket *) + ENOPROTOOPT = 92; (* Protocol not available *) + EPROTONOSUPPORT= 93; (* Protocol not supported *) + ESOCKTNOSUPPORT= 94; (* Socket type not supported *) + EOPNOTSUPP = 95; (* Operation not supported on transport endpoint *) + EPFNOSUPPORT = 96; (* Protocol family not supported *) + EAFNOSUPPORT = 97; (* Address family not supported by protocol *) + EADDRINUSE = 98; (* Address already in use *) + EADDRNOTAVAIL = 99; (* Cannot assign requested address *) + ENETDOWN = 100; (* Network is down *) + ENETUNREACH = 101; (* Network is unreachable *) + ENETRESET = 102; (* Network dropped connection because of reset *) + ECONNABORTED = 103; (* Software caused connection abort *) + ECONNRESET = 104; (* Connection reset by peer *) + ENOBUFS = 105; (* No buffer space available *) + EISCONN = 106; (* Transport endpoint is already connected *) + ENOTCONN = 107; (* Transport endpoint is not connected *) + ESHUTDOWN = 108; (* Cannot send after transport endpoint shutdown *) + ETOOMANYREFS = 109; (* Too many references: cannot splice *) + ETIMEDOUT = 110; (* Connection timed out *) + ECONNREFUSED = 111; (* Connection refused *) + EHOSTDOWN = 112; (* Host is down *) + EHOSTUNREACH = 113; (* No route to host *) + EALREADY = 114; (* Operation already in progress *) + EINPROGRESS = 115; (* Operation now in progress *) + ESTALE = 116; (* Stale NFS file handle *) + EUCLEAN = 117; (* Structure needs cleaning *) + ENOTNAM = 118; (* Not a XENIX named type file *) + ENAVAIL = 119; (* No XENIX semaphores available *) + EISNAM = 120; (* Is a named type file *) + EREMOTEIO = 121; (* Remote I/O error *) + EDQUOT = 122; (* Quota exceeded *) + + ENOMEDIUM = 123; (* No medium found *) + EMEDIUMTYPE = 124; (* Wrong medium type *) + + +{$ifndef errno} +var + sgIP_errno: cint; cvar; external; + {$define errno := sgIP_errno} +{$endif} + +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/dswifi/sys/socket.inc b/packages/libndsfpc/src/dswifi/sys/socket.inc new file mode 100644 index 0000000000..3f4e6a1988 --- /dev/null +++ b/packages/libndsfpc/src/dswifi/sys/socket.inc @@ -0,0 +1,166 @@ +(* + $Id: socket.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + DSWifi Project - socket emulation layer defines/prototypes (sys/socket.h) + (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org + ****************************************************************************** + DSWifi Lib and test materials are licenced under the MIT open source licence: + Copyright (c) 2005-2006 Stephen Stair + + 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. + ****************************************************************************** + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + Comments: + +*) + + +{$ifdef NDS_INTERFACE} + +const +//#include <sys/time.h> + SOL_SOCKET = $fff; (* options for socket level *) + SOL_TCP = 6; (* TCP level *) + PF_UNSPEC = 0; + PF_INET = 2; + PF_INET6 = 10; + + AF_UNSPEC = PF_UNSPEC; + AF_INET = PF_INET; + AF_INET6 = PF_INET6; + + SOCK_STREAM = 1; + SOCK_DGRAM = 2; + +// need to sync FIO* values with commonly accepted ones sometime + FIONBIO = 1; + FIONREAD = 2; + + SOCKET_ERROR = -1; + +// send()/recv()/etc flags +// at present, only MSG_PEEK is implemented though. + MSG_WAITALL = $40000000; + MSG_TRUNC = $20000000; + MSG_PEEK = $10000000; + MSG_OOB = $08000000; + MSG_EOR = $04000000; + MSG_DONTROUTE = $02000000; + MSG_CTRUNC = $01000000; + +// shutdown() flags: + SHUT_RD = 1; + SHUT_WR = 2; + SHUT_RDWR = 3; + + + SO_DEBUG = $0001; (* turn on debugging info recording *) + SO_ACCEPTCONN = $0002; (* socket has had listen() *) + SO_REUSEADDR = $0004; (* allow local address reuse *) + SO_KEEPALIVE = $0008; (* keep connections alive *) + SO_DONTROUTE = $0010; (* just use interface addresses *) + SO_BROADCAST = $0020; (* permit sending of broadcast msgs *) + SO_USELOOPBACK = $0040; (* bypass hardware when possible *) + SO_LINGER = $0080; (* linger on close if data present *) + SO_OOBINLINE = $0100; (* leave received OOB data in line *) + SO_REUSEPORT = $0200; (* allow local address & port reuse *) + + SO_DONTLINGER = not SO_LINGER; + + SO_SNDBUF = $1001; (* send buffer size *) + SO_RCVBUF = $1002; (* receive buffer size *) + SO_SNDLOWAT = $1003; (* send low-water mark *) + SO_RCVLOWAT = $1004; (* receive low-water mark *) + SO_SNDTIMEO = $1005; (* send timeout *) + SO_RCVTIMEO = $1006; (* receive timeout *) + SO_ERROR = $1007; (* get error status and clear *) + SO_TYPE = $1008; (* get socket type *) +type + sockaddr = record + _sa_family: cushort; + sa_data: array [0..13] of char; + end; + psockaddr = ^sockaddr; + + +function socket(domain, _type, protocol: cint): cint; cdecl; external; +function bind(socket: cint; {const} addr: psockaddr; addr_len: cint): cint; cdecl; external; +function connect(socket: cint; {const} addr: psockaddr; addr_len: cint): cint; cdecl; external; +function send(socket: cint; {const} data: pointer; sendlength, flags: cint): cint; cdecl; external; +function recv(socket: cint; data: pointer; recvlength, flags: cint): cint; cdecl; external; +function sendto(socket: cint; {const} data: pointer; sendlength, flags: cint; const addr: psockaddr; addr_len: cint): cint; cdecl; external; +function recvfrom(socket: cint; data: pointer; recvlength, flags: cint; addr: psockaddr; addr_len: pcint): cint; cdecl; external; +function listen(socket, max_connections: cint): cint; cdecl; external; +function accept(socket: cint; addr: psockaddr; addr_len: pcint): cint; cdecl; external; +function shutdown(socket, shutdown_type: cint): cint; cdecl; external; +function closesocket(socket: cint): cint; cdecl; external; + +function ioctl(socket: cint; cmd: clong; arg: pointer): cint; cdecl; external; + +function setsockopt(socket, level, option_name: cint; const data: pointer; data_len: cint): cint; cdecl; external; +function getsockopt(socket, level, option_name: cint; data: pointer; data_len: pcint): cint; cdecl; external; + +function getpeername(socket: cint; addr: psockaddr; addr_len: pcint): cint; cdecl; external; +function getsockname(socket: cint; addr: psockaddr; addr_len: pcint): cint; cdecl; external; + +function gethostname(name: pcchar; {size_t} len: cuint): cint; cdecl; external; +function sethostname(const name: pcchar; {size_t} len: cuint): cint; cdecl; external; + +function htons(num: cushort): cushort; cdecl; external; +function htonl(num: culong): culong; cdecl; external; + +function ntohs(num: cushort): cushort; inline; +function ntohl(num: culong): culong; inline; + + +type + fd_set = array [0..7] of clong; + pfd_set = ^fd_set; + + timeval = packed record + sec: clong; + usec: clong; + end; + ptimeval = ^timeval; + + +function select(nfds: cint; readfds, writefds, errorfds: pfd_set; timeout: ptimeval): cint; cdecl; external; +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +function ntohs(num: cushort): cushort; inline; +begin + ntohs := htons(num); +end; + +function ntohl(num: culong): culong; inline; +begin + ntohl := htonl(num); +end; + +{$endif NDS_IMPLEMENTATION} diff --git a/packages/libndsfpc/src/fat/fat.inc b/packages/libndsfpc/src/fat/fat.inc new file mode 100644 index 0000000000..83bd8e10bb --- /dev/null +++ b/packages/libndsfpc/src/fat/fat.inc @@ -0,0 +1,88 @@ +(* + $Id: fat.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) +{$ifdef NDS_INTERFACE} + +const + FEATURE_MEDIUM_CANREAD = $00000001; + FEATURE_MEDIUM_CANWRITE = $00000002; + FEATURE_SLOT_GBA = $00000010; + FEATURE_SLOT_NDS = $00000020; + +type + FN_MEDIUM_STARTUP = function: cbool; + FN_MEDIUM_ISINSERTED = function: cbool; + FN_MEDIUM_READSECTORS = function(sector, numSectors: cuint32; buffer: pointer): cbool; + FN_MEDIUM_WRITESECTORS = function(sector, numSectors: cuint32; const buffer: pointer): cbool; + FN_MEDIUM_CLEARSTATUS = function: cbool; + FN_MEDIUM_SHUTDOWN = function: cbool; + + IO_INTERFACE_STRUCT = record + ioType: cuint32; + features: cuint32; + fn_startup: FN_MEDIUM_STARTUP; + fn_isInserted: FN_MEDIUM_ISINSERTED; + fn_readSectors: FN_MEDIUM_READSECTORS; + fn_writeSectors: FN_MEDIUM_WRITESECTORS; + fn_clearStatus: FN_MEDIUM_CLEARSTATUS; + fn_shutdown: FN_MEDIUM_SHUTDOWN; + end; + + IO_INTERFACE = IO_INTERFACE_STRUCT; + TIO_INTERFACE_STRUCT = IO_INTERFACE_STRUCT; + PIO_INTERFACE_STRUCT = ^IO_INTERFACE_STRUCT; + + PARTITION_INTERFACE = ( + PI_DEFAULT = 0, + PI_SLOT_1, + PI_SLOT_2, + PI_CUSTOM + ); + + +function fatInit(cacheSize: cuint32; setAsDefaultDevice: cbool): cbool; cdecl; external; +function fatInitDefault(): cbool; cdecl; external; +function fatMountNormalInterface(partitionNumber: PARTITION_INTERFACE; cacheSize: cuint32): cbool; cdecl; external; +function fatMountCustomInterface(const device: PIO_INTERFACE_STRUCT; cacheSize: cuint32): cbool; cdecl; external; +function fatUnmount(partitionNumber: PARTITION_INTERFACE): cbool; cdecl; external; +function fatUnsafeUnmount(partitionNumber: PARTITION_INTERFACE): cbool; cdecl; external; +function fatSetDefaultInterface(partitionNumber: PARTITION_INTERFACE): cbool; cdecl; external; + +{$endif NDS_INTERFACE} + diff --git a/packages/libndsfpc/src/fat/fat.pp b/packages/libndsfpc/src/fat/fat.pp new file mode 100644 index 0000000000..502209f339 --- /dev/null +++ b/packages/libndsfpc/src/fat/fat.pp @@ -0,0 +1,32 @@ +unit fat; +{$mode objfpc} +{$apptype arm9} +{$define arm9} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds9; + +{$linklib nds9} +{$linklib libfat.a} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include fat.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include fat.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/fat/gbfs.inc b/packages/libndsfpc/src/fat/gbfs.inc new file mode 100644 index 0000000000..027809703f --- /dev/null +++ b/packages/libndsfpc/src/fat/gbfs.inc @@ -0,0 +1,75 @@ +(* + $Id: gbfs.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + Copyright + 2002-2004 Damian Yerrick + Additional code Dave Murphy + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +{$ifdef NDS_INTERFACE} +(* to make a 300 KB space called samples do GBFS_SPACE(samples, 300) *) + +{$define GBFS_SPACE(filename, kbytes) := filename: array [(kbytes)*1024 - 1] of char = 'PinEightGBFSSpace-' + filename + '-' + kbytes} + +type + GBFS_FILE = packed record + magic: array [0..15] of char; // "PinEightGBFS\r\n\032\n" + total_len: cuint32; // total length of archive + dir_off: cuint16; // offset in bytes to directory + dir_nmemb: cuint16; // number of files + reserved: array [0..7] of char; // for future use + end; + PGBFS_FILE = ^GBFS_FILE; + + GBFS_ENTRY = packed record + name: array [0..23] of char; // filename, nul-padded + len: cuint32; // length of object in bytes + data_offset: cuint32; // in bytes from beginning of file + end; + PGBFS_ENTRY = ^GBFS_ENTRY; + +procedure gbfs_search_range(gbfs_1st_limit: cuint32; gbfs_2nd_start: cuint32; + gbfs_2nd_limit: cuint32; gbfs_stride: cuint32); cdecl; external; + +function find_first_gbfs_file(const start: pointer): PGBFS_FILE; cdecl; external; +function skip_gbfs_file(const _file: PGBFS_FILE): pointer; cdecl; external; +function gbfs_get_obj(const _file: PGBFS_FILE; const name: pchar; len: pcuint32): pointer; cdecl; external; +function gbfs_get_nth_obj(const _file: PGBFS_FILE; n: cint {was size_t}; name: pchar; len: pcuint32): pointer; cdecl; external; +function gbfs_copy_obj(dst: pointer; const _file: PGBFS_FILE; const name: pchar): pointer; cdecl; external; +function gbfs_count_objs(const _file: PGBFS_FILE): cint {was size_t}; cdecl; external; + +{$endif NDS_INTERFACE} + diff --git a/packages/libndsfpc/src/fat/gbfs.pp b/packages/libndsfpc/src/fat/gbfs.pp new file mode 100644 index 0000000000..2ceb8949da --- /dev/null +++ b/packages/libndsfpc/src/fat/gbfs.pp @@ -0,0 +1,32 @@ +unit gbfs; +{$mode objfpc} +{$apptype arm9} +{$define arm9} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds9; + +{$linklib nds9} +{$linklib fat} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include gbfs.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include gbfs.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/libmikmod/inc/mikmod.inc b/packages/libndsfpc/src/libmikmod/inc/mikmod.inc new file mode 100644 index 0000000000..0c9204761b --- /dev/null +++ b/packages/libndsfpc/src/libmikmod/inc/mikmod.inc @@ -0,0 +1,1076 @@ +(* MikMod sound library + (c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS + for complete list. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*) + + +{$ifdef NDS_INTERFACE} +(**** CONST *******************************************************************) +const + LIBMIKMOD_VERSION_MAJOR = 3; + LIBMIKMOD_VERSION_MINOR = 1; + LIBMIKMOD_REVISION = 10; + + LIBMIKMOD_VERSION = ( + (LIBMIKMOD_VERSION_MAJOR shl 16) or + (LIBMIKMOD_VERSION_MINOR shl 8) or + (LIBMIKMOD_REVISION) + ); + + SFX_CRITICAL = 1; + + SF_16BITS = $0001; + SF_STEREO = $0002; + SF_SIGNED = $0004; + SF_BIG_ENDIAN = $0008; + SF_DELTA = $0010; + SF_ITPACKED = $0020; + + SF_FORMATMASK = $003F; + + SF_LOOP = $0100; + SF_BIDI = $0200; + SF_REVERSE = $0400; + SF_SUSTAIN = $0800; + + SF_PLAYBACKMASK = $0C00; + + SF_OWNPAN = $1000; + SF_UST_LOOP = $2000; + + SF_EXTRAPLAYBACKMASK = $3000; + + PAN_LEFT = 0; + PAN_HALFLEFT = 64; + PAN_CENTER = 128; + PAN_HALFRIGHT = 192; + PAN_RIGHT = 255; + PAN_SURROUND = 512; + + INSTNOTES = 120; + + ENVPOINTS = 32; + + UF_MAXCHAN = 64; + + UF_XMPERIODS = $0001; + UF_LINEAR = $0002; + UF_INST = $0004; + UF_NNA = $0008; + UF_S3MSLIDES = $0010; + UF_BGSLIDES = $0020; + UF_HIGHBPM = $0040; + UF_NOWRAP = $0080; + UF_ARPMEM = $0100; + UF_FT2QUIRKS = $0200; + UF_PANNING = $0400; + + MUTE_EXCLUSIVE = 32000; + MUTE_INCLUSIVE = 32001; + + DMODE_16BITS = $0001; + DMODE_STEREO = $0002; + DMODE_SOFT_SNDFX = $0004; + DMODE_SOFT_MUSIC = $0008; + DMODE_HQMIXER = $0010; + DMODE_SURROUND = $0100; + DMODE_INTERP = $0200; + DMODE_REVERSE = $0400; + + OCTAVE = 12; + + UF_MAXMACRO = $10; + UF_MAXFILTER = $100; + + FILT_CUT = $80; + FILT_RESONANT = $81; + + IF_OWNPAN = 1; + IF_PITCHPAN = 2; + + EF_ON = 1; + EF_SUSTAIN = 2; + EF_LOOP = 4; + EF_VOLENV = 8; + + NNA_CUT = 0; + NNA_CONTINUE = 1; + NNA_OFF = 2; + NNA_FADE = 3; + + NNA_MASK = 3; + + DCT_OFF = 0; + DCT_NOTE = 1; + DCT_SAMPLE = 2; + DCT_INST = 3; + + DCA_CUT = 0; + DCA_OFF = 1; + DCA_FADE = 2; + + KEY_KICK = 0; + KEY_OFF = 1; + KEY_FADE = 2; + KEY_KILL = (KEY_OFF or KEY_FADE); + + KICK_ABSENT = 0; + KICK_NOTE = 1; + KICK_KEYOFF = 2; + KICK_ENV = 4; + + AV_IT = 1; + + POS_NONE = (-2); + + LAST_PATTERN = word(-1); + + S3MIT_OLDSTYLE = 1; + S3MIT_IT = 2; + S3MIT_SCREAM = 4; + + MAXSAMPLEHANDLES = 384; + + +(****** Types *****************************************************************) +type + SBYTE = cschar; + PSBYTE = ^cschar; + UBYTE = cuchar; + PUBYTE = ^cuchar; + SWORD = csshort; + PSWORD = ^csshort; + UWORD = cushort; + PUWORD = ^cushort; + SLONG = csint; + PSLONG = ^csint; + ULONG = cuint; + PULONG = ^cuint; + BOOL = cint; + + MikMod_Errors = ( + MMERR_OPENING_FILE = 1, + MMERR_OUT_OF_MEMORY, + MMERR_DYNAMIC_LINKING, + + MMERR_SAMPLE_TOO_BIG, + MMERR_OUT_OF_HANDLES, + MMERR_UNKNOWN_WAVE_TYPE, + + MMERR_LOADING_PATTERN, + MMERR_LOADING_TRACK, + MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, + MMERR_NOT_A_MODULE, + MMERR_NOT_A_STREAM, + MMERR_MED_SYNTHSAMPLES, + MMERR_ITPACK_INVALID_DATA, + + MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, + MMERR_INITIALIZING_MIXER, + MMERR_OPENING_AUDIO, + MMERR_8BIT_ONLY, + MMERR_16BIT_ONLY, + MMERR_STEREO_ONLY, + MMERR_ULAW, + MMERR_NON_BLOCK, + + MMERR_AF_AUDIO_PORT, + + MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, + MMERR_AIX_CONFIG_START, + + MMERR_GUS_SETTINGS, + MMERR_GUS_RESET, + MMERR_GUS_TIMER, + + MMERR_HP_SETSAMPLESIZE, + MMERR_HP_SETSPEED, + MMERR_HP_CHANNELS, + MMERR_HP_AUDIO_OUTPUT, + MMERR_HP_AUDIO_DESC, + MMERR_HP_BUFFERSIZE, + + MMERR_OSS_SETFRAGMENT, + MMERR_OSS_SETSAMPLESIZE, + MMERR_OSS_SETSTEREO, + MMERR_OSS_SETSPEED, + + MMERR_SGI_SPEED, + MMERR_SGI_16BIT, + MMERR_SGI_8BIT, + MMERR_SGI_STEREO, + MMERR_SGI_MONO, + + MMERR_SUN_INIT, + + MMERR_OS2_MIXSETUP, + MMERR_OS2_SEMAPHORE, + MMERR_OS2_TIMER, + MMERR_OS2_THREAD, + + MMERR_DS_PRIORITY, + MMERR_DS_BUFFER, + MMERR_DS_FORMAT, + MMERR_DS_NOTIFY, + MMERR_DS_EVENT, + MMERR_DS_THREAD, + MMERR_DS_UPDATE, + + MMERR_WINMM_HANDLE, + MMERR_WINMM_ALLOCATED, + MMERR_WINMM_DEVICEID, + MMERR_WINMM_FORMAT, + MMERR_WINMM_UNKNOWN, + + MMERR_MAC_SPEED, + MMERR_MAC_START, + + MMERR_MAX + ); + + SAMPLE = packed record + panning: csshort; + speed: culong; + volume: cuchar; + inflags: cushort; + flags: cushort; + length: cuint; + loopstart: cuint; + loopend: cuint; + susbegin: cuint; + susend: cuint; + globvol: cuchar; + vibflags: cuchar; + vibtype: cuchar; + vibsweep: cuchar; + vibdepth: cuchar; + vibrate: cuchar; + samplename: pcchar; + avibpos: cushort; + divfactor: cuchar; + seekpos: cuint; + handle: csshort; + end; + TSample = SAMPLE; + PSample = ^SAMPLE; + + ENVPT = packed record + pos: csshort; + val: csshort; + end; + TENVPT = ENVPT; + PENVPT = ^ENVPT; + + INSTRUMENT = packed record + insname: pcchar; + flags: cuchar; + samplenumber: array [0..INSTNOTES - 1] of cushort; + samplenote: array [0..INSTNOTES - 1] of cuchar; + nnatype: cuchar; + dca: cuchar; + dct: cuchar; + globvol: cuchar; + volfade: cushort; + panning: csshort; + pitpansep: cuchar; + pitpancenter: cuchar; + rvolvar: cuchar; + rpanvar: cuchar; + volflg: cuchar; + volpts: cuchar; + volsusbeg: cuchar; + volsusend: cuchar; + volbeg: cuchar; + volend: cuchar; + volenv: array [0..ENVPOINTS - 1] of ENVPT; + panflg: cuchar; + panpts: cuchar; + pansusbeg: cuchar; + pansusend: cuchar; + panbeg: cuchar; + panend: cuchar; + panenv: array [0..ENVPOINTS - 1] of ENVPT; + pitflg: cuchar; + pitpts: cuchar; + pitsusbeg: cuchar; + pitsusend: cuchar; + pitbeg: cuchar; + pitend: cuchar; + pitenv: array [0..ENVPOINTS - 1] of ENVPT; + end; + TInstrument = INSTRUMENT; + PInstrument = ^INSTRUMENT; + + MP_CHANNEL = packed record + i: PInstrument; + s: PSample; + sample: cuchar; + note: cuchar; + outvolume: csshort; + chanvol: cschar; + fadevol: cushort; + panning: csshort; + kick: cuchar; + period: cushort; + nna: cuchar; + volflg: cuchar; + panflg: cuchar; + pitflg: cuchar; + keyoff: cuchar; + handle: csshort; + notedelay: cuchar; + start: csint; + end; + TMPChannel = MP_CHANNEL; + PMPChannel = ^MP_CHANNEL; + + ENVPR = packed record + flg: cuchar; + pts: cuchar; + susbeg: cuchar; + susend: cuchar; + beg: cuchar; + _end: cuchar; + p: csshort; + a: cushort; + b: cushort; + env: PENVPT; + end; + TENVPR = ENVPR; + PENVPR = ^ENVPR; + + + PMP_VOICE = ^MP_VOICE; + + MP_CONTROL = packed record + main: MP_CHANNEL; + slave: PMP_VOICE; + slavechn: cuchar; + muted: cuchar; + ultoffset: cushort; + anote: cuchar; + oldnote: cuchar; + ownper: csshort; + ownvol: csshort; + dca: cuchar; + dct: cuchar; + row: pcuchar; + retrig: cschar; + speed: cuint; + volume: csshort; + tmpvolume: csshort; + tmpperiod: cushort; + wantedperiod: cushort; + arpmem: cuchar; + pansspd: cuchar; + slidespeed: cushort; + portspeed: cushort; + s3mtremor: cuchar; + s3mtronof: cuchar; + s3mvolslide: cuchar; + sliding: cschar; + s3mrtgspeed: cuchar; + s3mrtgslide: cuchar; + glissando: cuchar; + wavecontrol: cuchar; + vibpos: cschar; + vibspd: cuchar; + vibdepth: cuchar; + trmpos: cschar; + trmspd: cuchar; + trmdepth: cuchar; + fslideupspd: cuchar; + fslidednspd: cuchar; + fportupspd: cuchar; + fportdnspd: cuchar; + ffportupspd: cuchar; + ffportdnspd: cuchar; + hioffset: cuint; + soffset: cushort; + sseffect: cuchar; + ssdata: cuchar; + chanvolslide: cuchar; + panbwave: cuchar; + panbpos: cuchar; + panbspd: cschar; + panbdepth: cuchar; + newsamp: cushort; + voleffect: cuchar; + voldata: cuchar; + pat_reppos: csshort; + pat_repcnt: cushort; + end; + TMPControl = MP_CONTROL; + PMPControl = ^MP_CONTROL; + + MP_VOICE = packed record + main: MP_CHANNEL; + venv: ENVPR; + penv: ENVPR; + cenv: ENVPR; + avibpos: cushort; + aswppos: cushort; + totalvol: cuint; + mflag: cint; + masterchn: csshort; + masterperiod: cushort; + master: PMPControl; + end; + TMPVoice = MP_VOICE; + PMPVoice = ^MP_VOICE; + + ppcuchar = ^pcuchar; + + MODULE = packed record + songname: pcchar; + modtype: pcchar; + comment: pcchar; + flags: cushort; + numchn: cuchar; + numvoices: cuchar; + numpos: cushort; + numpat: cushort; + numins: cushort; + numsmp: cushort; + instruments: PInstrument; + samples: PSample; + realchn: cuchar; + totalchn: cuchar; + reppos: cushort; + initspeed: cuchar; + inittempo: cushort; + initvolume: cuchar; + panning: array [0..UF_MAXCHAN - 1] of cushort; + chanvol: array [0..UF_MAXCHAN - 1] of cuchar; + bpm: cushort; + sngspd: cushort; + volume: csshort; + extspd: cint; + panflag: cint; + wrap: cint; + loop: cint; + fadeout: cint; + patpos: cushort; + sngpos: csshort; + sngtime: cuint; + relspd: csshort; + numtrk: cushort; + tracks: ppcuchar; + patterns: pcushort; + pattrows: pcushort; + positions: pcushort; + forbid: cint; + numrow: cushort; + vbtick: cushort; + sngremainder: cushort; + control: PMPControl; + voice: PMPVoice; + globalslide: cuchar; + pat_repcrazy: cuchar; + patbrk: cushort; + patdly: cuchar; + patdly2: cuchar; + posjmp: csshort; + bpmlimit: cushort; + end; + TModule = MODULE; + PModule = ^MODULE; + + drvenum1 = ( + MD_MUSIC = 0, + MD_SNDFX + ); + + drvenum2 = ( + MD_HARDWARE = 0, + MD_SOFTWARE + ); + + PMReader = ^MREADER; + TSeek1 = function(value1: PMReader; value2: clong; value3: cint): pcint; + PSeek1 = ^TSeek1; + TTell1 = function(value: PMReader): pclong; + PTell1 = ^TTell1; + TRead = function(value1: PMReader; value2: pointer; value3: cint): pcint; + PRead = ^TRead; + TGet = function(value: PMReader): pcint; + PGet = ^TGet; + TEof = function(value: PMReader): pcint; + PEof = ^TEof; + + MREADER = packed record + Seek: TSeek1; + Tell: TTell1; + Read: TRead; + Get: TGet; + Eof: TEof; + end; + + PMWriter = ^MWRITER; + TSeek2 = function(value1: PMWriter; value2: clong; value3: cint): pcint; + PSeek2 = ^TSeek2; + TTell2 = function(value: PMWriter): pclong; + PTell2 = ^TTell2; + TWrite = function(value1: PMWriter; value2: pointer; value3: cint): pcint; + PWrite = ^TWrite; + TPut = function(value1: PMWriter; value2: cint): pcint; + PPut = ^TPut; + + MWRITER = packed record + Seek: TSeek2; + Tell: TTell2; + Write: TWrite; + Put: TPut; + end; + TMWriter = MWRITER; + + PSampLoad = ^SAMPLOAD; + PPSampLoad = ^PSampLoad; + SAMPLOAD = packed record + next: PSampLoad; + length: cuint; + loopstart: cuint; + loopend: cuint; + infmt, outfmt: cushort; + scalefactor: cint; + sample: PSample; + reader: PMReader; + end; + TSampLoad = SAMPLOAD; + + TMDCommandLine = procedure(value: pcchar); + PMDCommandLine = ^TMDCommandLine; + TMDIsPresent = function(): cint; + PMDIsPresent = ^TMDIsPresent; + TMDSampleLoad = function (value1: PSAMPLOAD; value2: cint): csshort; + PMDSampleLoad = ^TMDSampleLoad; + TMDSampleUnload = procedure(value: csshort); + PMDSampleUnload = ^TMDSampleUnload; + TMDFreeSampleSpace = function(value: cint): cuint; + PMDFreeSampleSpace = ^TMDFreeSampleSpace; + TMDRealSampleLength = function(value1: cint; value2: PSAMPLE): cuint; + PMDRealSampleLength = ^TMDRealSampleLength; + TMDInit = function(): cint; + PMDInit = ^TMDInit; + TMDExit = procedure(); + PMDExit = ^TMDExit; + TMDReset = function(): cint; + PMDReset = ^TMDReset; + TMDSetNumVoices = function(): cint; + PMDSetNumVoices = ^TMDSetNumVoices; + TMDPlayStart = function(): cint; + PMDPlayStart = ^TMDPlayStart; + TMDPlayStop = procedure(); + PMDPlayStop = ^TMDPlayStop; + TMDUpdate = procedure(); + PMDUpdate = ^TMDUpdate; + TMDPause = procedure(); + PMDPause = ^TMDPause; + TMDVoiceSetVolume = procedure(value1: cuchar; value2: cushort); + PMDVoiceSetVolume = ^TMDVoiceSetVolume; + TMDVoiceGetVolume = function(value: cuchar): cushort; + PMDVoiceGetVolume = ^TMDVoiceGetVolume; + TMDVoiceSetFrequency = procedure(value1: cuchar; value2: cuint); + PMDVoiceSetFrequency = ^TMDVoiceSetFrequency; + TMDVoiceGetFrequency = function(value: cuchar): cuint; + PMDVoiceGetFrequency = ^TMDVoiceGetFrequency; + TMDVoiceSetPanning = procedure(value1: cuchar; value2: cuint); + PMDVoiceSetPanning = ^TMDVoiceSetPanning; + TMDVoiceGetPanning = function(value: cuchar): cuint; + PMDVoiceGetPanning = ^TMDVoiceGetPanning; + TMDVoicePlay = procedure(value1: cuchar; value2: csshort; value3, value4, value5, value6: cuint; value7: cushort); + PMDVoicePlay = ^TMDVoicePlay; + TMDVoiceStop = procedure(value: cuchar); + PMDVoiceStop = ^TMDVoiceStop; + TMDVoiceStopped = function(value: cuchar): cint; + PMDVoiceStopped = ^TMDVoiceStopped; + TMDVoiceGetPosition = function(value: cuchar): csint; + PMDVoiceGetPosition = ^TMDVoiceGetPosition; + TMDVoiceRealVolume = function(value: cuchar): cuint; + PMDVoiceRealVolume = ^TMDVoiceRealVolume; + + PMDriver = ^MDRIVER; + MDRIVER = packed record + next: PMdriver; + Name: pcchar; + Version: pcchar; + HardVoiceLimit: cuchar; + SoftVoiceLimit: cuchar; + Alias: pcchar; + CommandLine: TMDCommandLine; + IsPresent: TMDIsPresent; + SampleLoad: TMDSampleLoad; + SampleUnload: TMDSampleUnload; + FreeSampleSpace: TMDFreeSampleSpace; + RealSampleLength: TMDRealSampleLength; + Init: TMDInit; + Exit: TMDExit; + Reset: TMDReset; + SetNumVoices: TMDSetNumVoices; + PlayStart: TMDPlayStart; + PlayStop: TMDPlayStop; + Update: TMDUpdate; + Pause: TMDPause; + VoiceSetVolume: TMDVoiceSetVolume; + VoiceGetVolume: TMDVoiceGetVolume; + VoiceSetFrequency: TMDVoiceSetFrequency; + VoiceGetFrequency: TMDVoiceGetFrequency; + VoiceSetPanning: TMDVoiceSetPanning; + VoiceGetPanning: TMDVoiceGetPanning; + VoicePlay: TMDVoicePlay; + VoiceStop: TMDVoiceStop; + VoiceStopped: TMDVoiceStopped; + VoiceGetPosition: TMDVoiceGetPosition; + VoiceRealVolume: TMDVoiceRealVolume; + end; + TMDriver = MDRIVER; + + MikMod_player = procedure(); + TMikModPlayer = MikMod_player; + MikMod_player_t = ^MikMod_player; + PMikModPlayer = ^MikMod_player; + + uni_fx = ( + UNI_NOTE = 1, + UNI_INSTRUMENT, + UNI_PTEFFECT0, // arpeggio + UNI_PTEFFECT1, // porta up + UNI_PTEFFECT2, // porta down + UNI_PTEFFECT3, // porta to note + UNI_PTEFFECT4, // vibrato + UNI_PTEFFECT5, // dual effect 3+A + UNI_PTEFFECT6, // dual effect 4+A + UNI_PTEFFECT7, // tremolo + UNI_PTEFFECT8, // pan + UNI_PTEFFECT9, // sample offset + UNI_PTEFFECTA, // volume slide + UNI_PTEFFECTB, // pattern jump + UNI_PTEFFECTC, // set volume + UNI_PTEFFECTD, // pattern break + UNI_PTEFFECTE, // extended effects + UNI_PTEFFECTF, // set speed + UNI_S3MEFFECTA, // set speed + UNI_S3MEFFECTD, // volume slide + UNI_S3MEFFECTE, // porta down + UNI_S3MEFFECTF, // porta up + UNI_S3MEFFECTI, // tremor + UNI_S3MEFFECTQ, // retrig + UNI_S3MEFFECTR, // tremolo + UNI_S3MEFFECTT, // set tempo + UNI_S3MEFFECTU, // fine vibrato + UNI_KEYOFF, // note off + UNI_KEYFADE, // note fade + UNI_VOLEFFECTS, // volume column effects + UNI_XMEFFECT4, // vibrato + UNI_XMEFFECT6, // dual effect 4+A + UNI_XMEFFECTA, // volume slide + UNI_XMEFFECTE1, // fine porta up + UNI_XMEFFECTE2, // fine porta down + UNI_XMEFFECTEA, // fine volume slide up + UNI_XMEFFECTEB, // fine volume slide down + UNI_XMEFFECTG, // set global volume + UNI_XMEFFECTH, // global volume slide + UNI_XMEFFECTL, // set envelope position + UNI_XMEFFECTP, // pan slide + UNI_XMEFFECTX1, // extra fine porta up + UNI_XMEFFECTX2, // extra fine porta down + UNI_ITEFFECTG, // porta to note + UNI_ITEFFECTH, // vibrato + UNI_ITEFFECTI, // tremor (xy not incremented) + UNI_ITEFFECTM, // set channel volume + UNI_ITEFFECTN, // slide / fineslide channel volume + UNI_ITEFFECTP, // slide / fineslide channel panning + UNI_ITEFFECTT, // slide tempo + UNI_ITEFFECTU, // fine vibrato + UNI_ITEFFECTW, // slide / fineslide global volume + UNI_ITEFFECTY, // panbrello + UNI_ITEFFECTZ, // resonant filters + UNI_ITEFFECTS0, + UNI_ULTEFFECT9, // Sample fine offset + UNI_MEDSPEED, + UNI_MEDEFFECTF1, // play note twice + UNI_MEDEFFECTF2, // delay note + UNI_MEDEFFECTF3, // play note three times + UNI_OKTARP, // arpeggio + UNI_LAST + ); + + extsound_fx = ( + SS_GLISSANDO = 1, + SS_FINETUNE, + SS_VIBWAVE, + SS_TREMWAVE, + SS_PANWAVE, + SS_FRAMEDELAY, + SS_S7EFFECTS, + SS_PANNING, + SS_SURROUND, + SS_HIOFFSET, + SS_PATLOOP, + SS_NOTECUT, + SS_NOTEDELAY, + SS_PATDELAY + ); + + itcol_fx = ( + VOL_VOLUME = 1, + VOL_PANNING, + VOL_VOLSLIDE, + VOL_PITCHSLIDEDN, + VOL_PITCHSLIDEUP, + VOL_PORTAMENTO, + VOL_VIBRATO + ); + + FILTER = packed record + filter, inf: cuchar; + end; + TFilter = FILTER; + PFilter = ^FILTER; + + TMLInit = function(): cint; + PMLInit = ^TMLInit; + TMLTest = function(): cint; + PMLTest = ^TMLTest; + TMLLoad = function(value: cint): cint; + PMLLoad = ^TMLLoad; + TMLCleanup = procedure(); + PMLCleanup = ^TMLCleanup; + TMLLoadTitle = function(): pcchar; + PMLLoadTitle = ^TMLLoadTitle; + + PMLoader = ^MLOADER; + MLOADER = packed record + next: PMLoader; + _type: pcchar; + version: pcchar; + Init: TMLInit; + Test: TMLTest; + Load: TMLLoad; + Cleanup: TMLCleanup; + LoadTitle: TMLLoadTitle; + end; + TMLoader = MLOADER; + + MikMod_handler = procedure; + MikMod_handler_t = ^MikMod_handler; + TMikModHandler = MikMod_handler; + PMikModHandler = ^TMikModHandler; + + +var + _mm_errno : MikMod_Errors; + _mm_critical : cint; + _mm_errorhandler : MikMod_handler_t; cvar; external; + + unioperands: array [0.. integer(UNI_LAST) - 1] of cushort; cvar; external; + + MikMod_errno: cint; cvar; external; + MikMod_critical: cint; cvar; external; + + load_669: MLOADER; cvar; external; (* 669 and Extended-669 (by Tran/Renaissance) *) + load_amf: MLOADER; cvar; external; (* DMP Advanced Module Format (by Otto Chrons) *) + load_dsm: MLOADER; cvar; external; (* DSIK internal module format *) + load_far: MLOADER; cvar; external; (* Farandole Composer (by Daniel Potter) *) + load_gdm: MLOADER; cvar; external; (* General DigiMusic (by Edward Schlunder) *) + load_it: MLOADER; cvar; external; (* Impulse Tracker (by Jeffrey Lim) *) + load_imf: MLOADER; cvar; external; (* Imago Orpheus (by Lutz Roeder) *) + load_med: MLOADER; cvar; external; (* Amiga MED modules (by Teijo Kinnunen) *) + load_m15: MLOADER; cvar; external; (* Soundtracker 15-instrument *) + load_mod: MLOADER; cvar; external; (* Standard 31-instrument Module loader *) + load_mtm: MLOADER; cvar; external; (* Multi-Tracker Module (by Renaissance) *) + load_okt: MLOADER; cvar; external; (* Amiga Oktalyzer *) + load_stm: MLOADER; cvar; external; (* ScreamTracker 2 (by Future Crew) *) + load_stx: MLOADER; cvar; external; (* STMIK 0.2 (by Future Crew) *) + load_s3m: MLOADER; cvar; external; (* ScreamTracker 3 (by Future Crew) *) + load_ult: MLOADER; cvar; external; (* UltraTracker (by MAS) *) + load_uni: MLOADER; cvar; external; (* MikMod and APlayer internal module format *) + load_xm: MLOADER; cvar; external; (* FastTracker 2 (by Triton) *) + + md_volume: cuchar; cvar; external; (* global sound volume (0-128) *) + md_musicvolume: cuchar; cvar; external; (* volume of song *) + md_sndfxvolume: cuchar; cvar; external; (* volume of sound effects *) + md_reverb: cuchar; cvar; external; (* 0 = none; 15 = chaos *) + md_pansep: cuchar; cvar; external; (* 0 = mono; 128 == 100% (full left/right) *) + + md_device: cushort; cvar; external; (* device *) + md_mixfreq: cushort; cvar; external; (* mixing frequency *) + md_mode: cushort; cvar; external; (* mode. See DMODE_? flags above *) + + md_driver: PMDRIVER; cvar; external; (* Current driver in use. *) + + drv_nos: MDRIVER; cvar; external; (* no sound *) + drv_nds_sw: MDRIVER; cvar; external; (* Nintendo DS Software driver *) + drv_nds_hw: MDRIVER; cvar; external; (* Nintendo DS Hardware driver *) + + +{$ifdef ARM9} +var + md_bpm: cushort; cvar; +procedure MikMod9_SendCommand(command: cuint); cdecl; {forward;}external; +function Player_LoadMemory(const buffer: pointer; size: cint; maxchan: cint; curious: cint): PModule; cdecl; external; +{$endif ARM9} + +{$ifdef ARM7} +procedure MikMod7_ProcessCommand(command: cuint); cdecl; external; +{$endif ARM7} + + +function MikMod_GetVersion(): clong; cdecl; external; + +function _mm_malloc(value: cint): pointer; cdecl; external; +function _mm_calloc(value1, value2: cint): pointer; cdecl; external; + +procedure _mm_free(var p: pointer); inline; + +function Player_Init(value: PModule): cint; cdecl; external; +procedure Player_Exit(value: PModule); cdecl; external; +procedure Player_HandleTick(); cdecl; external; + +function _mm_new_file_reader(fp: P_FILE): PMReader; cdecl; external; +procedure _mm_delete_file_reader(value: PMReader); cdecl; external; + +function _mm_new_file_writer(fp: P_FILE): PMWriter; cdecl; external; +procedure _mm_delete_file_writer(value: PMWriter); cdecl; external; + +function _mm_FileExists(fname: pcchar): cint; cdecl; external; + + + + +procedure _mm_iobase_setcur(value: PMReader); cdecl; external; +procedure _mm_iobase_revert(); cdecl; external; +function _mm_fopen(value1, value2: pcchar): P_FILE; cdecl; external; +function _mm_fclose(value: P_FILE): cint; cdecl; external; +procedure _mm_write_string(value1: pcchar; value2: PMWriter); cdecl; external; +function _mm_read_string (value1: pcchar; value2: cint; value3: PMReader): cint; cdecl; external; + +function _mm_read_M_SWORD(value: PMReader): csshort; cdecl; external; +function _mm_read_I_SWORD(value: PMReader): csshort; cdecl; external; +function _mm_read_M_UWORD(value: PMReader): cushort; cdecl; external; +function _mm_read_I_UWORD(value: PMReader): cushort; cdecl; external; + +function _mm_read_M_SLONG(value: PMReader): csint; cdecl; external; +function _mm_read_I_SLONG(value: PMReader): csint; cdecl; external; +function _mm_read_M_ULONG(value: PMReader): cuint; cdecl; external; +function _mm_read_I_ULONG(value: PMReader): cuint; cdecl; external; + +function _mm_read_M_SWORDS(value1: pcsshort; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_I_SWORDS(value1: pcsshort; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_M_UWORDS(value1: pcushort; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_I_UWORDS(value1: pcushort; value2: cint; value3: PMReader): cint; cdecl; external; + +function _mm_read_M_SLONGS(value1: pcsint; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_I_SLONGS(value1: pcsint; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_M_ULONGS(value1: pcuint; value2: cint; value3: PMReader): cint; cdecl; external; +function _mm_read_I_ULONGS(value1: pcuint; value2: cint; value3: PMReader): cint; cdecl; external; + +procedure _mm_write_M_SWORD(value1: csshort; value2: PMWriter); cdecl; external; +procedure _mm_write_I_SWORD(value1: csshort; value2: PMWriter); cdecl; external; +procedure _mm_write_M_UWORD(value1: cushort; value2: PMWriter); cdecl; external; +procedure _mm_write_I_UWORD(value1: cushort; value2: PMWriter); cdecl; external; + +procedure _mm_write_M_SLONG(value1: csint; value2: PMWriter); cdecl; external; +procedure _mm_write_I_SLONG(value1: csint; value2: PMWriter); cdecl; external; +procedure _mm_write_M_ULONG(value1: cuint; value2: PMWriter); cdecl; external; +procedure _mm_write_I_ULONG(value1: cuint; value2: PMWriter); cdecl; external; + +procedure _mm_write_M_SWORDS(value1: pcsshort; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_I_SWORDS(value1: pcsshort; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_M_UWORDS(value1: pcushort; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_I_UWORDS(value1: pcushort; value2: cint; value3: PMWriter); cdecl; external; + +procedure _mm_write_M_SLONGS(value1: pcsint; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_I_SLONGS(value1: pcsint; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_M_ULONGS(value1: pcuint; value2: cint; value3: PMWriter); cdecl; external; +procedure _mm_write_I_ULONGS(value1: pcuint; value2: cint; value3: PMWriter); cdecl; external; + + +function MikMod_strerror(value: cint): pcchar; cdecl; external; +function MikMod_RegisterErrorHandler(value: MikMod_handler_t): MikMod_handler_t; cdecl; external; + +procedure MikMod_RegisterAllDrivers(); cdecl; external; + +function MikMod_InfoDriver(): pcchar; cdecl; external; +procedure MikMod_RegisterDriver(value: PMDriver); cdecl; external; +function MikMod_DriverFromAlias(value: pcint): cint; cdecl; external; + +function MikMod_Init(value: string): cint; cdecl; external; +procedure MikMod_Exit(); cdecl; external; +function MikMod_Reset(value: pcint): cint; cdecl; external; +function MikMod_SetNumVoices(value1, value2: cint): cint; cdecl; external; +function MikMod_Active(): cint; cdecl; external; +function MikMod_EnableOutput(): cint; cdecl; external; +procedure MikMod_DisableOutput(); cdecl; external; +procedure MikMod_Update(); cdecl; external; + +function MikMod_InitThreads(): cint; cdecl; external; +procedure MikMod_Lock(); cdecl; external; +procedure MikMod_Unlock(); cdecl; external; + +function Sample_Load(value: pcchar): PSAMPLE; cdecl; external; +function Sample_LoadFP(value: P_FILE): PSAMPLE; cdecl; external; +function Sample_LoadGeneric(value: PMREADER): PSAMPLE; cdecl; external; +procedure Sample_Free(value: PSAMPLE); cdecl; external; +function Sample_Play(value1: PSAMPLE; value2: cuint; value3: cuchar): cschar; cdecl; external; + +procedure Voice_SetVolume(value1: cschar; value2: cushort); cdecl; external; +function Voice_GetVolume(value: cschar): cushort; cdecl; external; +procedure Voice_SetFrequency(value1: cschar; value2: cuint); cdecl; external; +function Voice_GetFrequency(value: cschar): cuint; cdecl; external; +procedure Voice_SetPanning(value1: cschar; value2: cuint); cdecl; external; +function Voice_GetPanning(value: cschar): cuint; cdecl; external; +procedure Voice_Play(value1: cschar; value2: PSAMPLE; value3: cuint); cdecl; external; +procedure Voice_Stop(value: cschar); cdecl; external; +function Voice_Stopped(value: cschar): cint; cdecl; external; +function Voice_GetPosition(value: cschar): csint; cdecl; external; +function Voice_RealVolume(value: cschar): cuint; cdecl; external; + +function MikMod_InfoLoader(): pcchar; cdecl; external; +procedure MikMod_RegisterAllLoaders(); cdecl; external; +procedure MikMod_RegisterLoader(value: PMLOADER); cdecl; external; + +function Player_Load(value1: pcchar; value2: cint; value3: cint): PMODULE; cdecl; external; +function Player_LoadFP(value1: P_FILE; value2: cint; value3: cint): PMODULE; cdecl; external; +function Player_LoadGeneric(value1: PMREADER; value2: cint; value3: cint): PMODULE; cdecl; external; +function Player_LoadTitle(value: pcchar): pcchar; cdecl; external; +function Player_LoadTitleFP(value: P_FILE): pcchar; cdecl; external; +procedure Player_Free(value: PMODULE); cdecl; external; +procedure Player_Start(value: PMODULE); cdecl; external; +function Player_Active(): cint; cdecl; external; +procedure Player_Stop(); cdecl; external; +procedure Player_TogglePause(); cdecl; external; +function Player_Paused(): cint; cdecl; external; +procedure Player_NextPosition(); cdecl; external; +procedure Player_PrevPosition(); cdecl; external; +procedure Player_SetPosition(value: cushort); cdecl; external; +function Player_Muted(value: cuchar): cint; cdecl; external; +procedure Player_SetVolume(value: csshort); cdecl; external; +function Player_GetModule(): PMODULE; cdecl; external; +procedure Player_SetSpeed(value: cushort); cdecl; external; +procedure Player_SetTempo(value: cushort); cdecl; external; +procedure Player_Unmute(value: csint; args: array of const); cdecl; external; +procedure Player_Mute(value: csint; args: array of const); cdecl; external; +procedure Player_ToggleMute(value: csint; args: array of const); cdecl; external; +function Player_GetChannelVoice(value: cuchar): cint; cdecl; external; +function Player_GetChannelPeriod(value: cuchar): cushort; cdecl; external; + +function MikMod_RegisterPlayer(value: MikMod_player_t): MikMod_player_t; cdecl; external; + +function VC_Init(): cint; cdecl; external; +procedure VC_Exit(); cdecl; external; +function VC_SetNumVoices(): cint; cdecl; external; +function VC_SampleSpace(value: cint): cuint; cdecl; external; +function VC_SampleLength(value1: cint; value2: PSAMPLE): cuint; cdecl; external; + +function VC_PlayStart(): cint; cdecl; external; +procedure VC_PlayStop(); cdecl; external; + +function VC_SampleLoad(value1: PSAMPLOAD; value2: cint): csshort; cdecl; external; +procedure VC_SampleUnload(value: csshort); cdecl; external; + +function VC_WriteBytes(value1: pcschar; value2: cuint): cuint; cdecl; external; +function VC_SilenceBytes(value1: pcschar; value2: cuint): cuint; cdecl; external; + +procedure VC_VoiceSetVolume(value1: cuchar; value2: cushort); cdecl; external; +function VC_VoiceGetVolume(value: cuchar): cushort; cdecl; external; +procedure VC_VoiceSetFrequency(value1: cuchar; value2: cuint); cdecl; external; +function VC_VoiceGetFrequency(value: cuchar): cuint; cdecl; external; +procedure VC_VoiceSetPanning(value1: cuchar; value2: cuint); cdecl; external; +function VC_VoiceGetPanning(value: cuchar): cuint; cdecl; external; +procedure VC_VoicePlay(value1: cuchar; value2: csshort; value3, value4, value5, value6: cuint; value7: cushort); cdecl; external; + +procedure VC_VoiceStop(value: cuchar); cdecl; external; +function VC_VoiceStopped(value: cuchar): cint; cdecl; external; +function VC_VoiceGetPosition(value: cuchar): csint; cdecl; external; +function VC_VoiceRealVolume(value: cuchar): cuint; cdecl; external; + + +(****** NDS part **************************************************************) +const + NDS_HW_MAXSAMPLES = 128; + NDS_HW_MAXVOICES = 16; + + NDS_HW_CHANGE_START = (1 shl 0); + NDS_HW_CHANGE_STOP = (1 shl 1); + NDS_HW_CHANGE_VOLUME = (1 shl 2); + NDS_HW_CHANGE_FREQUENCY = (1 shl 3); + NDS_HW_CHANGE_PANNING = (1 shl 4); + +type + NDS_SW_IPC = packed record + buffer: pcschar; + prevTimer: cint; + writeCursor: cint; + readCursor: cint; + bufferSize: cint; + sampleRate: cint; + format: cint; + playing: cint; + end; + + NDS_HW_VOICE = packed record + handle: csshort; + start: cuint; + length: cuint; + loopstart: cuint; + loopend: cuint; + flags: cushort; + volume: cushort; + frequency: cuint; + panning: cuint; + playing: cint; + changes: cuchar; + end; + + NDS_HW_IPC = packed record + samples: array [0..NDS_HW_MAXSAMPLES - 1] of pointer; + voices: array [0..NDS_HW_MAXVOICES - 1] of NDS_HW_VOICE; + end; + + NDS_COMMAND = ( + NDS_SW_CMD_INIT = 1, + NDS_SW_CMD_START, + NDS_SW_CMD_UPDATE, + NDS_SW_CMD_STOP, + NDS_SW_CMD_EXIT, + NDS_HW_CMD_INIT, + NDS_HW_CMD_EXIT, + NDS_HW_CMD_PLAY_START, + NDS_HW_CMD_PLAY_STOP, + NDS_HW_CMD_RESET, + NDS_HW_CMD_VOICE_UPDATE + ); + +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +{$ifdef ARM9} +//procedure MikMod9_SendCommand(command: cuint); cdecl; forward; +{$endif ARM9} + +procedure _mm_free(var p: pointer); inline; +begin + if p <> nil then + FreeMem(p); + p := nil; +end; +{$endif NDS_IMPLEMENTATION} diff --git a/packages/libndsfpc/src/libmikmod/mikmod7.pp b/packages/libndsfpc/src/libmikmod/mikmod7.pp new file mode 100644 index 0000000000..c228dbf3a9 --- /dev/null +++ b/packages/libndsfpc/src/libmikmod/mikmod7.pp @@ -0,0 +1,32 @@ +unit mikmod7; +{$mode objfpc} +{$apptype arm7} +{$define arm7} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds7; + +{$linklib nds7} +{$linklib mikmod7} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include inc/mikmod.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include inc/mikmod.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/libmikmod/mikmod9.pp b/packages/libndsfpc/src/libmikmod/mikmod9.pp new file mode 100644 index 0000000000..e4ac249101 --- /dev/null +++ b/packages/libndsfpc/src/libmikmod/mikmod9.pp @@ -0,0 +1,32 @@ +unit mikmod9; +{$mode objfpc} +{$apptype arm9} +{$define arm9} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes, nds9; + +{$linklib nds9} +{$linklib mikmod9} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include inc/mikmod.inc} +{$undef NDS_INTERFACE} + +implementation +{$define NDS_IMPLEMENTATION} +{$include inc/mikmod.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/nds/arm7/audio.inc b/packages/libndsfpc/src/nds/arm7/audio.inc new file mode 100644 index 0000000000..e06f7954a6 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm7/audio.inc @@ -0,0 +1,200 @@ +(* + $Id: audio.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM7} +{$error Audio is only available on the ARM7} +{$endif ARM7} + +{$ifdef NDS_IMPLEMENTATION} +function SOUND_VOL(n: cint): cint; inline; +begin + SOUND_VOL := (n); +end; + +function SOUND_FREQ(n: cint): cint; inline; +begin + SOUND_FREQ := ((-$1000000 div (n))); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + SOUND_ENABLE = (1 shl 15); + SOUND_REPEAT = (1 shl 27); + SOUND_ONE_SHOT = (1 shl 28); + SOUND_FORMAT_16BIT = (1 shl 29); + SOUND_FORMAT_8BIT = (0 shl 29); + SOUND_FORMAT_PSG = (3 shl 29); + SOUND_FORMAT_ADPCM = (2 shl 29); + SOUND_16BIT = (1 shl 29); + SOUND_8BIT = (0); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function SOUND_PAN(n: cint): cint; inline; +begin + SOUND_PAN := ((n) shl 16); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + SCHANNEL_ENABLE = (1 shl 31); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +//--------------------------------------------------------------------------------- +// registers +//--------------------------------------------------------------------------------- +function SCHANNEL_CR(n: cint): pcuint32; inline; +begin + SCHANNEL_CR := pcuint32($04000400 + ((n) shl 4)); +end; + +function SCHANNEL_VOL(n: cint): pcuint8; inline; +begin + SCHANNEL_VOL := pcuint8($04000400 + ((n) shl 4)); +end; + +function SCHANNEL_PAN(n: cint): pcuint8; inline; +begin + SCHANNEL_PAN := pcuint8($04000402 + ((n) shl 4)); +end; + +function SCHANNEL_SOURCE(n: cint): pcuint32; inline; +begin + SCHANNEL_SOURCE := pcuint32($04000404 + ((n) shl 4)); +end; + +function SCHANNEL_TIMER(n: cint): pcuint16; inline; +begin + SCHANNEL_TIMER := pcuint16($04000408 + ((n) shl 4)); +end; + +function SCHANNEL_REPEAT_POINT(n: cint): pcuint16; inline; +begin + SCHANNEL_REPEAT_POINT := pcuint16($0400040A + ((n) shl 4)); +end; + +function SCHANNEL_LENGTH(n: cint): pcuint32; inline; +begin + SCHANNEL_LENGTH := pcuint32($0400040C + ((n) shl 4)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + SOUND_CR : pcuint16 = pointer($04000500); + SOUND_MASTER_VOL : pcuint8 = pointer($04000500); + +//--------------------------------------------------------------------------------- +// not sure on the following +//--------------------------------------------------------------------------------- + SOUND_BIAS : pcuint16 = pointer($04000504); + SOUND508 : pcuint16 = pointer($04000508); + SOUND510 : pcuint16 = pointer($04000510); + SOUND514 : pcuint16 = pointer($04000514); + SOUND518 : pcuint16 = pointer($04000518); + SOUND51C : pcuint16 = pointer($0400051C); + + +(*--------------------------------------------------------------------------------- + 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 +---------------------------------------------------------------------------------*) +function MIC_ReadData(): cuint8; cdecl; external; + +(*--------------------------------------------------------------------------------- + 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. +---------------------------------------------------------------------------------*) +procedure StartRecording(buffer: pcuint8; length: cint); cdecl; external; + +(*--------------------------------------------------------------------------------- + Stop recording data, and return the length of data recorded. +---------------------------------------------------------------------------------*) +function StopRecording(): cint; cdecl; external; + +(* This must be called during IRQ_TIMER0 *) +procedure ProcessMicrophoneTimerIRQ(); cdecl; external; + +procedure PM_SetAmp(control: cuint8); cdecl; external; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +//--------------------------------------------------------------------------------- +// Turn the microphone on +//--------------------------------------------------------------------------------- +procedure MIC_On(); inline; +begin + PM_SetAmp(PM_AMP_ON); +end; + +//--------------------------------------------------------------------------------- +// Turn the microphone off +//--------------------------------------------------------------------------------- +procedure MIC_Off(); inline; +begin + PM_SetAmp(PM_AMP_OFF); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +function SOUND_VOL(n: cint): cint; inline; +function SOUND_FREQ(n: cint): cint; inline; +function SOUND_PAN(n: cint): cint; inline; +function SCHANNEL_CR(n: cint): pcuint32; inline; +function SCHANNEL_VOL(n: cint): pcuint8; inline; +function SCHANNEL_PAN(n: cint): pcuint8; inline; +function SCHANNEL_SOURCE(n: cint): pcuint32; inline; +function SCHANNEL_TIMER(n: cint): pcuint16; inline; +function SCHANNEL_REPEAT_POINT(n: cint): pcuint16; inline; +function SCHANNEL_LENGTH(n: cint): pcuint32; inline; +procedure MIC_On(); inline; +procedure MIC_Off(); inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm7/clock.inc b/packages/libndsfpc/src/nds/arm7/clock.inc new file mode 100644 index 0000000000..d95d4be2d1 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm7/clock.inc @@ -0,0 +1,107 @@ +(* + $Id: clock.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM7} +{$error The clock is only available on the ARM7} +{$endif ARM7} + +{$ifdef NDS_INTERFACE} +const +// RTC registers + WRITE_STATUS_REG1 = $60; + READ_STATUS_REG1 = $61; + STATUS_POC = (1 shl 7); // read-only, cleared by reading (1 if just powered on) + STATUS_BLD = (1 shl 6); // read-only, cleared by reading (1 if power dropped below the safety threshold) + STATUS_INT2 = (1 shl 5); // read-only, INT2 has occured + STATUS_INT1 = (1 shl 4); // read-only, INT1 has occured + STATUS_SC1 = (1 shl 3); // R/W scratch bit + STATUS_SC0 = (1 shl 2); // R/W scratch bit + STATUS_24HRS = (1 shl 1); // 24 hour mode when 1, 12 hour mode when 0 + STATUS_RESET = (1 shl 0); // write-only, reset when 1 written + + WRITE_STATUS_REG2 = $62; + READ_STATUS_REG2 = $63; + STATUS_TEST = (1 shl 7); // + STATUS_INT2AE = (1 shl 6); // + STATUS_SC3 = (1 shl 5); // R/W scratch bit + STATUS_SC2 = (1 shl 4); // R/W scratch bit + + STATUS_32kE = (1 shl 3); // Interrupt mode bits + STATUS_INT1AE = (1 shl 2); // + STATUS_INT1ME = (1 shl 1); // + STATUS_INT1FE = (1 shl 0); // + + // full 7 bytes for time and date + WRITE_TIME_AND_DATE = $64; + READ_TIME_AND_DATE = $65; + + // last 3 bytes of current time + WRITE_TIME = $66; + READ_TIME = $67; + + + WRITE_INT_REG1 = $68; + READ_INT_REG1 = $69; + + READ_INT_REG2 = $6A; + WRITE_INT_REG2 = $6B; + + READ_CLOCK_ADJUST_REG = $6C; + WRITE_CLOCK_ADJUST_REG = $6D; +// clock-adjustment register + + READ_FREE_REG = $6E; + WRITE_FREE_REG = $6F; + + +procedure rtcReset(); cdecl; external; +procedure rtcTransaction(command: pcuint8; commandLength: cuint32; result: pcuint8; resultLength: cuint32); cdecl; external; +procedure rtcGetTime(time: pcuint8); cdecl; external; +procedure rtcSetTime(time: pcuint8); cdecl; external; +procedure rtcGetData(data: pcuint8; size: cuint32); cdecl; external; + +procedure rtcGetTimeAndDate(time: pcuint8); cdecl; external; +procedure rtcSetTimeAndDate(time: pcuint8); cdecl; external; + +procedure BCDToInteger(data: pcuint8; length: cuint32); cdecl; external; +procedure integerToBCD(data: pcuint8; length: uint32); cdecl; external; + +procedure initClockIRQ(); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm7/serial.inc b/packages/libndsfpc/src/nds/arm7/serial.inc new file mode 100644 index 0000000000..8a30b9c7f5 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm7/serial.inc @@ -0,0 +1,185 @@ +(* + $Id: serial.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM7} +{$error Serial header is for ARM7 only} +{$endif ARM7} + +{$ifdef NDS_INTERFACE} +const +// 'Networking' + REG_RCNT : pcuint16 = pointer($04000134); + REG_KEYXY : pcuint16 = pointer($04000136); + RTC_CR : pcuint16 = pointer($04000138); + RTC_CR8 : pcuint8 = pointer($04000138); + + REG_SIOCNT : pcuint16 = pointer($04000128); + + SIO_DATA8 : pcuint8 = pointer($0400012A); + SIO_DATA32 : pcuint32 = pointer($04000120); + + +// Fixme: Does the hardware still support 16 bit comms mode? +// BIOS makes use of 32 bit mode, so some regs still exist + SIO_MULTI_0 : pcuint16 = pointer($04000120); + SIO_MULTI_1 : pcuint16 = pointer($04000122); + SIO_MULTI_2 : pcuint16 = pointer($04000124); + SIO_MULTI_3 : pcuint16 = pointer($04000126); + SIO_MULTI_SEND : pcuint16 = pointer($0400012A); + + +// SPI chain registers + REG_SPICNT : pcuint16 = pointer($040001C0); + REG_SPIDATA : pcuint16 = pointer($040001C2); + + SPI_ENABLE = (1 shl 15); + SPI_IRQ = (1 shl 14); + SPI_BUSY = (1 shl 7); + +// Pick the SPI clock speed + SPI_BAUD_4MHZ = 0; + SPI_BAUD_2MHZ = 1; + SPI_BAUD_1MHZ = 2; + SPI_BAUD_512KHZ = 3; + +// Pick the SPI transfer length + SPI_BYTE_MODE = (0 shl 10); + SPI_HWORD_MODE = (1 shl 10); + +// Pick the SPI device + SPI_DEVICE_POWER = (0 shl 8); + SPI_DEVICE_FIRMWARE = (1 shl 8); + SPI_DEVICE_NVRAM = (1 shl 8); + SPI_DEVICE_TOUCH = (2 shl 8); + SPI_DEVICE_MICROPHONE = (2 shl 8); + +// When used, the /CS line will stay low after the transfer ends +// i.e. when we're part of a continuous transfer + SPI_CONTINUOUS = (1 shl 11); + +// Fixme: does this stuff really belong in serial.h? + +// Power management registers + PM_CONTROL_REG = 0; + PM_BATTERY_REG = 1; + PM_AMPLIFIER_REG = 2; + PM_READ_REGISTER = (1 shl 7); + +// PM control register bits - power control + PM_SOUND_AMP = (1 shl 0); // Power the sound hardware (needed to hear stuff in GBA mode too) + PM_SOUND_MUTE = (1 shl 1); // Mute the main speakers, headphone output will still work. + PM_BACKLIGHT_BOTTOM = (1 shl 2); // Enable the top backlight if set + PM_BACKLIGHT_TOP = (1 shl 3); // Enable the bottom backlight if set + PM_SYSTEM_PWR = (1 shl 6); // Turn the power *off* if set + PM_POWER_DOWN = (1 shl 6); // Same thing, I like this name better tho +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +// PM control register bits - LED control +function PM_LED_CONTROL(m: cint): cint; inline; +begin + PM_LED_CONTROL := m shl 4; // ? +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + PM_LED_ON = (0 shl 4); // Steady on + PM_LED_SLEEP = (1 shl 4); // Blinking, mostly off + PM_LED_BLINK = (3 shl 4); // Blinking, mostly on + + + PM_AMP_OFFSET = 2; + PM_AMP_ON = 1; + PM_AMP_OFF = 0; + +// Fixme: does this stuff really belong in serial.h? + +// Firmware commands + FIRMWARE_WREN = $06; + FIRMWARE_WRDI = $04; + FIRMWARE_RDID = $9F; + FIRMWARE_RDSR = $05; + FIRMWARE_READ = $03; + FIRMWARE_PW = $0A; + FIRMWARE_PP = $02; + FIRMWARE_FAST = $0B; + FIRMWARE_PE = $DB; + FIRMWARE_SE = $D8; + FIRMWARE_DP = $B9; + FIRMWARE_RDP = $AB; +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +procedure SerialWaitBusy(); inline; +begin + while (REG_SPICNT^ and SPI_BUSY) <> 0 do + swiDelay(1); +end; +{$endif NDS_IMPLEMENTATION} + +// 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 + +{$ifdef NDS_INTERFACE} +function writePowerManagement(reg: cint; command: cint): cint; cdecl; external; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function readPowerManagement(reg: cint): cint; inline; +begin + readPowerManagement := writePowerManagement(reg or PM_READ_REGISTER, 0); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +// Read the firmware +procedure readFirmware(address: cuint32; destination: pointer; size: cuint32); cdecl; external; +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function PM_LED_CONTROL(m: cint): cint; inline; +procedure SerialWaitBusy(); inline; +function readPowerManagement(reg: cint): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm7/touch.inc b/packages/libndsfpc/src/nds/arm7/touch.inc new file mode 100644 index 0000000000..5230a74152 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm7/touch.inc @@ -0,0 +1,66 @@ +(* + $Id: touch.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM7} +{$error Touch screen is only available on the ARM7} +{$endif ARM7} + +{$ifdef NDS_INTERFACE} +const + SCREEN_WIDTH = 256; + SCREEN_HEIGHT = 192; + + + TSC_MEASURE_TEMP1 = $84; + TSC_MEASURE_Y = $90; + TSC_MEASURE_BATTERY = $A4; + TSC_MEASURE_Z1 = $B4; + TSC_MEASURE_Z2 = $C4; + TSC_MEASURE_X = $D0; + TSC_MEASURE_AUX = $E4; + TSC_MEASURE_TEMP2 = $F4; + + + +function touchReadXY(): touchPosition; cdecl; external; + +function touchRead(command: cuint32): cuint16; cdecl; external; +function touchReadTemperature(t1: pcint; t2: pcint): cuint32; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/background.inc b/packages/libndsfpc/src/nds/arm9/background.inc new file mode 100644 index 0000000000..f4453dc7f9 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/background.inc @@ -0,0 +1,96 @@ +(* + $Id: background.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +// Background control defines + +{$ifdef NDS_INTERFACE} +// BGxCNT defines /// +const + BG_MOSAIC_ENABLE = $40; + BG_COLOR_256 = $80; + BG_COLOR_16 = $00; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function CHAR_BASE_BLOCK(n: cint): cint; inline; +begin + CHAR_BASE_BLOCK := (n * $4000)+ $06000000; +end; + +function CHAR_BASE_BLOCK_SUB(n: cint): cint; inline; +begin + CHAR_BASE_BLOCK_SUB := (n * $4000)+ $06200000; +end; + +function SCREEN_BASE_BLOCK(n: cint): cint; inline; +begin + SCREEN_BASE_BLOCK := (n * $800) + $06000000; +end; + +function SCREEN_BASE_BLOCK_SUB(n: cint): cint; inline; +begin + SCREEN_BASE_BLOCK_SUB := (n * $800) + $06200000; +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + CHAR_SHIFT = 2; + SCREEN_SHIFT = 8; + TEXTBG_SIZE_256x256 = $0; + TEXTBG_SIZE_256x512 = $8000; + TEXTBG_SIZE_512x256 = $4000; + TEXTBG_SIZE_512x512 = $C000; + + ROTBG_SIZE_128x128 = $0; + ROTBG_SIZE_256x256 = $4000; + ROTBG_SIZE_512x512 = $8000; + ROTBG_SIZE_1024x1024 = $C000; + + WRAPAROUND = $1; +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function CHAR_BASE_BLOCK(n: cint): cint; inline; +function CHAR_BASE_BLOCK_SUB(n: cint): cint; inline; +function SCREEN_BASE_BLOCK(n: cint): cint; inline; +function SCREEN_BASE_BLOCK_SUB(n: cint): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/boxtest.inc b/packages/libndsfpc/src/nds/arm9/boxtest.inc new file mode 100644 index 0000000000..976e927778 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/boxtest.inc @@ -0,0 +1,52 @@ +(* + $Id: boxtest.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +{$ifdef NDS_INTERFACE} +function BoxTest(x, y, z, width, height, depth: {v16}cuint16): cint; cdecl; external; + +function BoxTestf(x, y, z, width, height, depth: cfloat): cint; cdecl; external; + +procedure BoxTest_Asynch(x, y, z, width, height, depth: {v16}cuint16); cdecl; external; + +procedure BoxTestf_Asynch(x, y, z, width, height, depth: cfloat); cdecl; external; + +function BoxTestResult(): cint; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/cache.inc b/packages/libndsfpc/src/nds/arm9/cache.inc new file mode 100644 index 0000000000..f5ec28b5e4 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/cache.inc @@ -0,0 +1,53 @@ +(* + $Id: cache.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +procedure IC_InvalidateAll(); cdecl; external; + +procedure IC_InvalidateRange(const base: pointer; size: cuint32); cdecl; external; + +procedure DC_FlushAll(); cdecl; external; + +procedure DC_FlushRange(const base: pointer; size: cuint32); cdecl; external; + +procedure DC_InvalidateAll(); cdecl; external; + +procedure DC_InvalidateRange(const base: pointer; size: cuint32); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/console.inc b/packages/libndsfpc/src/nds/arm9/console.inc new file mode 100644 index 0000000000..0c3421b823 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/console.inc @@ -0,0 +1,51 @@ +(* + $Id: console.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +const + CONSOLE_USE_COLOR255 = 16; +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +procedure consoleInit(font: pcuint16; charBase: pcuint16; numCharacters: cuint16; charStart: cuint8; map: pcuint16; pal: cuint8; bitDepth: cuint8); cdecl; external; +procedure consoleInitDefault(map: pcuint16; charBase: pcuint16; bitDepth: cuint8); cdecl; external; +procedure consoleDemoInit(); cdecl; external; +procedure consoleClear(); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/exceptions.inc b/packages/libndsfpc/src/nds/arm9/exceptions.inc new file mode 100644 index 0000000000..5dc10c5329 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/exceptions.inc @@ -0,0 +1,55 @@ +(* + $Id: exceptions.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +const + EXCEPTION_VECTOR : ^VoidFunctionPointer = pointer($27FFD9C); + +var + exceptionC: ^VoidFunctionPointer; cvar; external; + exceptionStack: cuint32; cvar; external; + exceptionRegisters: pcint32; cvar; external; + +procedure enterException(); cdecl; external; +procedure setExceptionHandler(handler: VoidFunctionPointer); cdecl; external; +procedure defaultExceptionHandler(); cdecl; external; + +function getCPSR(): cuint32; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/image.inc b/packages/libndsfpc/src/nds/arm9/image.inc new file mode 100644 index 0000000000..5eba23e25a --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/image.inc @@ -0,0 +1,72 @@ +(* + $Id: image.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +type +//holds a rgb triplet + RGB_24 = packed record + r: cuchar; + g: cuchar; + b: cuchar; + end; + + //holds a basic image type for loading image files + sImage = record + height: cshort; + width: cshort; + bpp: cint; + palette: pcushort; + image: record + case integer of + 0: (data8: pcuchar); + 1: (data16: pcushort); + 2: (data32: pcuint); + end; + end; + TsImage = sImage; + PsImage = ^sImage; + + +procedure image24to16(img: PsImage); cdecl; external; +procedure image8to16(img: PsImage); cdecl; external; +procedure image8to16trans(img: PsImage; transperentColor: cuint8); cdecl; external; +procedure imageDestroy(img: PsImage); cdecl; external; +procedure imageTileData(img: PsImage); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/input.inc b/packages/libndsfpc/src/nds/arm9/input.inc new file mode 100644 index 0000000000..821706258d --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/input.inc @@ -0,0 +1,75 @@ +(* + $Id: input.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +// Keyboard +type + KEYPAD_BITS = cint; +const +//! Bit values for the keypad buttons. + KEY_A : KEYPAD_BITS = (1 shl 0); // Keypad A button. + KEY_B : KEYPAD_BITS = (1 shl 1); // Keypad B button. + KEY_SELECT : KEYPAD_BITS = (1 shl 2); // Keypad SELECT button. + KEY_START : KEYPAD_BITS = (1 shl 3); // Keypad START button. + KEY_RIGHT : KEYPAD_BITS = (1 shl 4); // Keypad RIGHT button. + KEY_LEFT : KEYPAD_BITS = (1 shl 5); // Keypad LEFT button. + KEY_UP : KEYPAD_BITS = (1 shl 6); // Keypad UP button. + KEY_DOWN : KEYPAD_BITS = (1 shl 7); // Keypad DOWN button. + KEY_R : KEYPAD_BITS = (1 shl 8); // Right shoulder button. + KEY_L : KEYPAD_BITS = (1 shl 9); // Left shoulder button. + KEY_X : KEYPAD_BITS = (1 shl 10); // Keypad X button. + KEY_Y : KEYPAD_BITS = (1 shl 11); // Keypad Y button. + KEY_TOUCH : KEYPAD_BITS = (1 shl 12); // Touchscreen pendown. + KEY_LID : KEYPAD_BITS = (1 shl 13); // Lid state. + +procedure scanKeys(); cdecl; external; + +function keysHeld(): cuint32; cdecl; external; + +function keysDown(): cuint32; cdecl; external; + +function keysDownRepeat(): cuint32; cdecl; external; + +procedure keysSetRepeat(setDelay: cuint8; setRepeat: cuint8); cdecl; external; + +function keysUp(): cuint32; cdecl; external; + +function touchReadXY(): touchPosition; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/math.inc b/packages/libndsfpc/src/nds/arm9/math.inc new file mode 100644 index 0000000000..0cf3bfc88f --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/math.inc @@ -0,0 +1,245 @@ +(* + $Id: math.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +// Math coprocessor register definitions +const + DIV_CR : pcuint16 = pointer($04000280); + DIV_NUMERATOR64 : pcint64 = pointer($04000290); + DIV_NUMERATOR32 : pcint32 = pointer($04000290); + DIV_DENOMINATOR64 : pcint64 = pointer($04000298); + DIV_DENOMINATOR32 : pcint32 = pointer($04000298); + DIV_RESULT64 : pcint64 = pointer($040002A0); + DIV_RESULT32 : pcint32 = pointer($040002A0); + DIV_REMAINDER64 : pcint64 = pointer($040002A8); + DIV_REMAINDER32 : pcint32 = pointer($040002A8); + + SQRT_CR : pcuint16 = pointer($040002B0); + SQRT_PARAM64 : pcint64 = pointer($040002B8); + SQRT_RESULT32 : pcint32 = pointer($040002B4); + SQRT_PARAM32 : pcint32 = pointer($040002B8); + +// Math coprocessor modes + + DIV_64_64 = 2; + DIV_64_32 = 1; + DIV_32_32 = 0; + DIV_BUSY = (1 shl 15); + + SQRT_64 = 1; + SQRT_32 = 0; + SQRT_BUSY = (1 shl 15); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function divf32(num: cint32; den: cint32): cint32; inline; +begin + DIV_CR^ := DIV_64_32; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + DIV_NUMERATOR64^ := cint64(num) shl 12; + DIV_DENOMINATOR32^ := den; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + divf32 := DIV_RESULT32^; +end; + +function mulf32(a, b: cint32): cint32; inline; +var + rslt: clonglong; +begin + rslt := clonglong(a) * clonglong(b); + mulf32 := cint32(rslt shr 12); +end; + +// Fixed point square root +// Takes 1.19.12 fixed point value and +// returns the fixed point result +function sqrtf32(a: cint32): cint32; inline; +begin + SQRT_CR^ := SQRT_64; + + while (SQRT_CR^ and SQRT_BUSY) <> 0 do; + + SQRT_PARAM64^ := cint64(a) shl 12; + + while (SQRT_CR^ and SQRT_BUSY) <> 0 do; + + sqrtf32 := SQRT_RESULT32^; +end; + +// Integer versions + +// Integer divide +// Takes a 32 bit numerator and 32 bit +// denominator and returns 32 bit result +function div32(num, den: cint32): cint32; inline; +begin + DIV_CR^ := DIV_32_32; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + DIV_NUMERATOR32^ := num; + DIV_DENOMINATOR32^ := den; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + div32 := DIV_RESULT32^; +end; + +// Integer divide +// Takes a 32 bit numerator and 32 bit +// denominator and returns 32 bit result +function mod32(num, den: cint32): cint32; inline; +begin + DIV_CR^ := DIV_32_32; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + DIV_NUMERATOR32^ := num; + DIV_DENOMINATOR32^ := den; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + mod32 := DIV_REMAINDER32^; +end; + +// Integer divide +// Takes a 64 bit numerator and 32 bit +// denominator are returns 32 bit result +function div64(num: cint64; den: cint32): cint32; inline; +begin + DIV_CR^ := DIV_64_32; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + DIV_NUMERATOR64^ := num; + DIV_DENOMINATOR32^ := den; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + div64 := DIV_RESULT32^; +end; + +// Integer divide +// Takes a 64 bit numerator and 32 bit +// denominator are returns 32 bit result +function mod64(num: cint64; den: cint32): cint32; inline; +begin + DIV_CR^ := DIV_64_32; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + DIV_NUMERATOR64^ := num; + DIV_DENOMINATOR32^ := den; + + while (DIV_CR^ and DIV_BUSY) <> 0 do; + + mod64 := DIV_REMAINDER32^; +end; + +// Integer square root +// takes a 32 bit integer and returns +// 32 bit result +function sqrt32(a: cint32): cint32; inline; +begin + SQRT_CR^ := SQRT_32; + + while(SQRT_CR^ and SQRT_BUSY) <> 0 do; + + SQRT_PARAM32^ := a; + + while(SQRT_CR^ and SQRT_BUSY) <> 0 do; + + sqrt32 := SQRT_RESULT32^; +end; + +// Trig Functions 1.19.12 fixed point + +// Cross product +// x = Ay * Bz - By * Az +// y = Az * Bx - Bz * Ax +// z = Ax * By - Bx * Ay +procedure crossf32(a: pcint32; b: pcint32; res: pcint32); inline; +begin + res[0] := mulf32(a[1], b[2]) - mulf32(b[1], a[2]); + res[1] := mulf32(a[2], b[0]) - mulf32(b[2], a[0]); + res[2] := mulf32(a[0], b[1]) - mulf32(b[0], a[1]); +end; + +// Dot Product +// result = Ax * Bx + Ay * By + Az * Bz +function dotf32(a, b: pcint32): cint32; inline; +begin + dotf32 := mulf32(a[0], b[0]) + mulf32(a[1], b[1]) + mulf32(a[2], b[2]); +end; + +// Normalize +// Ax = Ax / mag +// Ay = Ay / mag +// Az = Az / mag +procedure normalizef32(a: pcint32); inline; +var + magnitude: cint32; +begin + // magnitude = sqrt ( Ax^2 + Ay^2 + Az^2 ) + magnitude := sqrtf32( mulf32(a[0], a[0]) + mulf32(a[1], a[1]) + mulf32(a[2], a[2]) ); + + a[0] := divf32(a[0], magnitude); + a[1] := divf32(a[1], magnitude); + a[2] := divf32(a[2], magnitude); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +function divf32(num: cint32; den: cint32): cint32; inline; +function mulf32(a, b: cint32): cint32; inline; +function sqrtf32(a: cint32): cint32; inline; +function div32(num, den: cint32): cint32; inline; +function mod32(num, den: cint32): cint32; inline; +function div64(num: cint64; den: cint32): cint32; inline; +function mod64(num: cint64; den: cint32): cint32; inline; +function sqrt32(a: cint32): cint32; inline; +procedure crossf32(a: pcint32; b: pcint32; res: pcint32); inline; +function dotf32(a, b: pcint32): cint32; inline; +procedure normalizef32(a: pcint32); inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/ndsmotion.inc b/packages/libndsfpc/src/nds/arm9/ndsmotion.inc new file mode 100644 index 0000000000..65008566dd --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/ndsmotion.inc @@ -0,0 +1,72 @@ +(* + $Id: ndsmotion.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + Copyright (C) 2007 + 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. + ------------------------------------------------------------------------------ + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2007 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +type + MotionCalibration = record + xoff, yoff, zoff, goff: cshort; + xsens, ysens, zsens, gsens: cshort; + end; + TMotionCalibration = MotionCalibration; + PMotionCalibration = ^MotionCalibration; + +function motion_init(): cint; cdecl; external; +procedure motion_deinit(); cdecl; external; +function motion_read_x(): csint; cdecl; external; +function motion_read_y(): csint; cdecl; external; +function motion_read_z(): csint; cdecl; external; +function motion_read_gyro(): csint; cdecl; external; +function motion_acceleration_x(): cint; cdecl; external; +function motion_acceleration_y(): cint; cdecl; external; +function motion_acceleration_z(): cint; cdecl; external; +procedure motion_set_sens_x(sens: cint); cdecl; external; +procedure motion_set_sens_y(sens: cint); cdecl; external; +procedure motion_set_sens_z(sens: cint); cdecl; external; +procedure motion_set_sens_gyro(sens: cint); cdecl; external; +procedure motion_set_offs_x(); cdecl; external; +procedure motion_set_offs_y(); cdecl; external; +procedure motion_set_offs_z(); cdecl; external; +procedure motion_set_offs_gyro(); cdecl; external; +function motion_rotation(): cint; cdecl; external; +function motion_get_calibration(): PMotionCalibration; cdecl; external; +procedure motion_set_calibration(cal: PMotionCalibration); cdecl; external; +procedure motion_enable_ain_1(); cdecl; external; +procedure motion_enable_ain_2(); cdecl; external; +function motion_read_ain_1(): cint; cdecl; external; +function motion_read_ain_2(): cint; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/pcx.inc b/packages/libndsfpc/src/nds/arm9/pcx.inc new file mode 100644 index 0000000000..6bbf176ee2 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/pcx.inc @@ -0,0 +1,65 @@ +(* + $Id: pcx.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +type + // short int = cint16??? + PCXHeader = packed record + manufacturer: cchar; //should be 0 + version: cchar; //should be 5 + encoding: cchar; //should be 1 + bitsPerPixel: cchar; //should be 8 + xmin,ymin: cint16; //coordinates for top left,bottom right + xmax,ymax: cint16; + hres: cint16; //resolution + vres: cint16; + palette16: array [0..47] of cchar; //16 color palette if 16 color image + reserved: cchar; //ignore + colorPlanes: cchar; //ignore + bytesPerLine: cint16; + paletteYype: cint16; //should be 2 + filler: array [0..57] of cchar; //ignore + end; + TPCXHeader = PCXHeader; + PPCXHeader = ^PCXHeader; + + +function loadPCX(pcx: pcuchar; image: PsImage): cint; cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/postest.inc b/packages/libndsfpc/src/nds/arm9/postest.inc new file mode 100644 index 0000000000..8b1d134894 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/postest.inc @@ -0,0 +1,86 @@ +(* + $Id: postest.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + Copyright (C) 2007 + 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. + ------------------------------------------------------------------------------ + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2007 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_IMPLEMENTATION} +function PosTestBusy(): cbool; inline; +begin + PosTestBusy := (GFX_STATUS^ and (1 shl 0)) <> 0; +end; + +procedure PosTest_Asynch(x, y, z: v16); inline; +begin + GFX_POS_TEST^ := VERTEX_PACK(x, y); + GFX_POS_TEST^ := z; +end; + +procedure PosTest(x, y, z: v16); inline; +begin + PosTest_Asynch(x, y, z); + while PosTestBusy() do; +end; + +function PosTestWresult(): cint32; inline; +begin + PosTestWresult := GFX_POS_RESULT[3]; +end; + +function PosTestXresult(): cint32; inline; +begin + PosTestXresult := GFX_POS_RESULT[0]; +end; + +function PosTestYresult(): cint32; inline; +begin + PosTestYresult := GFX_POS_RESULT[1]; +end; + +function PosTestZresult(): cint32; inline; +begin + PosTestZresult := GFX_POS_RESULT[2]; +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +function PosTestBusy(): cbool; inline; +procedure PosTest_Asynch(x, y, z: v16); inline; +procedure PosTest(x, y, z: v16); inline; +function PosTestWresult(): cint32; inline; +function PosTestXresult(): cint32; inline; +function PosTestYresult(): cint32; inline; +function PosTestZresult(): cint32; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/rumble.inc b/packages/libndsfpc/src/nds/arm9/rumble.inc new file mode 100644 index 0000000000..5fe9f6fefa --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/rumble.inc @@ -0,0 +1,56 @@ +(* + $Id: rumble.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +const + RUMBLE_PAK: pcuint16 = pointer($08000000); + WARIOWARE_PAK: pcuint16 = pointer($080000C4); + WARIOWARE_ENABLE: pcuint16 = pointer($080000C6); + +type + RUMBLE_TYPE = ( + RUMBLE, WARIOWARE + ); + TRumbleType = RUMBLE_TYPE; + + +function isRumbleInserted(): cbool; cdecl; external; +procedure setRumble(position: cbool); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/sound.inc b/packages/libndsfpc/src/nds/arm9/sound.inc new file mode 100644 index 0000000000..c3979aef47 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/sound.inc @@ -0,0 +1,45 @@ +(* + $Id: sound.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +procedure playSound(sound: pTransferSoundData); cdecl; external; +procedure setGenericSound(rate: cuint32; vol: cuint8; pan: cuint8; format: cuint8); cdecl; external; +procedure playGenericSound(const data: pointer; length: cuint32); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/sprite.inc b/packages/libndsfpc/src/nds/arm9/sprite.inc new file mode 100644 index 0000000000..504d71611f --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/sprite.inc @@ -0,0 +1,224 @@ +(* + $Id: sprite.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + sprite.h -- definitions for DS sprites + + Copyright (C) 2007 + Liran Nuna (LiraNuna) + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM9} + {$error Sprites are only available on the ARM9} +{$endif ARM9} + +// Sprite control defines + +{$ifdef NDS_INTERFACE} +// Attribute 0 consists of 8 bits of Y plus the following flags: +const + ATTR0_NORMAL = (0 shl 8); + ATTR0_ROTSCALE = (1 shl 8); + ATTR0_DISABLED = (2 shl 8); + ATTR0_ROTSCALE_DOUBLE = (3 shl 8); + + ATTR0_TYPE_NORMAL = (0 shl 10); + ATTR0_TYPE_BLENDED = (1 shl 10); + ATTR0_TYPE_WINDOWED = (2 shl 10); + ATTR0_BMP = (3 shl 10); + + ATTR0_MOSAIC = (1 shl 12); + + ATTR0_COLOR_16 = (0 shl 13); //16 color in tile mode...16 bit in bitmap mode + ATTR0_COLOR_256 = (1 shl 13); + + ATTR0_SQUARE = (0 shl 14); + ATTR0_WIDE = (1 shl 14); + ATTR0_TALL = (2 shl 14); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function OBJ_Y(m: cint): cint; inline; +begin + OBJ_Y := ((m) and $00ff); +end; + +function ATTR1_ROTDATA(n: cint): cint; inline; +begin + ATTR1_ROTDATA := ((n) shl 9) // note: overlaps with flip flags +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + ATTR1_FLIP_X = (1 shl 12); + ATTR1_FLIP_Y = (1 shl 13); + ATTR1_SIZE_8 = (0 shl 14); + ATTR1_SIZE_16 = (1 shl 14); + ATTR1_SIZE_32 = (2 shl 14); + ATTR1_SIZE_64 = (3 shl 14); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function OBJ_X(m: cint): cint; inline; +begin + OBJ_X := ((m) and $01ff); +end; + +// Atribute 2 consists of the following: +function ATTR2_PRIORITY(n: cint): cint; inline; +begin + ATTR2_PRIORITY := ((n) shl 10); +end; + +function ATTR2_PALETTE(n: cint): cint; inline; +begin + ATTR2_PALETTE := ((n) shl 12); +end; + +function ATTR2_ALPHA(n: cint): cint; inline; +begin + ATTR2_ALPHA := ((n) shl 12); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +type + TObjMode = (OBJMODE_NORMAL, OBJMODE_BLENDED, OBJMODE_WINDOWED, OBJMODE_BITMAP); + TObjShape = (OBJSHAPE_SQUARE, OBJSHAPE_WIDE, OBJSHAPE_TALL, OBJSHAPE_FORBIDDEN); + TObjSize = (OBJSIZE_8, OBJSIZE_16, OBJSIZE_32, OBJSIZE_64); + TObjColMode = (OBJCOLOR_16, OBJCOLOR_256); + TObjPriority = (OBJPRIORITY_0, OBJPRIORITY_1, OBJPRIORITY_2, OBJPRIORITY_3); + + sSpriteEntry = packed record + case integer of + 0: (st1: packed record + st1: bitpacked record + posY: 0..8; + case integer of + 0: (st1: bitpacked record + __padding1: 0..1; + isHidden: 0..1; + __padding2: 0..6; + end; + ); + 1: (st2: bitpacked record + isRotoscale: 0..1; + rsDouble: 0..1; + objMode: 0..2; + isMosaic: 0..1; + colMode: 0..1; + objShape: 0..2; + end; + ); + end; + st2: bitpacked record + tileIdx: 0..10; + objPriority: 0..2; + objPal: 0..4; + end; + attribute3: cuint16; + case integer of + 0: (st1: bitpacked record + posX: 0..9; + __padding1: 0..7; + end; + ); + 1: (st2: bitpacked record + __padding1: 0..8; + case integer of + 0: (st1: bitpacked record + __padding1: 0..4; + hFlip: 0..1; + vFlip: 0..1; + __padding2: 0..2; + end; + ); + 1: (st2: bitpacked record + __padding1: 0..1; + rsMatrixIdx: 0..5; + objSize: 0..2; + end; + ); + end; + ); + end; + ); + 1: (st: packed record + attribute: array [0..2] of cuint16; + filler: cuint16; + end; + ); + end; + SpriteEntry = sSpriteEntry; + TSpriteEntry = sSpriteEntry; + PSpriteEntry = ^sSpriteEntry; + + + sSpriteRotation = record + filler1: array [0..2] of cuint16; + hdx: cint16; + filler2: array [0..2] of cuint16; + hdy: cint16; + filler3: array [0..2] of cuint16; + vdx: cint16; + filler4: array [0..2] of cuint16; + vdy: cint16; + end; + SpriteRotation = sSpriteRotation; + TSpriteRotation = sSpriteRotation; + pSpriteRotation = ^sSpriteRotation; + + +const + SPRITE_COUNT = 128; + MATRIX_COUNT = 32; + +type + TOAM = record + case integer of + 0: (spriteBuffer: array [0..SPRITE_COUNT-1] of TSpriteEntry;); + 1: (matrixBuffer: array [0..MATRIX_COUNT-1] of TSpriteRotation;); + end; +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function OBJ_Y(m: cint): cint; inline; +function ATTR1_ROTDATA(n: cint): cint; inline; +function OBJ_X(m: cint): cint; inline; +function ATTR2_PRIORITY(n: cint): cint; inline; +function ATTR2_PALETTE(n: cint): cint; inline; +function ATTR2_ALPHA(n: cint): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/trig_lut.inc b/packages/libndsfpc/src/nds/arm9/trig_lut.inc new file mode 100644 index 0000000000..a054f86f36 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/trig_lut.inc @@ -0,0 +1,50 @@ +(* + $Id: trig_lut.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +var + COS_bin: array [0..0] of cshort; cvar; external; + SIN_bin: array [0..0] of cshort; cvar; external; + TAN_bin: array [0..0] of cshort; cvar; external; + +{$define _COS := COS_bin} +{$define _SIN := SIN_bin} +{$define _TAN := TAN_bin} +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/video.inc b/packages/libndsfpc/src/nds/arm9/video.inc new file mode 100644 index 0000000000..9772a6949d --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/video.inc @@ -0,0 +1,766 @@ +(* + $Id: video.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifndef ARM9} + {$error Video is only available on the ARM9} +{$endif ARM9} + +{$ifdef NDS_IMPLEMENTATION} +function RGB15(r, g, b: cint): cuint16; +begin + RGB15 := ((r) or ((g) shl 5) or ((b) shl 10)); +end; + +function RGB5(r, g, b: cint): cuint16; +begin + RGB5 := ((r) or ((g) shl 5) or ((b) shl 10)); +end; + +function RGB8(r, g, b: cint): cuint8; +begin + RGB8 := (((r) shr 3) or (((g) shr 3) shl 5) or (((b) shr 3) shl 10)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + SCREEN_HEIGHT = 192; + SCREEN_WIDTH = 256; + +// Vram Control + VRAM_CR : pcuint32 = pointer($04000240); + VRAM_A_CR : pcuint8 = pointer($04000240); + VRAM_B_CR : pcuint8 = pointer($04000241); + VRAM_C_CR : pcuint8 = pointer($04000242); + VRAM_D_CR : pcuint8 = pointer($04000243); + VRAM_E_CR : pcuint8 = pointer($04000244); + VRAM_F_CR : pcuint8 = pointer($04000245); + VRAM_G_CR : pcuint8 = pointer($04000246); + WRAM_CR : pcuint8 = pointer($04000247); + VRAM_H_CR : pcuint8 = pointer($04000248); + VRAM_I_CR : pcuint8 = pointer($04000249); + + VRAM_ENABLE = (1 shl 7); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function VRAM_OFFSET(n: cint): cint; inline; +begin + VRAM_OFFSET := ((n) shl 3); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +type + VRAM_A_TYPE = cint; +const + VRAM_A_LCD : VRAM_A_TYPE = 0; + VRAM_A_MAIN_BG : VRAM_A_TYPE = 1; + VRAM_A_MAIN_BG_0x06000000 : VRAM_A_TYPE = 1 or (0 shl 3); + VRAM_A_MAIN_BG_0x06020000 : VRAM_A_TYPE = 1 or (1 shl 3); + VRAM_A_MAIN_BG_0x06040000 : VRAM_A_TYPE = 1 or (2 shl 3); + VRAM_A_MAIN_BG_0x06060000 : VRAM_A_TYPE = 1 or (3 shl 3); + VRAM_A_MAIN_SPRITE : VRAM_A_TYPE = 2; + VRAM_A_MAIN_SPRITE_0x06400000 : VRAM_A_TYPE = 2; + VRAM_A_MAIN_SPRITE_0x06420000 : VRAM_A_TYPE = 2 or (1 shl 3); + VRAM_A_TEXTURE : VRAM_A_TYPE = 3; + VRAM_A_TEXTURE_SLOT0 : VRAM_A_TYPE = 3 or (0 shl 3); + VRAM_A_TEXTURE_SLOT1 : VRAM_A_TYPE = 3 or (1 shl 3); + VRAM_A_TEXTURE_SLOT2 : VRAM_A_TYPE = 3 or (2 shl 3); + VRAM_A_TEXTURE_SLOT3 : VRAM_A_TYPE = 3 or (3 shl 3); + +type + VRAM_B_TYPE = cint; +const + VRAM_B_LCD : VRAM_B_TYPE = 0; + VRAM_B_MAIN_BG : VRAM_B_TYPE = 1 or (1 shl 3); + VRAM_B_MAIN_BG_0x06000000 : VRAM_B_TYPE = 1 or (0 shl 3); + VRAM_B_MAIN_BG_0x06020000 : VRAM_B_TYPE = 1 or (1 shl 3); + VRAM_B_MAIN_BG_0x06040000 : VRAM_B_TYPE = 1 or (2 shl 3); + VRAM_B_MAIN_BG_0x06060000 : VRAM_B_TYPE = 1 or (3 shl 3); + VRAM_B_MAIN_SPRITE : VRAM_B_TYPE = 2 or (1 shl 3); + VRAM_B_MAIN_SPRITE_0x06400000 : VRAM_B_TYPE = 2; + VRAM_B_MAIN_SPRITE_0x06420000 : VRAM_B_TYPE = 2 or (1 shl 3); + VRAM_B_TEXTURE : VRAM_B_TYPE = 3 or (1 shl 3); + VRAM_B_TEXTURE_SLOT0 : VRAM_B_TYPE = 3 or (0 shl 3); + VRAM_B_TEXTURE_SLOT1 : VRAM_B_TYPE = 3 or (1 shl 3); + VRAM_B_TEXTURE_SLOT2 : VRAM_B_TYPE = 3 or (2 shl 3); + VRAM_B_TEXTURE_SLOT3 : VRAM_B_TYPE = 3 or (3 shl 3); + + +type + VRAM_C_TYPE = cint; +const + VRAM_C_LCD : VRAM_C_TYPE = 0; + VRAM_C_MAIN_BG : VRAM_C_TYPE = 1 or (2 shl 3); + VRAM_C_MAIN_BG_0x06000000 : VRAM_C_TYPE = 1 or (0 shl 3); + VRAM_C_MAIN_BG_0x06020000 : VRAM_C_TYPE = 1 or (1 shl 3); + VRAM_C_MAIN_BG_0x06040000 : VRAM_C_TYPE = 1 or (2 shl 3); + VRAM_C_MAIN_BG_0x06060000 : VRAM_C_TYPE = 1 or (3 shl 3); + VRAM_C_ARM7 : VRAM_C_TYPE = 2; + VRAM_C_ARM7_0x06000000 : VRAM_C_TYPE = 2; + VRAM_C_ARM7_0x06020000 : VRAM_C_TYPE = 2 or (1 shl 3); + VRAM_C_SUB_BG : VRAM_C_TYPE = 4; + VRAM_C_SUB_BG_0x06200000 : VRAM_C_TYPE = 4 or (0 shl 3); + VRAM_C_SUB_BG_0x06220000 : VRAM_C_TYPE = 4 or (1 shl 3); + VRAM_C_SUB_BG_0x06240000 : VRAM_C_TYPE = 4 or (2 shl 3); + VRAM_C_SUB_BG_0x06260000 : VRAM_C_TYPE = 4 or (3 shl 3); + VRAM_C_TEXTURE : VRAM_C_TYPE = 3 or (2 shl 3); + VRAM_C_TEXTURE_SLOT0 : VRAM_C_TYPE = 3 or (0 shl 3); + VRAM_C_TEXTURE_SLOT1 : VRAM_C_TYPE = 3 or (1 shl 3); + VRAM_C_TEXTURE_SLOT2 : VRAM_C_TYPE = 3 or (2 shl 3); + VRAM_C_TEXTURE_SLOT3 : VRAM_C_TYPE = 3 or (3 shl 3); + + +type + VRAM_D_TYPE = cint; +const + VRAM_D_LCD : VRAM_D_TYPE = 0; + VRAM_D_MAIN_BG : VRAM_D_TYPE = 1 or (3 shl 3); + VRAM_D_MAIN_BG_0x06000000 : VRAM_D_TYPE = 1 or (0 shl 3); + VRAM_D_MAIN_BG_0x06020000 : VRAM_D_TYPE = 1 or (1 shl 3); + VRAM_D_MAIN_BG_0x06040000 : VRAM_D_TYPE = 1 or (2 shl 3); + VRAM_D_MAIN_BG_0x06060000 : VRAM_D_TYPE = 1 or (3 shl 3); + VRAM_D_ARM7 : VRAM_D_TYPE = 2 or (1 shl 3); + VRAM_D_ARM7_0x06000000 : VRAM_D_TYPE = 2; + VRAM_D_ARM7_0x06020000 : VRAM_D_TYPE = 2 or (1 shl 3); + VRAM_D_SUB_SPRITE : VRAM_D_TYPE = 4; + VRAM_D_TEXTURE : VRAM_D_TYPE = 3 or (3 shl 3); + VRAM_D_TEXTURE_SLOT0 : VRAM_D_TYPE = 3 or (0 shl 3); + VRAM_D_TEXTURE_SLOT1 : VRAM_D_TYPE = 3 or (1 shl 3); + VRAM_D_TEXTURE_SLOT2 : VRAM_D_TYPE = 3 or (2 shl 3); + VRAM_D_TEXTURE_SLOT3 : VRAM_D_TYPE = 3 or (3 shl 3); + +type + VRAM_E_TYPE = cint; +const + VRAM_E_LCD : VRAM_E_TYPE = 0; + VRAM_E_MAIN_BG : VRAM_E_TYPE = 1; + VRAM_E_MAIN_SPRITE : VRAM_E_TYPE = 2; + VRAM_E_TEX_PALETTE : VRAM_E_TYPE = 3; + VRAM_E_BG_EXT_PALETTE : VRAM_E_TYPE = 4; + VRAM_E_OBJ_EXT_PALETTE : VRAM_E_TYPE = 5; + +type + VRAM_F_TYPE = cint; +const + VRAM_F_LCD : VRAM_F_TYPE = 0; + VRAM_F_MAIN_BG : VRAM_F_TYPE = 1; + VRAM_F_MAIN_SPRITE : VRAM_F_TYPE = 2; + VRAM_F_MAIN_SPRITE_0x06000000 : VRAM_F_TYPE = 2; + VRAM_F_MAIN_SPRITE_0x06004000 : VRAM_F_TYPE = 2 or (1 shl 3); + VRAM_F_MAIN_SPRITE_0x06010000 : VRAM_F_TYPE = 2 or (2 shl 3); + VRAM_F_MAIN_SPRITE_0x06014000 : VRAM_F_TYPE = 2 or (3 shl 3); + VRAM_F_TEX_PALETTE : VRAM_F_TYPE = 3; + VRAM_F_BG_EXT_PALETTE : VRAM_F_TYPE = 4; + VRAM_F_OBJ_EXT_PALETTE : VRAM_F_TYPE = 5; + +type + VRAM_G_TYPE = cint; +const + VRAM_G_LCD : VRAM_G_TYPE = 0; + VRAM_G_MAIN_BG : VRAM_G_TYPE = 1; + VRAM_G_MAIN_SPRITE : VRAM_G_TYPE = 2; + VRAM_G_MAIN_SPRITE_0x06000000 : VRAM_G_TYPE = 2; + VRAM_G_MAIN_SPRITE_0x06004000 : VRAM_G_TYPE = 2 or (1 shl 3); + VRAM_G_MAIN_SPRITE_0x06010000 : VRAM_G_TYPE = 2 or (2 shl 3); + VRAM_G_MAIN_SPRITE_0x06014000 : VRAM_G_TYPE = 2 or (3 shl 3); + VRAM_G_TEX_PALETTE : VRAM_G_TYPE = 3; + VRAM_G_BG_EXT_PALETTE : VRAM_G_TYPE = 4; + VRAM_G_OBJ_EXT_PALETTE : VRAM_G_TYPE = 5; + +type + VRAM_H_TYPE = cint; +const + VRAM_H_LCD : VRAM_H_TYPE = 0; + VRAM_H_SUB_BG : VRAM_H_TYPE = 1; + VRAM_H_SUB_BG_EXT_PALETTE : VRAM_H_TYPE = 2; + +type + VRAM_I_TYPE = cint; +const + VRAM_I_LCD : VRAM_I_TYPE = 0; + VRAM_I_SUB_BG : VRAM_I_TYPE = 1; + VRAM_I_SUB_SPRITE : VRAM_I_TYPE = 2; + VRAM_I_SUB_SPRITE_EXT_PALETTE : VRAM_I_TYPE = 3; + +type + TPalette = array [0..255] of cuint16; + TExtPalette = array [0..15] of TPalette; + PPalette = ^TPalette; + PExtPalette = ^TExtPalette; + +var + VRAM_E_EXT_PALETTE : PExtPalette absolute VRAM_E; + VRAM_F_EXT_PALETTE : PExtPalette absolute VRAM_F; + VRAM_G_EXT_PALETTE : PExtPalette absolute VRAM_G; + VRAM_H_EXT_PALETTE : PExtPalette absolute VRAM_H; + +function vramSetMainBanks(a: VRAM_A_TYPE; b: VRAM_B_TYPE; c: VRAM_C_TYPE; d: VRAM_D_TYPE): cuint32; cdecl; external; +procedure vramRestoreMainBanks(vramTemp: cuint32); cdecl; external; + +procedure vramSetBankA(a: VRAM_A_TYPE); cdecl; external; +procedure vramSetBankB(b: VRAM_B_TYPE); cdecl; external; +procedure vramSetBankC(c: VRAM_C_TYPE); cdecl; external; +procedure vramSetBankD(d: VRAM_D_TYPE); cdecl; external; +procedure vramSetBankE(e: VRAM_E_TYPE); cdecl; external; +procedure vramSetBankF(f: VRAM_F_TYPE); cdecl; external; +procedure vramSetBankG(g: VRAM_G_TYPE); cdecl; external; +procedure vramSetBankH(h: VRAM_H_TYPE); cdecl; external; +procedure vramSetBankI(i: VRAM_I_TYPE); cdecl; external; + + +// Display control registers +const + DISPLAY_CR : pcuint32 = pointer($04000000); + SUB_DISPLAY_CR : pcuint32 = pointer($04001000); + + MODE_0_2D = $10000; + MODE_1_2D = $10001; + MODE_2_2D = $10002; + MODE_3_2D = $10003; + MODE_4_2D = $10004; + MODE_5_2D = $10005; + +// main display only + MODE_6_2D = $10006; + MODE_FIFO = (3 shl 16); + + ENABLE_3D = (1 shl 3); + + DISPLAY_BG0_ACTIVE = (1 shl 8); + DISPLAY_BG1_ACTIVE = (1 shl 9); + DISPLAY_BG2_ACTIVE = (1 shl 10); + DISPLAY_BG3_ACTIVE = (1 shl 11); + DISPLAY_SPR_ACTIVE = (1 shl 12); + DISPLAY_WIN0_ON = (1 shl 13); + DISPLAY_WIN1_ON = (1 shl 14); + DISPLAY_SPR_WIN_ON = (1 shl 15); + + +// Main display only + MODE_0_3D = (MODE_0_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_1_3D = (MODE_1_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_2_3D = (MODE_2_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_3_3D = (MODE_3_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_4_3D = (MODE_4_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_5_3D = (MODE_5_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + MODE_6_3D = (MODE_6_2D or DISPLAY_BG0_ACTIVE or ENABLE_3D); + + MODE_FB0 = ($00020000); + MODE_FB1 = ($00060000); + MODE_FB2 = ($000A0000); + MODE_FB3 = ($000E0000); + + DISPLAY_SPR_HBLANK = (1 shl 23); + + DISPLAY_SPR_1D_LAYOUT = (1 shl 4); + + DISPLAY_SPR_1D = (1 shl 4); + DISPLAY_SPR_2D = (0 shl 4); + DISPLAY_SPR_1D_BMP = (4 shl 4); + DISPLAY_SPR_2D_BMP_128 = (0 shl 4); + DISPLAY_SPR_2D_BMP_256 = (2 shl 4); + + + DISPLAY_SPR_1D_SIZE_32 = (0 shl 20); + DISPLAY_SPR_1D_SIZE_64 = (1 shl 20); + DISPLAY_SPR_1D_SIZE_128 = (2 shl 20); + DISPLAY_SPR_1D_SIZE_256 = (3 shl 20); + DISPLAY_SPR_1D_BMP_SIZE_128 = (0 shl 22); + DISPLAY_SPR_1D_BMP_SIZE_256 = (1 shl 22); + + + DISPLAY_SPR_EXT_PALETTE = (1 shl 31); + DISPLAY_BG_EXT_PALETTE = (1 shl 30); + + DISPLAY_SCREEN_OFF = (1 shl 7); +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +function DISPLAY_CHAR_BASE(n: cuint32): cuint32; inline; +begin + DISPLAY_CHAR_BASE := ((n) and 7) shl 24; +end; + +function DISPLAY_SCREEN_BASE(n: cuint32): cuint32; inline; +begin + DISPLAY_SCREEN_BASE := ((n) and 7) shl 27; +end; + +procedure videoSetMode(mode: cuint32); inline; +begin + DISPLAY_CR^ := mode; +end; + +procedure videoSetModeSub(mode: cuint32); inline; +begin + SUB_DISPLAY_CR^ := mode; +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + BRIGHTNESS : pcuint16 = pointer($0400006C); + SUB_BRIGHTNESS : pcuint16 = pointer($0400106C); + + BGCTRL : pcuint16 = pointer($04000008); + BG0_CR : pcuint16 = pointer($04000008); + BG1_CR : pcuint16 = pointer($0400000A); + BG2_CR : pcuint16 = pointer($0400000C); + BG3_CR : pcuint16 = pointer($0400000E); + + BGCTRL_SUB : pcuint16 = pointer($04001008); + SUB_BG0_CR : pcuint16 = pointer($04001008); + SUB_BG1_CR : pcuint16 = pointer($0400100A); + SUB_BG2_CR : pcuint16 = pointer($0400100C); + SUB_BG3_CR : pcuint16 = pointer($0400100E); + + BG_256_COLOR = (1 shl 7); + BG_16_COLOR = (0); + + BG_MOSAIC_ON = (1 shl 6); + BG_MOSAIC_OFF = (0); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function BG_PRIORITY(n: cint): cint; inline; +begin + BG_PRIORITY := (n); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + BG_PRIORITY_0 = (0); + BG_PRIORITY_1 = (1); + BG_PRIORITY_2 = (2); + BG_PRIORITY_3 = (3); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function BG_TILE_BASE(base: cint): cint; inline; +begin + BG_TILE_BASE := ((base) shl 2); +end; + +function BG_MAP_BASE(base: cint): cint; inline; +begin + BG_MAP_BASE := ((base) shl 8); +end; + +function BG_BMP_BASE(base: cint): cint; inline; +begin + BG_BMP_BASE := ((base) shl 8); +end; + + +function BG_MAP_RAM(base: cint): cint; inline; +begin + BG_MAP_RAM := (((base) * $800) + $06000000); +end; + +function BG_MAP_RAM_SUB(base: cint): cint; inline; +begin + BG_MAP_RAM_SUB := (((base) * $800) + $06200000); +end; + + +function BG_TILE_RAM(base: cint): cint; inline; +begin + BG_TILE_RAM := (((base) * $4000) + $06000000); +end; + +function BG_TILE_RAM_SUB(base: cint): cint; inline; +begin + BG_TILE_RAM_SUB := (((base) * $4000) + $06200000); +end; + + +function BG_BMP_RAM(base: cint): cint; inline; +begin + BG_BMP_RAM := (((base) * $4000) + $06000000); +end; + +function BG_BMP_RAM_SUB(base: cint): cint; inline; +begin + BG_BMP_RAM_SUB := (((base) * $4000) + $06200000); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + BG_WRAP_OFF = (0); + BG_WRAP_ON = (1 shl 13); + + BG_32x32 = (0 shl 14); + BG_64x32 = (1 shl 14); + BG_32x64 = (2 shl 14); + BG_64x64 = (3 shl 14); + + BG_RS_16x16 = (0 shl 14); + BG_RS_32x32 = (1 shl 14); + BG_RS_64x64 = (2 shl 14); + BG_RS_128x128 = (3 shl 14); + + BG_BMP8_128x128 = (BG_RS_16x16 or BG_256_COLOR); + BG_BMP8_256x256 = (BG_RS_32x32 or BG_256_COLOR); + BG_BMP8_512x256 = (BG_RS_64x64 or BG_256_COLOR); + BG_BMP8_512x512 = (BG_RS_128x128 or BG_256_COLOR); + BG_BMP8_1024x512 = (1 shl 14); + BG_BMP8_512x1024 = 0; + + BG_BMP16_128x128 = (BG_RS_16x16 or BG_256_COLOR or (1 shl 2)); + BG_BMP16_256x256 = (BG_RS_32x32 or BG_256_COLOR or (1 shl 2)); + BG_BMP16_512x256 = (BG_RS_64x64 or BG_256_COLOR or (1 shl 2)); + BG_BMP16_512x512 = (BG_RS_128x128 or BG_256_COLOR or (1 shl 2)); + + BG_PALETTE_SLOT0 = 0; + BG_PALETTE_SLOT1 = 0; + BG_PALETTE_SLOT2 = (1 shl 13); + BG_PALETTE_SLOT3 = (1 shl 13); + +type + bg_scroll = record + x: cuint16; + y: cuint16; + end; + Tbg_scroll = bg_scroll; + Pbg_scroll = ^bg_scroll; + + bg_rotation = record + xdx: cuint16; + xdy: cuint16; + ydx: cuint16; + ydy: cuint16; + centerX: cuint32; + centerY: cuint32; + end; + Tbg_rotation = bg_rotation; + Pbg_rotation = ^bg_rotation; + + bg_attribute = record + control: array [0..3] of cuint16; + scroll: array [0..3] of bg_scroll; + bg2_rotation: bg_rotation; + bg3_rotation: bg_rotation; + end; + Tbg_attribute = bg_attribute; + Pbg_attribute = ^bg_attribute; + + +const + BACKGROUND : Pbg_attribute = pointer($04000008); + BACKGROUND_SUB : Pbg_attribute = pointer($04001008); + + BG_OFFSET : Pbg_scroll = pointer($04000010); + + BG0_X0 : pcuint16 = pointer($04000010); + BG0_Y0 : pcuint16 = pointer($04000012); + BG1_X0 : pcuint16 = pointer($04000014); + BG1_Y0 : pcuint16 = pointer($04000016); + BG2_X0 : pcuint16 = pointer($04000018); + BG2_Y0 : pcuint16 = pointer($0400001A); + BG3_X0 : pcuint16 = pointer($0400001C); + BG3_Y0 : pcuint16 = pointer($0400001E); + + BG2_XDX : pcuint16 = pointer($04000020); + BG2_XDY : pcuint16 = pointer($04000022); + BG2_YDX : pcuint16 = pointer($04000024); + BG2_YDY : pcuint16 = pointer($04000026); + BG2_CX : pcuint32 = pointer($04000028); + BG2_CY : pcuint32 = pointer($0400002C); + + BG3_XDX : pcuint16 = pointer($04000030); + BG3_XDY : pcuint16 = pointer($04000032); + BG3_YDX : pcuint16 = pointer($04000034); + BG3_YDY : pcuint16 = pointer($04000036); + BG3_CX : pcuint32 = pointer($04000038); + BG3_CY : pcuint32 = pointer($0400003C); + + SUB_BG0_X0 : pcuint16 = pointer($04001010); + SUB_BG0_Y0 : pcuint16 = pointer($04001012); + SUB_BG1_X0 : pcuint16 = pointer($04001014); + SUB_BG1_Y0 : pcuint16 = pointer($04001016); + SUB_BG2_X0 : pcuint16 = pointer($04001018); + SUB_BG2_Y0 : pcuint16 = pointer($0400101A); + SUB_BG3_X0 : pcuint16 = pointer($0400101C); + SUB_BG3_Y0 : pcuint16 = pointer($0400101E); + + SUB_BG2_XDX : pcuint16 = pointer($04001020); + SUB_BG2_XDY : pcuint16 = pointer($04001022); + SUB_BG2_YDX : pcuint16 = pointer($04001024); + SUB_BG2_YDY : pcuint16 = pointer($04001026); + SUB_BG2_CX : pcuint32 = pointer($04001028); + SUB_BG2_CY : pcuint32 = pointer($0400102C); + + SUB_BG3_XDX : pcuint16 = pointer($04001030); + SUB_BG3_XDY : pcuint16 = pointer($04001032); + SUB_BG3_YDX : pcuint16 = pointer($04001034); + SUB_BG3_YDY : pcuint16 = pointer($04001036); + SUB_BG3_CX : pcuint32 = pointer($04001038); + SUB_BG3_CY : pcuint32 = pointer($0400103C); + +// Window 0 + WIN0_X0 : pcuint8 = pointer($04000041); + WIN0_X1 : pcuint8 = pointer($04000040); + WIN0_Y0 : pcuint8 = pointer($04000045); + WIN0_Y1 : pcuint8 = pointer($04000044); + +// Window 1 + WIN1_X0 : pcuint8 = pointer($04000042); + WIN1_X1 : pcuint8 = pointer($04000043); + WIN1_Y0 : pcuint8 = pointer($04000047); + WIN1_Y1 : pcuint8 = pointer($04000046); + + WIN_IN : pcuint16 = pointer($04000048); + WIN_OUT : pcuint16 = pointer($0400004A); + +// Window 0 + SUB_WIN0_X0 : pcuint8 = pointer($04001041); + SUB_WIN0_X1 : pcuint8 = pointer($04001040); + SUB_WIN0_Y0 : pcuint8 = pointer($04001045); + SUB_WIN0_Y1 : pcuint8 = pointer($04001044); + +// Window 1 + SUB_WIN1_X0 : pcuint8 = pointer($04001042); + SUB_WIN1_X1 : pcuint8 = pointer($04001043); + SUB_WIN1_Y0 : pcuint8 = pointer($04001047); + SUB_WIN1_Y1 : pcuint8 = pointer($04001046); + + SUB_WIN_IN : pcuint16 = pointer($04001048); + SUB_WIN_OUT : pcuint16 = pointer($0400104A); + + MOSAIC_CR : pcuint16 = pointer($0400004C); + SUB_MOSAIC_CR : pcuint16 = pointer($0400104C); + + BLEND_CR : pcuint16 = pointer($04000050); + BLEND_AB : pcuint16 = pointer($04000052); + BLEND_Y : pcuint16 = pointer($04000054); + + SUB_BLEND_CR : pcuint16 = pointer($04001050); + SUB_BLEND_AB : pcuint16 = pointer($04001052); + SUB_BLEND_Y : pcuint16 = pointer($04001054); + + BLEND_NONE = (0 shl 6); + BLEND_ALPHA = (1 shl 6); + BLEND_FADE_WHITE = (2 shl 6); + BLEND_FADE_BLACK = (3 shl 6); + + BLEND_SRC_BG0 = (1 shl 0); + BLEND_SRC_BG1 = (1 shl 1); + BLEND_SRC_BG2 = (1 shl 2); + BLEND_SRC_BG3 = (1 shl 3); + BLEND_SRC_SPRITE = (1 shl 4); + BLEND_SRC_BACKDROP = (1 shl 5); + + BLEND_DST_BG0 = (1 shl 8); + BLEND_DST_BG1 = (1 shl 9); + BLEND_DST_BG2 = (1 shl 10); + BLEND_DST_BG3 = (1 shl 11); + BLEND_DST_SPRITE = (1 shl 12); + BLEND_DST_BACKDROP = (1 shl 13); + +// Display capture control + + REG_DISPCAPCNT: pcuint32 = pointer($04000064); + REG_DISP_MMEM_FIFO: pcuint32 = pointer($04000068); + + DCAP_ENABLE = (1 shl 31); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function DCAP_MODE(n: cint): cint; inline; +begin + DCAP_MODE := (((n) and 3) shl 29); +end; + +function DCAP_DST(n: cint): cint; inline; +begin + DCAP_DST := (((n) and 3) shl 26); +end; + +function DCAP_SRC(n: cint): cint; inline; +begin + DCAP_SRC := (((n) and 3) shl 24); +end; + +function DCAP_SIZE(n: cint): cint; inline; +begin + DCAP_SIZE := (((n) and 3) shl 20); +end; + +function DCAP_OFFSET(n: cint): cint; inline; +begin + DCAP_OFFSET := (((n) and 3) shl 18); +end; + +function DCAP_BANK(n: cint): cint; inline; +begin + DCAP_BANK := (((n) and 3) shl 16); +end; + +function DCAP_B(n: cint): cint; inline; +begin + DCAP_B := (((n) and $1F) shl 8); +end; + +function DCAP_A(n: cint): cint; inline; +begin + DCAP_A := (((n) and $1F) shl 0); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +// 3D core control +const + GFX_CONTROL : pcuint16 = pointer($04000060); + + GFX_FIFO : pcuint32 = pointer($04000400); + GFX_STATUS : pcuint32 = pointer($04000600); + GFX_COLOR : pcuint32 = pointer($04000480); + + GFX_VERTEX10 : pcuint32 = pointer($04000490); + GFX_VERTEX_XY : pcuint32 = pointer($04000494); + GFX_VERTEX_XZ : pcuint32 = pointer($04000498); + GFX_VERTEX_YZ : pcuint32 = pointer($0400049C); + GFX_VERTEX_DIFF : pcuint32 = pointer($040004A0); + + GFX_VERTEX16 : pcuint32 = pointer($0400048C); + GFX_TEX_COORD : pcuint32 = pointer($04000488); + GFX_TEX_FORMAT : pcuint32 = pointer($040004A8); + GFX_PAL_FORMAT : pcuint32 = pointer($040004AC); + + GFX_CLEAR_COLOR : pcuint32 = pointer($04000350); + GFX_CLEAR_DEPTH : pcuint16 = pointer($04000354); + + GFX_LIGHT_VECTOR : pcuint32 = pointer($040004C8); + GFX_LIGHT_COLOR : pcuint32 = pointer($040004CC); + GFX_NORMAL : pcuint32 = pointer($04000484); + + GFX_DIFFUSE_AMBIENT : pcuint32 = pointer($040004C0); + GFX_SPECULAR_EMISSION : pcuint32 = pointer($040004C4); + GFX_SHININESS : pcuint32 = pointer($040004D0); + + GFX_POLY_FORMAT : pcuint32 = pointer($040004A4); + GFX_ALPHA_TEST : pcuint16 = pointer($04000340); + + GFX_BEGIN : pcuint32 = pointer($04000500); + GFX_END : pcuint32 = pointer($04000504); + GFX_FLUSH : pcuint32 = pointer($04000540); + GFX_VIEWPORT : pcuint32 = pointer($04000580); + GFX_TOON_TABLE : pcuint16 = pointer($04000380); + GFX_EDGE_TABLE : pcuint16 = pointer($04000330); + GFX_FOG_COLOR : pcuint32 = pointer($04000358); + GFX_FOG_OFFSET : pcuint32 = pointer($0400035C); + GFX_FOG_TABLE : pcuint8 = pointer($04000360); + GFX_BOX_TEST : pcint32 = pointer($040005C0); + GFX_POS_TEST : pcint32 = pointer($040005C4); + GFX_POS_RESULT : pcint32 = pointer($04000620); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function GFX_BUSY: boolean; inline; +begin + GFX_BUSY := GFX_STATUS^ and (1 shl 27) <> 0; +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +const + GFX_VERTEX_RAM_USAGE : pcuint16 = pointer($04000606); + GFX_POLYGON_RAM_USAGE : pcuint16 = pointer($04000604); + + GFX_CUTOFF_DEPTH : pcuint16 = pointer($04000610); + +// Matrix processor control + + MATRIX_CONTROL : pcuint32 = pointer($04000440); + MATRIX_PUSH : pcuint32 = pointer($04000444); + MATRIX_POP : pcuint32 = pointer($04000448); + MATRIX_SCALE : pcint32 = pointer($0400046C); + MATRIX_TRANSLATE : pcint32 = pointer($04000470); + MATRIX_RESTORE : pcuint32 = pointer($04000450); + MATRIX_STORE : pcuint32 = pointer($0400044C); + MATRIX_IDENTITY : pcuint32 = pointer($04000454); + MATRIX_LOAD4x4 : pcint32 = pointer($04000458); + MATRIX_LOAD4x3 : pcint32 = pointer($0400045C); + MATRIX_MULT4x4 : pcint32 = pointer($04000460); + MATRIX_MULT4x3 : pcint32 = pointer($04000464); + MATRIX_MULT3x3 : pcint32 = pointer($04000468); + +//matrix operation results + MATRIX_READ_CLIP : pcint32 = pointer($04000640); + MATRIX_READ_VECTOR : pcint32 = pointer($04000680); + POINT_RESULT : pcint32 = pointer($04000620); + VECTOR_RESULT : pcuint16 = pointer($04000630); +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function RGB15(r, g, b: cint): cuint16; +function RGB5(r, g, b: cint): cuint16; +function RGB8(r, g, b: cint): cuint8; +function VRAM_OFFSET(n: cint): cint; inline; +function DISPLAY_CHAR_BASE(n: cuint32): cuint32; inline; +function DISPLAY_SCREEN_BASE(n: cuint32): cuint32; inline; +procedure videoSetMode(mode: cuint32); inline; +procedure videoSetModeSub(mode: cuint32); inline; +function BG_PRIORITY(n: cint): cint; inline; +function BG_TILE_BASE(base: cint): cint; inline; +function BG_MAP_BASE(base: cint): cint; inline; +function BG_BMP_BASE(base: cint): cint; inline; +function BG_MAP_RAM(base: cint): cint; inline; +function BG_MAP_RAM_SUB(base: cint): cint; inline; +function BG_TILE_RAM(base: cint): cint; inline; +function BG_TILE_RAM_SUB(base: cint): cint; inline; +function BG_BMP_RAM(base: cint): cint; inline; +function BG_BMP_RAM_SUB(base: cint): cint; inline; +function DCAP_MODE(n: cint): cint; inline; +function DCAP_DST(n: cint): cint; inline; +function DCAP_SRC(n: cint): cint; inline; +function DCAP_SIZE(n: cint): cint; inline; +function DCAP_OFFSET(n: cint): cint; inline; +function DCAP_BANK(n: cint): cint; inline; +function DCAP_B(n: cint): cint; inline; +function DCAP_A(n: cint): cint; inline; +function GFX_BUSY: boolean; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/arm9/videoGL.inc b/packages/libndsfpc/src/nds/arm9/videoGL.inc new file mode 100644 index 0000000000..e7bed53055 --- /dev/null +++ b/packages/libndsfpc/src/nds/arm9/videoGL.inc @@ -0,0 +1,1440 @@ +(* + $Id: videoGL.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +{$ifndef ARM9} + {$error 3D hardware is only available from the ARM9} +{$endif} + + +{$ifdef NDS_INTERFACE} +(*--------------------------------------------------------------------------------- + lut resolution for trig functions + (must be power of two and must be the same as LUT resolution) + in other words dont change unless you also change your LUTs +---------------------------------------------------------------------------------*) +const + LUT_SIZE = (512); + LUT_MASK = ($1FF); + +type + GLuint = cuint32; + GLfloat = cfloat; + +////////////////////////////////////////////////////////////////////// +// Fixed point / floating point / integer conversion macros +////////////////////////////////////////////////////////////////////// + + fixed12d3 = cuint16 ; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function int_to_12d3(n: cint): fixed12d3; inline; +begin + int_to_12d3 := fixed12d3(n shl 3); +end; + +function float_to_12d3(n: cfloat): fixed12d3; inline; +begin + float_to_12d3 := fixed12d3(trunc( n * (1 shl 3))); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + GL_MAX_DEPTH = $7FFF; +{$endif NDS_INTERFACE} + +////////////////////////////////////////////////////////////////////// + +{$ifdef NDS_IMPLEMENTATION} +function inttof32(n: cint): cint32; inline; +begin + inttof32 := ((n) shl 12); +end; + +function f32toint(n: cint32): cint; inline; +begin + f32toint := ((n) shr 12); +end; + +function floattof32(n: cfloat): cint32; inline; +begin + floattof32 := trunc((n) * (1 shl 12)); +end; + +// check it! +function f32tofloat(n: cint32): cfloat; inline; +begin + f32tofloat := (n * 1.0) / ((1 shl 12) * 1.0); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +type + t16 = cint16; // text coordinate 12.4 fixed point (or cint?) +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function f32tot16(n: cint32): t16; inline; +begin + f32tot16 := t16(n shr 8); +end; + +function inttot16(n: cint): cint32; inline; //??? +begin + inttot16 := (n shl 4); +end; + +function t16toint(n: t16): cint; inline; +begin + t16toint := cint((n) shr 4); +end; + +function floattot16(n: cfloat): t16; inline; +begin + floattot16 := t16(trunc(n * (1 shl 4))); +end; + +function TEXTURE_PACK(u, v: cint): cint; inline; +begin + TEXTURE_PACK := (u and $FFFF) or (v shl 16); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +type + v16 = cuint16; // vertex 4.12 fixed format +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function inttov16(n: cint): cint; inline; +begin + inttov16 := (n shl 12); +end; + +function f32tov16(n: cint32): v16; inline; +begin + f32tov16 := v16(n); +end; + +function v16toint(n: v16): cint; inline; +begin + v16toint := cint((n) shr 12); +end; + +function floattov16(n: cfloat): v16; inline; +begin + floattov16 := v16(trunc(n * (1 shl 12))); +end; + +function VERTEX_PACK(x,y: cint): cint; inline; +begin + VERTEX_PACK := (x and $FFFF) or (y shl 16); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +type + v10 = cint16; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function inttov10(n: cint): cint; inline; +begin + inttov10 := ((n) shl 9); +end; + +function f32tov10(n: cint32): cint; inline; +begin + f32tov10 := (n shr 3); +end; + +function v10toint(n: v10): cint; inline; +begin + v10toint := cint((n) shr 9); +end; + +function floattov10(n: cfloat): v10; inline; +begin + if n > 0.998 then + floattov10 := v10($1FF) + else + floattov10 := trunc(n * (1 shl 9)); +end; + +function NORMAL_PACK(x,y,z: cint): cint; inline; +begin + NORMAL_PACK := ((x and $3FF) or ((y and $3FF) shl 10) or (z shl 20)); +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +type + rgb = cushort; + + m3x3 = record + m: array [0..8] of cint32; + end; + pm3x3 = ^m3x3; + + m4x4 = record + m: array [0..15] of cint32; + end; + pm4x4 = ^m4x4; + + m4x3 = record + m: array [0..11] of cint32; + end; + pm4x3 = ^m4x3; + + GLvector = record + x,y,z: cint32; + end; + PGLvector= ^GLvector; + +////////////////////////////////////////////////////////////////////// + +const + GL_FALSE = 0; + GL_TRUE = 1; + +////////////////////////////////////////////////////////////////////// +// glBegin constants +////////////////////////////////////////////////////////////////////// +type + GL_GLBEGIN_ENUM = cint32; +const + GL_TRIANGLES : GL_GLBEGIN_ENUM = 0; + GL_QUADS : GL_GLBEGIN_ENUM = 1; + GL_TRIANGLE_STRIP : GL_GLBEGIN_ENUM = 2; + GL_QUAD_STRIP : GL_GLBEGIN_ENUM = 3; + GL_TRIANGLE : GL_GLBEGIN_ENUM = 0; + GL_QUAD : GL_GLBEGIN_ENUM = 1; + +////////////////////////////////////////////////////////////////////// +// glMatrixMode constants +////////////////////////////////////////////////////////////////////// +type + GL_MATRIX_MODE_ENUM = cint32; +const + GL_PROJECTION : GL_MATRIX_MODE_ENUM = 0; + GL_POSITION : GL_MATRIX_MODE_ENUM = 1; + GL_MODELVIEW : GL_MATRIX_MODE_ENUM = 2; + GL_TEXTURE : GL_MATRIX_MODE_ENUM = 3; + +////////////////////////////////////////////////////////////////////// +// glMaterialf constants +////////////////////////////////////////////////////////////////////// +type + GL_MATERIALS_ENUM = cint32; +const + GL_AMBIENT : GL_MATERIALS_ENUM = $01; + GL_DIFFUSE : GL_MATERIALS_ENUM = $02; + GL_AMBIENT_AND_DIFFUSE : GL_MATERIALS_ENUM = $03; + GL_SPECULAR : GL_MATERIALS_ENUM = $04; + GL_SHININESS : GL_MATERIALS_ENUM = $08; + GL_EMISSION : GL_MATERIALS_ENUM = $10; + +//////////////////////////////////////////////////////////// +// glPolyFmt constants +//////////////////////////////////////////////////////////// +type + GL_POLY_FORMAT_ENUM = cint32; +const + POLY_DECAL : GL_POLY_FORMAT_ENUM = (1 shl 4); + POLY_TOON_SHADING : GL_POLY_FORMAT_ENUM = (1 shl 5); + POLY_CULL_BACK : GL_POLY_FORMAT_ENUM = (1 shl 7); + POLY_CULL_FRONT : GL_POLY_FORMAT_ENUM = (1 shl 6); + POLY_CULL_NONE : GL_POLY_FORMAT_ENUM = (3 shl 6); + POLY_FORMAT_LIGHT0 : GL_POLY_FORMAT_ENUM = (1 shl 0); + POLY_FORMAT_LIGHT1 : GL_POLY_FORMAT_ENUM = (1 shl 1); + POLY_FORMAT_LIGHT2 : GL_POLY_FORMAT_ENUM = (1 shl 2); + POLY_FORMAT_LIGHT3 : GL_POLY_FORMAT_ENUM = (1 shl 3); + + + + +//////////////////////////////////////////////////////////// +// glTexImage2d constants +//////////////////////////////////////////////////////////// +type + GL_TEXTURE_SIZE_ENUM = cint32; +const + TEXTURE_SIZE_8 : GL_TEXTURE_SIZE_ENUM = 0; + TEXTURE_SIZE_16 : GL_TEXTURE_SIZE_ENUM = 1; + TEXTURE_SIZE_32 : GL_TEXTURE_SIZE_ENUM = 2; + TEXTURE_SIZE_64 : GL_TEXTURE_SIZE_ENUM = 3; + TEXTURE_SIZE_128 : GL_TEXTURE_SIZE_ENUM = 4; + TEXTURE_SIZE_256 : GL_TEXTURE_SIZE_ENUM = 5; + TEXTURE_SIZE_512 : GL_TEXTURE_SIZE_ENUM = 6; + TEXTURE_SIZE_1024 : GL_TEXTURE_SIZE_ENUM = 7; + +type + GL_TEXTURE_PARAM_ENUM = cuint32; +const + GL_TEXTURE_WRAP_S : GL_TEXTURE_PARAM_ENUM = (1 shl 16); + GL_TEXTURE_WRAP_T : GL_TEXTURE_PARAM_ENUM = (1 shl 17); + GL_TEXTURE_FLIP_S : GL_TEXTURE_PARAM_ENUM = (1 shl 18); + GL_TEXTURE_FLIP_T : GL_TEXTURE_PARAM_ENUM = (1 shl 19); + GL_TEXTURE_COLOR0_TRANSPARENT : GL_TEXTURE_PARAM_ENUM = (1 shl 29); + GL_TEXTURE_ALPHA_MASK : GL_TEXTURE_PARAM_ENUM = (1 shl 29); + TEXGEN_OFF : GL_TEXTURE_PARAM_ENUM = (0 shl 30); + TEXGEN_TEXCOORD : GL_TEXTURE_PARAM_ENUM = (1 shl 30); + TEXGEN_NORMAL : GL_TEXTURE_PARAM_ENUM = (2 shl 30); + TEXGEN_POSITION : GL_TEXTURE_PARAM_ENUM = (3 shl 30); + + +type + GL_TEXTURE_TYPE_ENUM = cint32; +const + GL_RGB32_A3 : GL_TEXTURE_TYPE_ENUM = 1; + GL_RGB4 : GL_TEXTURE_TYPE_ENUM = 2; + GL_RGB16 : GL_TEXTURE_TYPE_ENUM = 3; + GL_RGB256 : GL_TEXTURE_TYPE_ENUM = 4; + GL_COMPRESSED : GL_TEXTURE_TYPE_ENUM = 5; + GL_RGB8_A5 : GL_TEXTURE_TYPE_ENUM = 6; + GL_RGBA : GL_TEXTURE_TYPE_ENUM = 7; + GL_RGB : GL_TEXTURE_TYPE_ENUM = 8; + + + +type + DISP3DCNT_ENUM = cint32; +const + GL_TEXTURE_2D : DISP3DCNT_ENUM = (1 shl 0); + GL_TOON_HIGHLIGHT : DISP3DCNT_ENUM = (1 shl 1); + GL_ALPHA_TEST : DISP3DCNT_ENUM = (1 shl 2); + GL_BLEND : DISP3DCNT_ENUM = (1 shl 3); + GL_ANTIALIAS : DISP3DCNT_ENUM = (1 shl 4); + GL_OUTLINE : DISP3DCNT_ENUM = (1 shl 5); + GL_COLOR_UNDERFLOW : DISP3DCNT_ENUM = (1 shl 12); + GL_POLY_OVERFLOW : DISP3DCNT_ENUM = (1 shl 13); + GL_CLEAR_BMP : DISP3DCNT_ENUM = (1 shl 14); + + +//////////////////////////////////////////////////////////// +// glGet constants +//////////////////////////////////////////////////////////// + +type + GL_GET_ENUM = ( + GL_GET_VERTEX_RAM_COUNT, + GL_GET_POLYGON_RAM_COUNT, + GL_GET_MATRIX_VECTOR, + GL_GET_MATRIX_POSITION, + GL_GET_MATRIX_PROJECTION, + GL_GET_MATRIX_CLIP, + GL_GET_TEXTURE_WIDTH, + GL_GET_TEXTURE_HEIGHT + ); + + +type + GLFLUSH_ENUM = cint32; +const + GL_TRANS_MANUALSORT: GLFLUSH_ENUM = (1 shl 0); + GL_WBUFFERING : GLFLUSH_ENUM = (1 shl 1); + +//////////////////////////////////////////////////////////// +// Misc. constants +//////////////////////////////////////////////////////////// + +const + MAX_TEXTURES = 2048; //this should be enough ! but feel free to change + GL_LIGHTING = 1; // no idea what this is for / who defined it + +type + gl_hidden_globals = record + matrixMode: GL_MATRIX_MODE_ENUM; // holds the current Matrix Mode + // holds the current state of the clear color register + clearColor: cuint32; // state of clear color register + // texture globals + textures: array [0..MAX_TEXTURES-1] of cuint32; + activeTexture: cuint32; + nextBlock: pcuint32; + nextPBlock: cuint32; + nameCount: cint; + end; + TGLHiddenGlobals = gl_hidden_globals; + PGLHiddenGlobals = ^gl_hidden_globals; + +var + // Pointer to global data for videoGL + glGlob: PGLHiddenGlobals = nil; + + + +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +//--------------------------------------------------------------------------------- +//Fifo commands +//--------------------------------------------------------------------------------- +function FIFO_COMMAND_PACK(c1,c2,c3,c4: cint): cint; inline; +begin + FIFO_COMMAND_PACK := (((c4) shl 24) or ((c3) shl 16) or ((c2) shl 8) or (c1)); +end; + +function REG2ID(r: pcuint32): cuint8; inline; +begin + REG2ID := cuint8((cuint32(r) - $04000400) shr 2); +end; + +function FIFO_NOP(): cuint8; inline; +begin + FIFO_NOP := REG2ID(GFX_FIFO); +end; + +function FIFO_STATUS(): cuint8; inline; +begin + FIFO_STATUS := REG2ID(GFX_STATUS); +end; + +function FIFO_COLOR(): cuint8; inline; +begin + FIFO_COLOR := REG2ID(GFX_COLOR); +end; + + +function FIFO_VERTEX16(): cuint8; inline; +begin + FIFO_VERTEX16 := REG2ID(GFX_VERTEX16); +end; + +function FIFO_TEX_COORD(): cuint8; inline; +begin + FIFO_TEX_COORD := REG2ID(GFX_TEX_COORD); +end; + +function FIFO_TEX_FORMAT(): cuint8; inline; +begin + FIFO_TEX_FORMAT := REG2ID(GFX_TEX_FORMAT); +end; + +function FIFO_PAL_FORMAT(): cuint8; inline; +begin + FIFO_PAL_FORMAT := REG2ID(GFX_PAL_FORMAT); +end; + + +function FIFO_CLEAR_COLOR(): cuint8; inline; +begin + FIFO_CLEAR_COLOR := REG2ID(GFX_CLEAR_COLOR); +end; + +function FIFO_CLEAR_DEPTH(): cuint8; inline; +begin + FIFO_CLEAR_DEPTH := REG2ID(pcuint32(GFX_CLEAR_DEPTH)); +end; + + +function FIFO_LIGHT_VECTOR(): cuint8; inline; +begin + FIFO_LIGHT_VECTOR := REG2ID(GFX_LIGHT_VECTOR); +end; + +function FIFO_LIGHT_COLOR(): cuint8; inline; +begin + FIFO_LIGHT_COLOR := REG2ID(GFX_LIGHT_COLOR); +end; + +function FIFO_NORMAL(): cuint8; inline; +begin + FIFO_NORMAL := REG2ID(GFX_NORMAL); +end; + +function FIFO_DIFFUSE_AMBIENT(): cuint8; inline; +begin + FIFO_DIFFUSE_AMBIENT := REG2ID(GFX_DIFFUSE_AMBIENT); +end; + +function FIFO_SPECULAR_EMISSION(): cuint8; inline; +begin + FIFO_SPECULAR_EMISSION := REG2ID(GFX_SPECULAR_EMISSION); +end; + +function FIFO_SHININESS(): cuint8; inline; +begin + FIFO_SHININESS := REG2ID(GFX_SHININESS); +end; + + +function FIFO_POLY_FORMAT(): cuint8; inline; +begin + FIFO_POLY_FORMAT := REG2ID(GFX_POLY_FORMAT); +end; + + +function FIFO_BEGIN(): cuint8; inline; +begin + FIFO_BEGIN := REG2ID(GFX_BEGIN); +end; + +function FIFO_END(): cuint8; inline; +begin + FIFO_END := REG2ID(GFX_END); +end; + +function FIFO_FLUSH(): cuint8; inline; +begin + FIFO_FLUSH := REG2ID(GFX_FLUSH); +end; + +function FIFO_VIEWPORT(): cuint8; inline; +begin + FIFO_VIEWPORT := REG2ID(GFX_VIEWPORT); +end; + +{ $define FIFO_NOP := REG2ID(GFX_FIFO)} +{ $define FIFO_STATUS := REG2ID(GFX_STATUS)} +{ $define FIFO_COLOR := REG2ID(GFX_COLOR)} + +{ $define FIFO_VERTEX16 := REG2ID(GFX_VERTEX16)} +{ $define FIFO_TEX_COORD := REG2ID(GFX_TEX_COORD)} +{ $define FIFO_TEX_FORMAT := REG2ID(GFX_TEX_FORMAT)} +{ $define FIFO_PAL_FORMAT := REG2ID(GFX_PAL_FORMAT)} + +{ $define FIFO_CLEAR_COLOR := REG2ID(GFX_CLEAR_COLOR)} +{ $define FIFO_CLEAR_DEPTH := REG2ID(GFX_CLEAR_DEPTH)} + +{ $define FIFO_LIGHT_VECTOR := REG2ID(GFX_LIGHT_VECTOR)} +{ $define FIFO_LIGHT_COLOR := REG2ID(GFX_LIGHT_COLOR)} +{ $define FIFO_NORMAL := REG2ID(GFX_NORMAL)} + +{ $define FIFO_DIFFUSE_AMBIENT := REG2ID(GFX_DIFFUSE_AMBIENT)} +{ $define FIFO_SPECULAR_EMISSION := REG2ID(GFX_SPECULAR_EMISSION)} +{ $define FIFO_SHININESS := REG2ID(GFX_SHININESS)} + +{ $define FIFO_POLY_FORMAT := REG2ID(GFX_POLY_FORMAT)} + +{ $define FIFO_BEGIN := REG2ID(GFX_BEGIN)} +{ $define FIFO_END := REG2ID(GFX_END)} +{ $define FIFO_FLUSH := REG2ID(GFX_FLUSH)} +{ $define FIFO_VIEWPORT := REG2ID(GFX_VIEWPORT)} +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} + + +//--------------------------------------------------------------------------------- +//float wrappers for porting +//--------------------------------------------------------------------------------- + +procedure glRotatef32i(angle: cint; x, y, z: cint32); cdecl; external; +function glTexImage2D(target, empty1: cint; _type: GL_TEXTURE_TYPE_ENUM; sizeX, sizeY, empty2, param: cint; texture: pcuint8): cint; cdecl; external; +procedure glTexLoadPal(const pal: pcuint16; count: cuint16; addr: cuint32); cdecl; external; +function gluTexLoadPal(const pal: pcuint16; count: cuint16; format: cuint8): cint; cdecl; external; +procedure glTexParameter(sizeX, sizeY: cuint8; const addr: pcuint32; mode: GL_TEXTURE_TYPE_ENUM; param: cuint32); cdecl; external; +function glGetTexParameter(): cuint32; cdecl; external; +function glGetTexturePointer(name: cint): pointer; cdecl; external; +procedure glBindTexture(target, name: cint); cdecl; external; +procedure glColorTable(format: cuint8; addr: cuint32); cdecl; external; +function glGenTextures(n: cint; names: pcint): cint; cdecl; external; +procedure glResetTextures(); cdecl; external; +procedure glTexCoord2f32(u, v: cint32); cdecl; external; +procedure glMaterialf(mode: GL_MATERIALS_ENUM; color: rgb); cdecl; external; +procedure glInit_C(); cdecl; external; +function glGetGlobals(): PGLHiddenGlobals; cdecl; external; +{$endif NDS_INTERFACE} + + + + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +//////////// //////////// +//////////// //////////// +//////////// //////////// +//////////// INLINED FUNCTIONS //////////// +//////////// //////////// +//////////// //////////// +//////////// //////////// +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +{$ifdef NDS_IMPLEMENTATION} +function POLY_ALPHA(n: cint): cuint32; inline; +begin + POLY_ALPHA := cuint32((n) shl 16); +end; + +function POLY_ID(n: cint): cuint32; inline; +begin + POLY_ID := cuint32((n) shl 24); +end; + +procedure glBegin(mode: GL_GLBEGIN_ENUM); inline; +begin + GFX_BEGIN^ := mode; +end; + +procedure glEnd(); inline; +begin + GFX_END^ := 0; +end; + +procedure glClearDepth(depth: fixed12d3); inline; +begin + GFX_CLEAR_DEPTH^ := depth; +end; + +procedure glColor3b(red, green, blue: cuint8); inline; +begin + GFX_COLOR^ := cuint32(RGB15(red shr 3, green shr 3, blue shr 3)); +end; + +procedure glColor(color: rgb); inline; +begin + GFX_COLOR^ := cuint32(color); +end; + +procedure glVertex3v16(x, y, z: v16); inline; +begin + GFX_VERTEX16^ := cuint32((y shl 16) or (x and $FFFF)); + GFX_VERTEX16^ := cuint32(cuint16(z)); +end; + +procedure glTexCoord2t16(u, v: t16); inline; +begin + GFX_TEX_COORD^ := TEXTURE_PACK(u, v); +end; + +procedure glPushMatrix(); inline; +begin + MATRIX_PUSH^ := 0; +end; + +procedure glPopMatrix(num: cint32); inline; +begin + MATRIX_POP^ := num; +end; + +procedure glRestoreMatrix(index: cint32); inline; +begin + MATRIX_RESTORE^ := index; +end; + +procedure glStoreMatrix(index: cint32); inline; +begin + MATRIX_STORE^ := index; +end; + +procedure glScalev(const v: PGLvector); inline; +begin + MATRIX_SCALE^ := v^.x; + MATRIX_SCALE^ := v^.y; + MATRIX_SCALE^ := v^.z; +end; + + +procedure glTranslatev(const v: PGLvector) ; inline; +begin + MATRIX_TRANSLATE^ := v^.x; + MATRIX_TRANSLATE^ := v^.y; + MATRIX_TRANSLATE^ := v^.z; +end; + +procedure glTranslate3f32(x, y, z: cint32); inline; +begin + MATRIX_TRANSLATE^ := x; + MATRIX_TRANSLATE^ := y; + MATRIX_TRANSLATE^ := z; +end; + +procedure glScalef32(factor: cint32); inline; +begin + MATRIX_SCALE^ := factor; + MATRIX_SCALE^ := factor; + MATRIX_SCALE^ := factor; +end; + +procedure glLight(id: cint; color: rgb; x, y, z: v10); inline; +begin + id := (id and 3) shl 30; + GFX_LIGHT_VECTOR^ := id or ((z and $3FF) shl 20) or ((y and $3FF) shl 10) or (x and $3FF); + GFX_LIGHT_COLOR^ := id or color; +end; + +procedure glNormal(normal: cuint32); inline; +begin + GFX_NORMAL^ := normal; +end; + +procedure glLoadIdentity(); inline; +begin + MATRIX_IDENTITY^ := 0; +end; + +procedure glIdentity(); inline; +begin + MATRIX_IDENTITY^ := 0; +end; + +procedure glMatrixMode(mode: GL_MATRIX_MODE_ENUM); inline; +begin + MATRIX_CONTROL^ := mode; +end; + +procedure glViewport(x1, y1, x2, y2: cuint8); inline; +begin + GFX_VIEWPORT^ := (x1) + (y1 shl 8) + (x2 shl 16) + (y2 shl 24); +end; + +procedure glFlush(mode: cuint32); inline; +begin + GFX_FLUSH^ := mode; +end; + +procedure glMaterialShinyness(); inline; +var + shiny32: array [0..31] of cuint32; + shiny8: pcuint8; + i: integer; +begin + shiny8 := pcuint8(@shiny32); + + i := 0; + while i < (128 * 2) do + begin + shiny8[i shr 1] := i; + inc(i, 2); + end; + + for i := 0 to 31 do + GFX_SHININESS[i] := shiny32[i]; +end; + + +procedure glCallList(list: pcuint32); inline; +var + count: cuint32; +begin + count := list^; + inc(list); + DC_FlushRange(list, count*4); + while ( ((DMA_CR(0)^ and DMA_BUSY) <> 0) or + ((DMA_CR(1)^ and DMA_BUSY) <> 0) or + ((DMA_CR(2)^ and DMA_BUSY) <> 0) or + ((DMA_CR(3)^ and DMA_BUSY) <> 0)) do; + + DMA_SRC(0)^ := cuint32(list); + DMA_DEST(0)^ := $4000400; + DMA_CR(0)^ := DMA_FIFO or count; + while (DMA_CR(0)^ and DMA_BUSY) <> 0 do; +end; + +procedure glPolyFmt(params: cuint32); inline; +begin + GFX_POLY_FORMAT^ := params; +end; +//////////////////////////////////////////////////////////////// + +procedure glEnable(bits: cint); inline; +begin + GFX_CONTROL^ := GFX_CONTROL^ or bits; +end; + +procedure glDisable(bits: cint); inline; +begin + GFX_CONTROL^ := GFX_CONTROL^ and not bits; +end; + +procedure glLoadMatrix4x4(const m: pm4x4); inline; +begin + MATRIX_LOAD4x4^ := m^.m[0]; + MATRIX_LOAD4x4^ := m^.m[1]; + MATRIX_LOAD4x4^ := m^.m[2]; + MATRIX_LOAD4x4^ := m^.m[3]; + + MATRIX_LOAD4x4^ := m^.m[4]; + MATRIX_LOAD4x4^ := m^.m[5]; + MATRIX_LOAD4x4^ := m^.m[6]; + MATRIX_LOAD4x4^ := m^.m[7]; + + MATRIX_LOAD4x4^ := m^.m[8]; + MATRIX_LOAD4x4^ := m^.m[9]; + MATRIX_LOAD4x4^ := m^.m[10]; + MATRIX_LOAD4x4^ := m^.m[11]; + + MATRIX_LOAD4x4^ := m^.m[12]; + MATRIX_LOAD4x4^ := m^.m[13]; + MATRIX_LOAD4x4^ := m^.m[14]; + MATRIX_LOAD4x4^ := m^.m[15]; +end; + + +procedure glLoadMatrix4x3(const m: pm4x3); inline; +begin + MATRIX_LOAD4x3^ := m^.m[0]; + MATRIX_LOAD4x3^ := m^.m[1]; + MATRIX_LOAD4x3^ := m^.m[2]; + MATRIX_LOAD4x3^ := m^.m[3]; + + MATRIX_LOAD4x3^ := m^.m[4]; + MATRIX_LOAD4x3^ := m^.m[5]; + MATRIX_LOAD4x3^ := m^.m[6]; + MATRIX_LOAD4x3^ := m^.m[7]; + + MATRIX_LOAD4x3^ := m^.m[8]; + MATRIX_LOAD4x3^ := m^.m[9]; + MATRIX_LOAD4x3^ := m^.m[10]; + MATRIX_LOAD4x3^ := m^.m[11]; +end; + + +procedure glMultMatrix4x4(const m: pm4x4); inline; +begin + MATRIX_MULT4x4^ := m^.m[0]; + MATRIX_MULT4x4^ := m^.m[1]; + MATRIX_MULT4x4^ := m^.m[2]; + MATRIX_MULT4x4^ := m^.m[3]; + + MATRIX_MULT4x4^ := m^.m[4]; + MATRIX_MULT4x4^ := m^.m[5]; + MATRIX_MULT4x4^ := m^.m[6]; + MATRIX_MULT4x4^ := m^.m[7]; + + MATRIX_MULT4x4^ := m^.m[8]; + MATRIX_MULT4x4^ := m^.m[9]; + MATRIX_MULT4x4^ := m^.m[10]; + MATRIX_MULT4x4^ := m^.m[11]; + + MATRIX_MULT4x4^ := m^.m[12]; + MATRIX_MULT4x4^ := m^.m[13]; + MATRIX_MULT4x4^ := m^.m[14]; + MATRIX_MULT4x4^ := m^.m[15]; +end; + +procedure glMultMatrix4x3(const m: pm4x3); inline; +begin + MATRIX_MULT4x3^ := m^.m[0]; + MATRIX_MULT4x3^ := m^.m[1]; + MATRIX_MULT4x3^ := m^.m[2]; + MATRIX_MULT4x3^ := m^.m[3]; + + MATRIX_MULT4x3^ := m^.m[4]; + MATRIX_MULT4x3^ := m^.m[5]; + MATRIX_MULT4x3^ := m^.m[6]; + MATRIX_MULT4x3^ := m^.m[7]; + + MATRIX_MULT4x3^ := m^.m[8]; + MATRIX_MULT4x3^ := m^.m[9]; + MATRIX_MULT4x3^ := m^.m[10]; + MATRIX_MULT4x3^ := m^.m[11]; +end; + +procedure glMultMatrix3x3(const m: pm3x3); inline; +begin + MATRIX_MULT3x3^ := m^.m[0]; + MATRIX_MULT3x3^ := m^.m[1]; + MATRIX_MULT3x3^ := m^.m[2]; + + MATRIX_MULT3x3^ := m^.m[3]; + MATRIX_MULT3x3^ := m^.m[4]; + MATRIX_MULT3x3^ := m^.m[5]; + + MATRIX_MULT3x3^ := m^.m[6]; + MATRIX_MULT3x3^ := m^.m[7]; + MATRIX_MULT3x3^ := m^.m[8]; +end; + +procedure glRotateXi(angle: cint); inline; +var + sine, cosine: cint32; +begin + sine := _SIN[angle and LUT_MASK]; + cosine := _COS[angle and LUT_MASK]; + + MATRIX_MULT3x3^ := inttof32(1); + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := 0; + + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := cosine; + MATRIX_MULT3x3^ := sine; + + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := -sine; + MATRIX_MULT3x3^ := cosine; +end; + +procedure glRotateYi(angle: cint); inline; +var + sine, cosine: cint32; +begin + sine := _SIN[angle and LUT_MASK]; + cosine := _COS[angle and LUT_MASK]; + + MATRIX_MULT3x3^ := cosine; + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := -sine; + + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := inttof32(1); + MATRIX_MULT3x3^ := 0; + + MATRIX_MULT3x3^ := sine; + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := cosine; +end; + +procedure glRotateZi(angle: cint); inline; +var + sine, cosine: cint32; +begin + sine := _SIN[angle and LUT_MASK]; + cosine := _COS[angle and LUT_MASK]; + + MATRIX_MULT3x3^ := cosine; + MATRIX_MULT3x3^ := sine; + MATRIX_MULT3x3^ := 0; + + MATRIX_MULT3x3^ := -sine; + MATRIX_MULT3x3^ := cosine; + MATRIX_MULT3x3^ := 0; + + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := 0; + MATRIX_MULT3x3^ := inttof32(1); +end; + +procedure glOrthof32(left, right, bottom, top, zNear, zFar: cint32); inline; +begin + MATRIX_MULT4x4^ := divf32(inttof32(2), right - left); + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := divf32(inttof32(2), top - bottom); + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := divf32(inttof32(-2), zFar - zNear); + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := -divf32(right + left, right - left);//0; + MATRIX_MULT4x4^ := -divf32(top + bottom, top - bottom); //0; + MATRIX_MULT4x4^ := -divf32(zFar + zNear, zFar - zNear);//0; + MATRIX_MULT4x4^ := floattof32(1.0); + + //glStoreMatrix(0); +end; + +procedure gluLookAtf32(eyex, eyey, eyez, lookAtx, lookAty, lookAtz, upx, upy, upz: cint32); inline; +var + side, forwrd, up, eye: array [0..2] of cint32; +begin + + forwrd[0] := eyex - lookAtx; + forwrd[1] := eyey - lookAty; + forwrd[2] := eyez - lookAtz; + + normalizef32(@forwrd); + + up[0] := upx; + up[1] := upy; + up[2] := upz; + eye[0] := eyex; + eye[1] := eyey; + eye[2] := eyez; + + crossf32(@up, @forwrd, @side); + + normalizef32(@side); + + // Recompute local up + crossf32(@forwrd, @side, @up); + + glMatrixMode(GL_MODELVIEW); + + + // should we use MATRIX_MULT4x3? + MATRIX_MULT4x3^ := side[0]; + MATRIX_MULT4x3^ := up[0]; + MATRIX_MULT4x3^ := forwrd[0]; + + MATRIX_MULT4x3^ := side[1]; + MATRIX_MULT4x3^ := up[1]; + MATRIX_MULT4x3^ := forwrd[1]; + + MATRIX_MULT4x3^ := side[2]; + MATRIX_MULT4x3^ := up[2]; + MATRIX_MULT4x3^ := forwrd[2]; + + MATRIX_MULT4x3^ := -dotf32(@eye,@side); + MATRIX_MULT4x3^ := -dotf32(@eye,@up); + MATRIX_MULT4x3^ := -dotf32(@eye,@forwrd); +end; + +procedure glFrustumf32(left, right, bottom, top, zNear, zFar: cint32); inline; +begin +(* + MATRIX_MULT4x4^ := divf32(2*znear, right - left); + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := divf32(right + left, right - left); + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := divf32(2*znear, top - bottom); + MATRIX_MULT4x4^ := divf32(top + bottom, top - bottom); + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := -divf32(zfar + znear, zfar - znear); + MATRIX_MULT4x4^ := floattof32(-1.0); + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := -divf32(2 * mulf32(zfar, znear), zfar - znear); + MATRIX_MULT4x4^ := 0; +*) + MATRIX_MULT4x4^ := divf32(2*znear, right - left); + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := divf32(2*znear, top - bottom); + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := divf32(right + left, right - left); + MATRIX_MULT4x4^ := divf32(top + bottom, top - bottom); + MATRIX_MULT4x4^ := -divf32(zfar + znear, zfar - znear); + MATRIX_MULT4x4^ := floattof32(-1.0); + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := -divf32(2 * mulf32(zfar, znear), zfar - znear); + MATRIX_MULT4x4^ := 0; +end; + +procedure gluPerspectivef32(fovy: cint; aspect, zNear, zFar: cint32); inline; +var + xmin, xmax, ymin, ymax: cint32; +begin + ymax := mulf32(zNear, TAN_bin[(fovy shr 1) and LUT_MASK]); + ymin := -ymax; + xmin := mulf32(ymin, aspect); + xmax := mulf32(ymax, aspect); + + glFrustumf32(xmin, xmax, ymin, ymax, zNear, zFar); +end; + +procedure glTexCoord2f(s, t: cfloat); inline; +var + x, y: cint; +begin + x := ((glGlob^.textures[glGlob^.activeTexture]) shr 20) and 7; + y := ((glGlob^.textures[glGlob^.activeTexture]) shr 23) and 7; + + glTexCoord2t16(floattot16(s*(8 shl x)), floattot16(t*(8 shl y))); +end; + +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +type + TArr4ofInt = array [0..3] of cint32; +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +procedure gluPickMatrix(x, y, width, height: cint32; const viewport: TArr4ofInt); inline; +begin + MATRIX_MULT4x4^ := inttof32(viewport[2]) div width; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := inttof32(viewport[3]) div height; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := inttof32(1); + MATRIX_MULT4x4^ := 0; + + MATRIX_MULT4x4^ := inttof32(viewport[2] + ((viewport[0] - x) shl 1)) div width; + MATRIX_MULT4x4^ := inttof32(viewport[3] + ((viewport[1] - y) shl 1)) div height; + MATRIX_MULT4x4^ := 0; + MATRIX_MULT4x4^ := inttof32(1); +end; + +procedure glResetMatrixStack(); inline; +begin + // make sure there are no push/pops that haven't executed yet + while (GFX_STATUS^ and (1 shl 14)) <> 0 do + begin + GFX_STATUS^ := GFX_STATUS^ or (1 shl 15); // clear push/pop errors or push/pop busy bit never clears + end; + + // pop the projection stack to the top; poping 0 off an empty stack causes an error... weird? + if (GFX_STATUS^ and (1 shl 13)) <> 0 then + begin + glMatrixMode(GL_PROJECTION); + glPopMatrix(1); + end; + + // 31 deep modelview matrix; 32nd entry works but sets error flag + glMatrixMode(GL_MODELVIEW); + glPopMatrix((GFX_STATUS^ shr 8) and $1F); + + // load identity to all the matrices + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); +end; + +procedure glSetOutlineColor(id: cint; color: rgb); inline; +begin + GFX_EDGE_TABLE[id] := cuint16(color); +end; + +procedure glSetToonTable(const table: pcuint16); inline; +var + i: integer; +begin + for i := 0 to 31 do + GFX_TOON_TABLE[i] := table[i]; +end; + +procedure glSetToonTableRange(_start, _end: cint; color: rgb); inline; +var + i: integer; +begin + for i := _start to _end do + GFX_TOON_TABLE[i] := cuint16(color); +end; + +procedure glGetFixed(const param: GL_GET_ENUM; f: pcint32); inline; +var + i: integer; +begin + case param of + GL_GET_MATRIX_VECTOR: + begin + while (GFX_BUSY) do; // wait until the graphics engine has stopped to read matrixes + for i := 0 to 8 do + f[i] := MATRIX_READ_VECTOR[i]; + end; + GL_GET_MATRIX_CLIP: + begin + while (GFX_BUSY) do; // wait until the graphics engine has stopped to read matrixes + for i := 0 to 15 do + f[i] := MATRIX_READ_CLIP[i]; + end; + GL_GET_MATRIX_PROJECTION: + begin + glMatrixMode(GL_POSITION); + glPushMatrix(); // save the current state of the position matrix + glLoadIdentity(); // load an identity matrix into the position matrix so that the modelview matrix = projection matrix + while (GFX_BUSY) do; // wait until the graphics engine has stopped to read matrixes + for i := 0 to 15 do + f[i] := MATRIX_READ_CLIP[i]; // read out the projection matrix + glPopMatrix(1); // restore the position matrix + end; + GL_GET_MATRIX_POSITION: + begin + glMatrixMode(GL_PROJECTION); + glPushMatrix(); // save the current state of the projection matrix + glLoadIdentity(); // load a identity matrix into the projection matrix so that the modelview matrix = position matrix + while (GFX_BUSY) do; // wait until the graphics engine has stopped to read matrixes + for i := 0 to 15 do + f[i] := MATRIX_READ_CLIP[i]; // read out the position matrix + glPopMatrix(1); // restore the projection matrix + end; + end; +end; + +procedure glAlphaFunc(alphaThreshold: cint); inline; +begin + GFX_ALPHA_TEST^ := alphaThreshold; +end; + +procedure glCutoffDepth(wVal: fixed12d3); inline; +begin + GFX_CUTOFF_DEPTH^ := wVal; +end; + +procedure glInit(); inline; +begin + glGlob := glGetGlobals(); // make sure globals are synced between compilation units + glInit_C(); // actually does the initialization +end; + +procedure glClearColor(red, green, blue, alpha: cuint8); inline; +begin + GFX_CLEAR_COLOR^ := (glGlob^.clearColor and $FFE08000) or ($7FFF and RGB15(red, green, blue)) or ((alpha and $1F) shl 16); + glGlob^.clearColor := GFX_CLEAR_COLOR^; +end; + +procedure glClearPolyID(ID: cuint8); inline; +begin + GFX_CLEAR_COLOR^ := ( glGlob^.clearColor and $C0FFFFFF) or (( ID and $3F ) shl 24 ); + glGlob^.clearColor := GFX_CLEAR_COLOR^; +end; + +procedure glGetInt(param: GL_GET_ENUM; var i: cint); inline; +begin + case param of + GL_GET_POLYGON_RAM_COUNT: + i := GFX_POLYGON_RAM_USAGE^; + GL_GET_VERTEX_RAM_COUNT: + i := GFX_VERTEX_RAM_USAGE^; + GL_GET_TEXTURE_WIDTH: + i := 8 shl (((glGlob^.textures[glGlob^.activeTexture]) shr 20) and 7); + GL_GET_TEXTURE_HEIGHT: + i := 8 shl (((glGlob^.textures[glGlob^.activeTexture]) shr 23) and 7); + end; +end; + +//--------------------------------------------------------------------------------- +// INLINED FlOAT WRAPPERS + +procedure glVertex3f(x, y, z: cfloat); inline; +begin + glVertex3v16(floattov16(x), floattov16(y), floattov16(z)); +end; + +procedure glRotatef32(angle: cfloat; x, y, z: cint32); inline; +begin + glRotatef32i(trunc(angle * LUT_SIZE / 360.0), x, y, z); +end; + +procedure glRotatef(angle, x, y, z: cfloat); inline; +begin + glRotatef32(angle, floattof32(x), floattof32(y), floattof32(z)); +end; + +procedure glColor3f(r, g, b: cfloat); inline; +begin + glColor3b(trunc(r*255), trunc(g*255), trunc(b*255)); +end; + +procedure glScalef(x, y, z: cfloat); inline; +begin + MATRIX_SCALE^ := floattof32(x); + MATRIX_SCALE^ := floattof32(y); + MATRIX_SCALE^ := floattof32(z); +end; + +procedure glTranslatef(x, y, z: cfloat); inline; +begin + MATRIX_TRANSLATE^ := floattof32(x); + MATRIX_TRANSLATE^ := floattof32(y); + MATRIX_TRANSLATE^ := floattof32(z); +end; + +procedure glNormal3f(x, y, z: cfloat); inline; +begin + glNormal(NORMAL_PACK(floattov10(x), floattov10(y), floattov10(z))); +end; + +procedure glRotateX(angle: cfloat); inline; +begin + glRotateXi(trunc(angle * LUT_SIZE / 360.0)); +end; + +procedure glRotateY(angle: cfloat); inline; +begin + glRotateYi(trunc(angle * LUT_SIZE / 360.0)); +end; + +procedure glRotateZ(angle: cfloat); inline; +begin + glRotateZi(trunc(angle * LUT_SIZE / 360.0)); +end; + +procedure glOrtho(left, right, bottom, top, zNear, zFar: cfloat); inline; +begin + glOrthof32(floattof32(left), floattof32(right), floattof32(bottom), floattof32(top), floattof32(zNear), floattof32(zFar)); +end; + +procedure gluLookAt(eyex, eyey, eyez, lookAtx, lookAty, lookAtz, upx, upy, upz: cfloat); inline; +begin + gluLookAtf32(floattof32(eyex), floattof32(eyey), floattof32(eyez), + floattof32(lookAtx), floattof32(lookAty), floattof32(lookAtz), + floattof32(upx), floattof32(upy), floattof32(upz)); +end; + +procedure glFrustum(left, right, bottom, top, znear, zfar: cfloat); inline; +begin + glFrustumf32(floattof32(left), floattof32(right), floattof32(bottom), floattof32(top), floattof32(znear), floattof32(zfar)); +end; + +procedure gluPerspective(fovy, aspect, zNear, zFar: cfloat); inline; +begin + gluPerspectivef32(trunc(fovy * LUT_SIZE / 360.0), floattof32(aspect), floattof32(zNear), floattof32(zFar)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +function int_to_12d3(n: cint): fixed12d3; inline; +function float_to_12d3(n: cfloat): fixed12d3; inline; +function inttof32(n: cint): cint32; inline; +function f32toint(n: cint32): cint; inline; +function floattof32(n: cfloat): cint32; inline; +function f32tofloat(n: cint32): cfloat; inline; +function f32tot16(n: cint32): t16; inline; +function inttot16(n: cint): cint32; inline; //??? +function t16toint(n: t16): cint; inline; +function floattot16(n: cfloat): t16; inline; +function TEXTURE_PACK(u, v: cint): cint; inline; +function inttov16(n: cint): cint; inline; +function f32tov16(n: cint32): v16; inline; +function v16toint(n: v16): cint; inline; +function floattov16(n: cfloat): v16; inline; +function VERTEX_PACK(x,y: cint): cint; inline; +function inttov10(n: cint): cint; inline; +function f32tov10(n: cint32): cint; inline; +function v10toint(n: v10): cint; inline; +function floattov10(n: cfloat): v10; inline; +function NORMAL_PACK(x,y,z: cint): cint; inline; +function FIFO_COMMAND_PACK(c1,c2,c3,c4: cint): cint; inline; +function REG2ID(r: pcuint32): cuint8; inline; +function FIFO_NOP(): cuint8; inline; +function FIFO_STATUS(): cuint8; inline; +function FIFO_COLOR(): cuint8; inline; +function FIFO_VERTEX16(): cuint8; inline; +function FIFO_TEX_COORD(): cuint8; inline; +function FIFO_TEX_FORMAT(): cuint8; inline; +function FIFO_PAL_FORMAT(): cuint8; inline; +function FIFO_CLEAR_COLOR(): cuint8; inline; +function FIFO_CLEAR_DEPTH(): cuint8; inline; +function FIFO_LIGHT_VECTOR(): cuint8; inline; +function FIFO_LIGHT_COLOR(): cuint8; inline; +function FIFO_NORMAL(): cuint8; inline; +function FIFO_DIFFUSE_AMBIENT(): cuint8; inline; +function FIFO_SPECULAR_EMISSION(): cuint8; inline; +function FIFO_SHININESS(): cuint8; inline; +function FIFO_POLY_FORMAT(): cuint8; inline; +function FIFO_BEGIN(): cuint8; inline; +function FIFO_END(): cuint8; inline; +function FIFO_FLUSH(): cuint8; inline; +function FIFO_VIEWPORT(): cuint8; inline; +function POLY_ALPHA(n: cint): cuint32; inline; +function POLY_ID(n: cint): cuint32; inline; +procedure glBegin(mode: GL_GLBEGIN_ENUM); inline; +procedure glEnd(); inline; +procedure glClearDepth(depth: fixed12d3); inline; +procedure glColor3b(red, green, blue: cuint8); inline; +procedure glColor(color: rgb); inline; +procedure glVertex3v16(x, y, z: v16); inline; +procedure glTexCoord2t16(u, v: t16); inline; +procedure glPushMatrix(); inline; +procedure glPopMatrix(num: cint32); inline; +procedure glRestoreMatrix(index: cint32); inline; +procedure glStoreMatrix(index: cint32); inline; +procedure glScalev(const v: PGLvector); inline; +procedure glTranslatev(const v: PGLvector) ; inline; +procedure glTranslate3f32(x, y, z: cint32); inline; +procedure glScalef32(factor: cint32); inline; +procedure glLight(id: cint; color: rgb; x, y, z: v10); inline; +procedure glNormal(normal: cuint32); inline; +procedure glLoadIdentity(); inline; +procedure glIdentity(); inline; +procedure glMatrixMode(mode: GL_MATRIX_MODE_ENUM); inline; +procedure glViewport(x1, y1, x2, y2: cuint8); inline; +procedure glFlush(mode: cuint32); inline; +procedure glMaterialShinyness(); inline; +procedure glCallList(list: pcuint32); inline; +procedure glPolyFmt(params: cuint32); inline; +procedure glEnable(bits: cint); inline; +procedure glDisable(bits: cint); inline; +procedure glLoadMatrix4x4(const m: pm4x4); inline; +procedure glLoadMatrix4x3(const m: pm4x3); inline; +procedure glMultMatrix4x4(const m: pm4x4); inline; +procedure glMultMatrix4x3(const m: pm4x3); inline; +procedure glMultMatrix3x3(const m: pm3x3); inline; +procedure glRotateXi(angle: cint); inline; +procedure glRotateYi(angle: cint); inline; +procedure glRotateZi(angle: cint); inline; +procedure glOrthof32(left, right, bottom, top, zNear, zFar: cint32); inline; +procedure gluLookAtf32(eyex, eyey, eyez, lookAtx, lookAty, lookAtz, upx, upy, upz: cint32); inline; +procedure glFrustumf32(left, right, bottom, top, zNear, zFar: cint32); inline; +procedure gluPerspectivef32(fovy: cint; aspect, zNear, zFar: cint32); inline; +procedure gluPickMatrix(x, y, width, height: cint32; const viewport: TArr4ofInt); inline; +procedure glResetMatrixStack(); inline; +procedure glSetOutlineColor(id: cint; color: rgb); inline; +procedure glSetToonTable(const table: pcuint16); inline; +procedure glSetToonTableRange(_start, _end: cint; color: rgb); inline; +procedure glGetFixed(const param: GL_GET_ENUM; f: pcint32); inline; +procedure glAlphaFunc(alphaThreshold: cint); inline; +procedure glCutoffDepth(wVal: fixed12d3); inline; +procedure glInit(); inline; +procedure glClearColor(red, green, blue, alpha: cuint8); inline; +procedure glClearPolyID(ID: cuint8); inline; +procedure glGetInt(param: GL_GET_ENUM; var i: cint); inline; +procedure glVertex3f(x, y, z: cfloat); inline; +procedure glRotatef32(angle: cfloat; x, y, z: cint32); inline; +procedure glRotatef(angle, x, y, z: cfloat); inline; +procedure glColor3f(r, g, b: cfloat); inline; +procedure glScalef(x, y, z: cfloat); inline; +procedure glTranslatef(x, y, z: cfloat); inline; +procedure glNormal3f(x, y, z: cfloat); inline; +procedure glRotateX(angle: cfloat); inline; +procedure glRotateY(angle: cfloat); inline; +procedure glRotateZ(angle: cfloat); inline; +procedure glOrtho(left, right, bottom, top, zNear, zFar: cfloat); inline; +procedure gluLookAt(eyex, eyey, eyez, lookAtx, lookAty, lookAtz, upx, upy, upz: cfloat); inline; +procedure glFrustum(left, right, bottom, top, znear, zfar: cfloat); inline; +procedure gluPerspective(fovy, aspect, zNear, zFar: cfloat); inline; +procedure glTexCoord2f(s, t: cfloat); inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/bios.inc b/packages/libndsfpc/src/nds/bios.inc new file mode 100644 index 0000000000..9796342148 --- /dev/null +++ b/packages/libndsfpc/src/nds/bios.inc @@ -0,0 +1,125 @@ +(* + $Id: bios.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} + +type + TGetSize = function(source: pcuint8; dest: pcuint16; r2: cuint32): pcint; + TGetResult = function(source: pcuint8): pcint; + TReadByte = function(source: pcuint8): pcuint8; + + +type + DecompressionStream = packed record + getSize: TGetSize; + getResult: TGetResult; + readByte: TReadByte; + end; + TDecompressionStream = DecompressionStream; + PDecompressionStream = ^TDecompressionStream; + + UnpackStruct = packed record + sourceSize: cuint16; // in bytes + sourceWidth: cuint8; + destWidth: cuint8; + dataOffset: cuint32; + end; + TUnpackStruct = UnpackStruct; + PUnpackStruct = ^TUnpackStruct; + + +procedure swiSoftReset(); cdecl; external; + +procedure swiDelay(duration: cuint32); cdecl; external; + +procedure swiIntrWait(waitForSet: cint; flags: cuint32); cdecl; external; + +procedure swiWaitForVBlank(); cdecl; external; + +function swiDivide(numerator, divisor: cint): cint; cdecl; external; +function swiRemainder(numerator, divisor: cint): cint; cdecl; external; +procedure swiDivMod(numerator, divisor: cint; result, remainder: pcint); cdecl; external; + +const + COPY_MODE_HWORD = (0); + COPY_MODE_WORD = (1 shl 26); + COPY_MODE_COPY = (0); + COPY_MODE_FILL = (1 shl 24); + +procedure swiCopy(const source: pointer; dest: pointer; flags: cint); cdecl; external; +procedure swiFastCopy(const source: pointer; dest: pointer; flags: cint); cdecl; external; + +function swiSqrt(value: cint): cint; cdecl; external; + +function swiCRC16(crc: cuint16; data: pointer; size: cuint32): cuint16; cdecl; external; + +function swiIsDebugger(): cint; cdecl; external; + +procedure swiUnpackBits(source: pcuint8; destination: pcuint32; params: PUnpackStruct); cdecl; external; + +procedure swiDecompressLZSSWram(source, destination: pointer); cdecl; external; +function swiDecompressLZSSVram(source, destination: pointer; toGetSize: cuint32; stream: PDecompressionStream): cint; cdecl; external; + +function swiDecompressHuffman(source, destination: pointer; toGetSize: cuint32; stream: PDecompressionStream): cint; cdecl; external; + +procedure swiDecompressRLEWram(source, destination: pointer); cdecl; external; +function swiDecompressRLEVram(source, destination: pointer; toGetSize: cuint32; stream: PDecompressionStream): cint; cdecl; external; +{$endif NDS_INTERFACE} + + +{$ifdef NDS_INTERFACE} +{$ifdef ARM9} +procedure swiWaitForIRQ(); cdecl; external; +procedure swiSetHaltCR(data: cuint32); cdecl; external; +procedure swiDecodeDelta8(source, destination: pointer); cdecl; external; +procedure swiDecodeDelta16(source, destination: pointer); cdecl; external; +{$endif ARM9} + +{$ifdef ARM7} +procedure swiHalt(); cdecl; external; +procedure swiSleep(); cdecl; external; +procedure swiSwitchToGBAMode(); cdecl; external; +procedure swiSetHaltCR(data: cuint8); cdecl; external; +function swiGetSineTable(index: cint): cuint16; cdecl; external; +function swiGetPitchTable(index: cint): cuint16; cdecl; external; +function swiGetVolumeTable(index: cint): cuint8; cdecl; external; +procedure swiChangeSoundBias(enabled, delay: cint); cdecl; external; +{$endif ARM7} +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/card.inc b/packages/libndsfpc/src/nds/card.inc new file mode 100644 index 0000000000..8f399d6ae8 --- /dev/null +++ b/packages/libndsfpc/src/nds/card.inc @@ -0,0 +1,101 @@ +(* + $Id: card.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +{$ifdef NDS_INTERFACE} +const + // Card bus + CARD_CR1 : pcuint16 = pointer($040001A0); + CARD_CR1H : pcuint8 = pointer($040001A1); + CARD_EEPDATA : pcuint8 = pointer($040001A2); + CARD_CR2 : pcuint32 = pointer($040001A4); + CARD_COMMAND : pcuint8 = pointer($040001A8); + + CARD_DATA_RD : pcuint32 = pointer($04100010); + + CARD_1B0 : pcuint32 = pointer($040001B0); + CARD_1B4 : pcuint32 = pointer($040001B4); + CARD_1B8 : pcuint16 = pointer($040001B8); + CARD_1BA : pcuint16 = pointer($040001BA); + + + CARD_CR1_ENABLE = $80; // in byte 1, i.e. 0x8000 + CARD_CR1_IRQ = $40; // in byte 1, i.e. 0x4000 + + +// CARD_CR2 register: + CARD_ACTIVATE = (1 shl 31); // when writing, get the ball rolling + // 1<<30 + CARD_nRESET = (1 shl 29); // value on the /reset pin (1 = high out, not a reset state, 0 = low out = in reset) + CARD_28 = (1 shl 28); // when writing + CARD_27 = (1 shl 27); // when writing + CARD_26 = (1 shl 26); + CARD_22 = (1 shl 22); + CARD_19 = (1 shl 19); + CARD_ENCRYPTED = (1 shl 14); // when writing, this command should be encrypted + CARD_13 = (1 shl 13); // when writing + CARD_4 = (1 shl 4); // when writing + + // 3 bits in b10..b8 indicate something + // read bits + CARD_BUSY = (1 shl 31); // when reading, still expecting incomming data? + CARD_DATA_READY = (1 shl 23); // when reading, CARD_DATA_RD or CARD_DATA has another word of data and is good to go + + + +procedure cardWriteCommand(const command: pcuint8); cdecl; external; + +procedure cardPolledTransfer(flags: cuint32; destination: pcuint32; length: cuint32; const command: pcuint8); cdecl; external; +procedure cardStartTransfer(const command: pcuint8; destination: pcuint32; channel: cint; flags: cuint32); cdecl; external; +function cardWriteAndRead(const command: pcuint8; flags: cuint32): cuint32; cdecl; external; +procedure cardRead00(address: cuint32; destination: pcuint32; length: cuint32; flags: cuint32); cdecl; external; +procedure cardReadHeader(header: pcuint8); cdecl; external; +function cardReadID(flags: cuint32): cint; cdecl; external; +procedure cardReadEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external; +procedure cardWriteEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external; + +function cardEepromReadID(i: cuint8): cuint8; cdecl; external; +function cardEepromCommand(command: cuint8; address: cuint32): cuint8; cdecl; external; +function cardEepromGetType({void}): cint; cdecl; external; +function cardEepromGetSize(): cuint32; cdecl; external; +procedure cardEepromChipErase({void}); cdecl; external; +procedure cardEepromSectorErase(address: cuint32); cdecl; external; +{$endif NDS_INTERFACE} + diff --git a/packages/libndsfpc/src/nds/dma.inc b/packages/libndsfpc/src/nds/dma.inc new file mode 100644 index 0000000000..4118bb78f8 --- /dev/null +++ b/packages/libndsfpc/src/nds/dma.inc @@ -0,0 +1,206 @@ +(* + $Id: dma.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + + +{$ifdef NDS_INTERFACE} +const + DMA0_SRC : pcuint32 = pointer($040000B0); + DMA0_DEST : pcuint32 = pointer($040000B4); + DMA0_CR : pcuint32 = pointer($040000B8); + + DMA1_SRC : pcuint32 = pointer($040000BC); + DMA1_DEST : pcuint32 = pointer($040000C0); + DMA1_CR : pcuint32 = pointer($040000C4); + + DMA2_SRC : pcuint32 = pointer($040000C8); + DMA2_DEST : pcuint32 = pointer($040000CC); + DMA2_CR : pcuint32 = pointer($040000D0); + + DMA3_SRC : pcuint32 = pointer($040000D4); + DMA3_DEST : pcuint32 = pointer($040000D8); + DMA3_CR : pcuint32 = pointer($040000DC); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function DMA_SRC(n: cint): pcuint32; inline; +begin + DMA_SRC := pcuint32($040000B0 + (n * 12)); +end; + +function DMA_DEST(n: cint): pcuint32; inline; +begin + DMA_DEST := pcuint32($040000B4 + (n * 12)); +end; + +function DMA_CR(n: cint): pcuint32; inline; +begin + DMA_CR := pcuint32($040000B8 + (n * 12)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +// DMA control register contents +// The defaults are 16-bit, increment source/dest addresses, no irq +const + DMA_ENABLE = (1 shl 31); //BIT(31); + DMA_BUSY = (1 shl 31); //BIT(31); + DMA_IRQ_REQ = (1 shl 30); //BIT(30); + + DMA_START_NOW = 0; + DMA_START_CARD = (5 shl 27); + +{$ifdef ARM7} + DMA_START_VBL = (1 shl 27); //BIT(27); +{$endif ARM7} + +{$ifdef ARM9} + DMA_START_HBL = (1 shl 28); //BIT(28); + DMA_START_VBL = (1 shl 27); //BIT(27); + DMA_START_FIFO = (7 shl 27); + DMA_DISP_FIFO = (4 shl 27); +{$endif ARM9} + + DMA_16_BIT = 0; + DMA_32_BIT = (1 shl 26); //BIT(26); + + DMA_REPEAT = (1 shl 25); //BIT(25); + + DMA_SRC_INC = (0); + DMA_SRC_DEC = (1 shl 23); //BIT(23); + DMA_SRC_FIX = (1 shl 24); //BIT(24); + + DMA_DST_INC = (0); + DMA_DST_DEC = (1 shl 21); //BIT(21); + DMA_DST_FIX = (1 shl 22); //BIT(22); + DMA_DST_RESET = (3 shl 21); + + DMA_COPY_WORDS = (DMA_ENABLE or DMA_32_BIT or DMA_START_NOW); + DMA_COPY_HALFWORDS = (DMA_ENABLE or DMA_16_BIT or DMA_START_NOW); +{$ifdef ARM9} + DMA_FIFO = (DMA_ENABLE or DMA_32_BIT or DMA_DST_FIX or DMA_START_FIFO); +{$endif ARM9} +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} + +procedure dmaCopyWords(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(channel)^ := cuint32(src); + DMA_DEST(channel)^ := cuint32(dest); + DMA_CR(channel)^ := DMA_COPY_WORDS or (size shr 2); + while (DMA_CR(channel)^ and DMA_BUSY) <> 0 do; +end; + +procedure dmaCopyHalfWords(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(channel)^ := cuint32(src); + DMA_DEST(channel)^ := cuint32(dest); + DMA_CR(channel)^ := DMA_COPY_HALFWORDS or (size shr 1); + while (DMA_CR(channel)^ and DMA_BUSY) <> 0 do; +end; + +procedure dmaCopy(const source: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(3)^ := cuint32(source); + DMA_DEST(3)^ := cuint32(dest); + DMA_CR(3)^ := DMA_COPY_HALFWORDS or (size shr 1); + while (DMA_CR(3)^ and DMA_BUSY <> 0) do; +end; + +procedure dmaCopyWordsAsynch(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(channel)^ := cuint32(src); + DMA_DEST(channel)^ := cuint32(dest); + DMA_CR(channel)^ := DMA_COPY_WORDS or (size shr 2); +end; + +procedure dmaCopyHalfWordsAsynch(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(channel)^ := cuint32(src); + DMA_DEST(channel)^ := cuint32(dest); + DMA_CR(channel)^ := DMA_COPY_HALFWORDS or (size shr 1); +end; + +procedure dmaCopyAsynch(const source: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(3)^ := cuint32(source); + DMA_DEST(3)^ := cuint32(dest); + DMA_CR(3)^ := DMA_COPY_HALFWORDS or (size shr 1); +end; + +procedure dmaFillWords(const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(3)^ := cuint32(src); + DMA_DEST(3)^ := cuint32(dest); + DMA_CR(3)^ := DMA_SRC_FIX or DMA_COPY_WORDS or (size shr 2); + while (DMA_CR(3)^ and DMA_BUSY) <> 0 do; +end; + +procedure dmaFillHalfWords(const src: pointer; dest: pointer; size: cuint32); inline; +begin + DMA_SRC(3)^ := cuint32(src); + DMA_DEST(3)^ := cuint32(dest); + DMA_CR(3)^ := DMA_SRC_FIX or DMA_COPY_HALFWORDS or (size shr 1); + while (DMA_CR(3)^ and DMA_BUSY) <> 0 do; +end; + +function dmaBusy(channel: cuint8): cint; inline; +begin + dmaBusy := (DMA_CR(channel)^ and DMA_BUSY) shr 31; +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +function DMA_SRC(n: cint): pcuint32; inline; +function DMA_DEST(n: cint): pcuint32; inline; +function DMA_CR(n: cint): pcuint32; inline; +procedure dmaCopyWords(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +procedure dmaCopyHalfWords(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +procedure dmaCopy(const source: pointer; dest: pointer; size: cuint32); inline; +procedure dmaCopyWordsAsynch(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +procedure dmaCopyHalfWordsAsynch(channel: cuint8; const src: pointer; dest: pointer; size: cuint32); inline; +procedure dmaCopyAsynch(const source: pointer; dest: pointer; size: cuint32); inline; +procedure dmaFillWords(const src: pointer; dest: pointer; size: cuint32); inline; +procedure dmaFillHalfWords(const src: pointer; dest: pointer; size: cuint32); inline; +function dmaBusy(channel: cuint8): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/helper.inc b/packages/libndsfpc/src/nds/helper.inc new file mode 100644 index 0000000000..4664e02e56 --- /dev/null +++ b/packages/libndsfpc/src/nds/helper.inc @@ -0,0 +1,139 @@ +(* + $Id: helper.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + Copyright (C) 2007 Francesco Lombardi + + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +(* +------------------------------------------------------------------------+ *) +(* Begin Random function *) +(* +------------------------------------------------------------------------+ *) +{$ifdef NDS_INTERFACE} +const + QRAN_SHIFT = 15; + QRAN_MASK = ((1 shl QRAN_SHIFT) - 1); + QRAN_MAX = QRAN_MASK; + QRAN_A = 1664525; + QRAN_C = 1013904223; + +var + RandSeed: dword = 42; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function Randomize(seed: cint): cint; +var + old: cint; +begin + old := RandSeed; + RandSeed := seed; + Randomize := old; +end; + +function Rand(): cint; +begin + RandSeed := QRAN_A * RandSeed + QRAN_C; + Rand := (RandSeed shr 16) and QRAN_MAX; +end; + +function Rand(value: cint): cint; +var + a: cint; +begin + RandSeed := QRAN_A * RandSeed + QRAN_C; + a := (RandSeed shr 16) and QRAN_MAX; + Rand := (a * value) shr 15; +end; +(* +------------------------------------------------------------------------+ *) +(* End Random function *) +(* +------------------------------------------------------------------------+ *) +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +(* Some libc functions *) +function printf(format: Pchar; args: array of const): longint; cdecl; external; +function printf(format: Pchar): longint; cdecl; varargs; external; +function sprintf(s: Pchar; format: Pchar; args: array of const): longint; cdecl; external; +function sprintf(s: Pchar; format: Pchar): longint; varargs; cdecl; external; +function iprintf(format: Pchar; args: array of const): longint; cdecl; external; +function iprintf(format: Pchar): longint; varargs; cdecl; external; +function scanf(format: Pchar; args: array of const): longint; cdecl; external; +function scanf(format: Pchar): longint; cdecl; varargs; external; +function sscanf(s: Pchar; format: Pchar; args: array of const): longint; cdecl; external; +function sscanf(s: Pchar; format: Pchar): longint; cdecl; varargs; external; + + +(* libc file handling types and routines *) +type + _FILE = record + firstCluster: cuint; + length: cuint; + curPos: cuint; + curClus: cuint; // Current cluster to read from + curSect: integer; // Current sector within cluster + curByte: integer; // Current byte within sector + readBuffer: array [0..511] of byte; // Buffer used for unaligned reads + appClus: cuint; // Cluster to append to + appSect: integer; // Sector within cluster for appending + appByte: integer; // Byte within sector for appending + read: boolean; // Can read from file + write: boolean; // Can write to file + append: boolean;// Can append to file + inUse: boolean; // This file is open + dirEntSector: cuint; // The sector where the directory entry is stored + dirEntOffset: integer; // The offset within the directory sector + end; + P_FILE = ^_FILE; + +const + SEEK_SET = 0; + SEEK_CUR = 1; + SEEK_END = 2; + +function fopen(filename: Pchar; modes: Pchar): P_FILE; cdecl; external; +function fread(ptr: pointer; size: longint; n: longint; stream: P_FILE): longint; cdecl; external; +function fwrite(ptr: pointer; size: longint; n: longint; s: P_FILE): longint; cdecl; external; +function ftell(stream: P_FILE): longint; cdecl; external; +function fseek(stream: P_FILE; off: longint; whence: longint): longint; cdecl; external; +function fclose(stream: P_FILE): longint; cdecl; external; +{$endif NDS_INTERFACE} + + + + +{$ifdef NDS_INTERFACE} +function Randomize(seed: cint): cint; +function Rand(): cint; +function Rand(value: cint): cint; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/interrupts.inc b/packages/libndsfpc/src/nds/interrupts.inc new file mode 100644 index 0000000000..1571a70e27 --- /dev/null +++ b/packages/libndsfpc/src/nds/interrupts.inc @@ -0,0 +1,117 @@ +(* + $Id: interrupts.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + + +{$ifdef NDS_INTERFACE} +type + IRQ_MASKS = cuint; + IRQ_MASK = IRQ_MASKS; +const + IRQ_VBLANK : IRQ_MASK = (1 shl 0); (* vertical blank interrupt mask *) + IRQ_HBLANK : IRQ_MASK = (1 shl 1); (* horizontal blank interrupt mask *) + IRQ_VCOUNT : IRQ_MASK = (1 shl 2); (* vcount match interrupt mask *) + IRQ_TIMER0 : IRQ_MASK = (1 shl 3); (* timer 0 interrupt mask *) + IRQ_TIMER1 : IRQ_MASK = (1 shl 4); (* timer 1 interrupt mask *) + IRQ_TIMER2 : IRQ_MASK = (1 shl 5); (* timer 2 interrupt mask *) + IRQ_TIMER3 : IRQ_MASK = (1 shl 6); (* timer 3 interrupt mask *) + IRQ_NETWORK : IRQ_MASK = (1 shl 7); (* serial interrupt mask *) + IRQ_DMA0 : IRQ_MASK = (1 shl 8); (* DMA 0 interrupt mask *) + IRQ_DMA1 : IRQ_MASK = (1 shl 9); (* DMA 1 interrupt mask *) + IRQ_DMA2 : IRQ_MASK = (1 shl 10); (* DMA 2 interrupt mask *) + IRQ_DMA3 : IRQ_MASK = (1 shl 11); (* DMA 3 interrupt mask *) + IRQ_KEYS : IRQ_MASK = (1 shl 12); (* Keypad interrupt mask *) + IRQ_CART : IRQ_MASK = (1 shl 13); (* GBA cartridge interrupt mask *) + IRQ_IPC_SYNC : IRQ_MASK = (1 shl 16); (* IPC sync interrupt mask *) + IRQ_FIFO_EMPTY : IRQ_MASK = (1 shl 17); (* Send FIFO empty interrupt mask *) + IRQ_FIFO_NOT_EMPTY : IRQ_MASK = (1 shl 18); (* Receive FIFO empty interrupt mask *) + IRQ_CARD : IRQ_MASK = (1 shl 19); (* interrupt mask *) + IRQ_CARD_LINE : IRQ_MASK = (1 shl 20); (* interrupt mask *) + IRQ_GEOMETRY_FIFO : IRQ_MASK = (1 shl 21); (* geometry FIFO interrupt mask *) + IRQ_LID : IRQ_MASK = (1 shl 22); (* interrupt mask *) + IRQ_SPI : IRQ_MASK = (1 shl 23); (* SPI interrupt mask *) + IRQ_WIFI : IRQ_MASK = (1 shl 24); (* WIFI interrupt mask (ARM7)*) + IRQ_ALL : IRQ_MASK = $FFFFFF {not 0}; + +const + MAX_INTERRUPTS = 25; + + + +const + REG_IE : pcuint32 = pointer($04000210); + REG_IF : pcuint32 = pointer($04000214); + REG_IME : pcuint16 = pointer($04000208); + +type + IME_VALUE = integer; +const + IME_DISABLE : IME_VALUE = 0; (* Disable all interrupts. *) + IME_ENABLE : IME_VALUE = 1; (* Enable all interrupts not masked out in REG_IE *) + + +var +// __irq_vector: array [0..0] of VoidFunctionPointer; cvar; external; +// __irq_vector: array [0..0] of Pointer; cvar; external; +// __irq_flags: array [0..0] of cuint32; cvar; external; +// __irq_flags: pcuint32; cvar; external; +// __irq_vector: ^VoidFunctionPointer; cvar; external; + __irq_vector: Pointer; cvar; external; + __irq_flags: pcuint32; cvar; external; + + + +{$define VBLANK_INTR_WAIT_FLAGS := __irq_flags} +{$define IRQ_HANDLER := __irq_vector} + +type + IntTable = record + handler: IntFn; + mask: cuint32; + end; + +procedure irqInit(); cdecl; external; +//procedure irqSet(irq: IRQ_MASK; handler: VoidFunctionPointer); cdecl; external; +procedure irqSet(irq: IRQ_MASK; handler: pointer); cdecl; external; +procedure irqClear(irq: IRQ_MASK); cdecl; external; +//procedure irqInitHandler(handler: VoidFunctionPointer); cdecl; external; +procedure irqInitHandler(handler: pointer); cdecl; external; +procedure irqEnable(irq: cuint32); cdecl; external; +procedure irqDisable(irq: cuint32); cdecl; external; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/ipc.inc b/packages/libndsfpc/src/nds/ipc.inc new file mode 100644 index 0000000000..9054ac512d --- /dev/null +++ b/packages/libndsfpc/src/nds/ipc.inc @@ -0,0 +1,180 @@ +(* + $Id: ipc.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +type + sTransferSoundData = record + data: pointer;//pcint; + len: cuint32; + rate: cuint32; + vol: cuint8; + pan: cuint8; + format: cuint8; + PADDING: cuint8; + end; + TransferSoundData = sTransferSoundData; + TTransferSoundData = TransferSoundData; + PTransferSoundData = ^sTransferSoundData; + + sTransferSound = record + data: array [0..15] of TransferSoundData; + count: cuint8; + PADDING: array [0..2] of cuint8; + end; + TransferSound = sTransferSound; + TTransferSound = TransferSound; + PTransferSound = ^sTransferSound; + + sTransferRegion = record + touchX, touchY: cint16; // TSC X, Y + touchXpx, touchYpx: cint16; // TSC X, Y pixel values + touchZ1, touchZ2: cint16; // TSC x-panel measurements + tdiode1, tdiode2: cuint16; // TSC temperature diodes + temperature: cuint32; // TSC computed temperature + + buttons: cuint16; // X, Y, /PENIRQ buttons + + time: record + case integer of + 0: (curtime: array [0..7] of cuint8); // current time response from RTC + 1: (rtc: record + command: cuint8; + year: cuint8; //add 2000 to get 4 digit year + month: cuint8; //1 to 12 + day: cuint8; //1 to (days in month) + + incr: cuint8; + hours: cuint8; //0 to 11 for AM, 52 to 63 for PM + minutes: cuint8; //0 to 59 + seconds: cuint8; //0 to 59 + end; + ); + end; + unixTime: cint32; + + battery: cuint16; // battery life ?? hopefully. :) + aux: cuint16; // i have no idea... + + + // Don't rely on these below, will change or be removed in the future + soundData: pTransferSound; + mailAddr: cuint32; + mailData: cuint32; + mailRead: cuint8; + mailBusy: cuint8; + mailSize: cuint32; + + end; + TransferRegion = sTransferRegion; + TTransferRegion = TransferRegion; + PTransferRegion = ^sTransferRegion; + + +const + //IPC : pTransferRegion = pointer($027FF000); + + IPC_PEN_DOWN = (1 shl 6); + IPC_X = (1 shl 0); + IPC_Y = (1 shl 1); + IPC_LID_CLOSED = (1 shl 7); + +//--------------------------------------------------------------------------------- +// Synchronization register +//--------------------------------------------------------------------------------- + REG_IPC_SYNC : pcuint16 = pointer($04000180); + +type + IPC_SYNC_BITS = longint; +const + IPC_SYNC_IRQ_ENABLE: IPC_SYNC_BITS = (1 shl 14); + IPC_SYNC_IRQ_REQUEST: IPC_SYNC_BITS = (1 shl 13); +{$endif NDS_INTERFACE} + + +{$ifdef NDS_IMPLEMENTATION} +function getIPC(): pTransferRegion; inline; +begin + getIPC := pTransferRegion(pointer($027FF000)); +end; + +function IPC(): TransferRegion; +begin + IPC := getIPC()^; +end; + +procedure IPC_SendSync(sync: cuint); inline; +begin + REG_IPC_SYNC^ := (REG_IPC_SYNC^ and $f0ff) or (((sync) and $0f) shl 8) or IPC_SYNC_IRQ_REQUEST; +end; + +function IPC_GetSync(): cint; inline; +begin + IPC_GetSync := REG_IPC_SYNC^ and $0f; +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +const + REG_IPC_FIFO_TX : pcuint32 = pointer($04000188); + REG_IPC_FIFO_RX : pcuint32 = pointer($04100000); + REG_IPC_FIFO_CR : pcuint16 = pointer($04000184); + +type + IPC_CONTROL_BITS = cint; + +const + IPC_FIFO_SEND_EMPTY : IPC_CONTROL_BITS = (1 shl 0); + IPC_FIFO_SEND_FULL : IPC_CONTROL_BITS = (1 shl 1); + IPC_FIFO_SEND_IRQ : IPC_CONTROL_BITS = (1 shl 2); + IPC_FIFO_SEND_CLEAR : IPC_CONTROL_BITS = (1 shl 3); + IPC_FIFO_RECV_EMPTY : IPC_CONTROL_BITS = (1 shl 8); + IPC_FIFO_RECV_FULL : IPC_CONTROL_BITS = (1 shl 9); + IPC_FIFO_RECV_IRQ : IPC_CONTROL_BITS = (1 shl 10); + IPC_FIFO_ERROR : IPC_CONTROL_BITS = (1 shl 14); + IPC_FIFO_ENABLE : IPC_CONTROL_BITS = (1 shl 15); +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function getIPC(): pTransferRegion; inline; +function IPC(): TransferRegion; +procedure IPC_SendSync(sync: cuint); inline; +function IPC_GetSync(): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/jtypes.inc b/packages/libndsfpc/src/nds/jtypes.inc new file mode 100644 index 0000000000..65fd1b23b9 --- /dev/null +++ b/packages/libndsfpc/src/nds/jtypes.inc @@ -0,0 +1,168 @@ +(* + $Id: jtypes.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +//--------------------------------------------------------------------------------- +{ +//--------------------------------------------------------------------------------- +// 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 +//--------------------------------------------------------------------------------- +{ ### To do +#define GETRAW(name) (name) +#define GETRAWSIZE(name) ((int)name##_size) +#define GETRAWEND(name) ((int)name##_end) +} + +{$ifdef NDS_INTERFACE} +type + (* Unsigned types *) + uint8 = cuint8; + uint16 = cuint16; + uint32 = cuint32; + uint64 = cuint64; + puint8 = pcuint8; + puint16 = pcuint16; + puint32 = pcuint32; + puint64 = pcuint64; + + (* Signed types *) + int8 = cint8; + int16 = cint16; + int32 = cint32; + pint8 = pcint8; + pint16 = pcint16; + pint32 = pcint32; + pint64 = pcint64; + + + float32 = cfloat; + +{ +typedef volatile uint8 vuint8; +typedef volatile uint16 vuint16; +typedef volatile uint32 vuint32; +typedef volatile uint64 vuint64; + +typedef volatile int8 vint8; +typedef volatile int16 vint16; +typedef volatile int32 vint32; +typedef volatile int64 vint64; + +typedef volatile float32 vfloat32; +typedef volatile float64 vfloat64; +} + + +{ +typedef volatile int32 vfixed; +} + + u8 = cuint8; + u16 = cuint16; + u32 = cuint32; + u64 = cuint64; + pu8 = pcuint8; + pu16 = pcuint16; + pu32 = pcuint32; + pu64 = pcuint64; + + s8 = cint8; + s16 = cint16; + s32 = cint32; + s64 = cint64; + ps8 = pcint8; + ps16 = pcint16; + ps32 = pcint32; + ps64 = pcint64; + +{ +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; +} + + touchPosition = record + x: cint16; + y: cint16; + px: cint16; + py: cint16; + z1: cint16; + z2: cint16; + end; + TtouchPosition = touchPosition; + PtouchPosition = ^touchPosition; + + //IntFn = function: pointer; + VoidFunctionPointer = function: pointer; cdecl; + //fp = function: pointer; + + IntFn = procedure; + //VoidFunctionPointer = procedure; cdecl; + fp = procedure; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function BIT(n: cint): cint; inline; +begin + BIT := (1 shl (n)); +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef NDS_INTERFACE} +function BIT(n: cint): cint; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/memory.inc b/packages/libndsfpc/src/nds/memory.inc new file mode 100644 index 0000000000..a5519a1421 --- /dev/null +++ b/packages/libndsfpc/src/nds/memory.inc @@ -0,0 +1,272 @@ +(* + $Id: memory.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +// WAIT_CR: Wait State Control Register +const +{$ifdef ARM9} + REG_EXMEMCNT : pcuint16 = pointer($04000204); +{$else} + REG_EXMEMSTAT: pcuint16 = pointer($04000204); +{$endif} + ARM7_MAIN_RAM_PRIORITY = (1 shl 15); + ARM7_OWNS_CARD = (1 shl 11); + ARM7_OWNS_ROM = (1 shl 7); + + +// Protection register (write-once sadly) +{$ifdef ARM7} + PROTECTION : pcuint32 = pointer($04000308); +{$endif ARM7} + + + ALLRAM : pcuint8 = pointer($00000000); + + MAINRAM8 : pcuint8 = pointer($02000000); + MAINRAM16 : pcuint16 = pointer($02000000); + MAINRAM32 : pcuint32 = pointer($02000000); + +// fixme: shared RAM + +// GBA_BUS is volatile, while GBAROM is not + GBA_BUS : pcuint16 = pointer($08000000); + GBAROM : pcuint16 = pointer($08000000); + + SRAM : pcuint8 = pointer($0A000000); + + +{$ifdef ARM9} + PALETTE : pcuint16 = pointer($05000000); + PALETTE_SUB : pcuint16 = pointer($05000400); + + BG_PALETTE : pcuint16 = pointer($05000000); + BG_PALETTE_SUB : pcuint16 = pointer($05000400); + + SPRITE_PALETTE : pcuint16 = pointer($05000200); + SPRITE_PALETTE_SUB : pcuint16 = pointer($05000600); + + BG_GFX : pcuint16 = pointer($06000000); + BG_GFX_SUB : pcuint16 = pointer($06200000); + SPRITE_GFX : pcuint16 = pointer($06400000); + SPRITE_GFX_SUB : pcuint16 = pointer($06600000); + + VRAM_0 : pcuint16 = pointer($06000000); + VRAM : pcuint16 = pointer($06800000); + VRAM_A : pcuint16 = pointer($06800000); + VRAM_B : pcuint16 = pointer($06820000); + VRAM_C : pcuint16 = pointer($06840000); + VRAM_D : pcuint16 = pointer($06860000); + VRAM_E : pcuint16 = pointer($06880000); + VRAM_F : pcuint16 = pointer($06890000); + VRAM_G : pcuint16 = pointer($06894000); + VRAM_H : pcuint16 = pointer($06898000); + VRAM_I : pcuint16 = pointer($068A0000); + + OAM : pcuint16 = pointer($07000000); + OAM_SUB : pcuint16 = pointer($07000400); +{$endif ARM9} + +{$ifdef ARM7} + VRAM : pcuint16 = pointer($06000000); +{$endif ARM7} + +type + sGBAHeader = packed record + entryPoint: cuint32; + logo: array [0..155] of cuint8; + title: array [0..11] of cchar; + gamecode: array [0..3] of cchar; + makercode: cuint16; + is96h: cuint8; + unitcode: cuint8; + devicecode: cuint8; + unused: array [0..6] of cuint8; + version: cuint8; + complement: cuint8; + checksum: cuint16; + end; + TGBAHeader = sGBAHeader; + PGBAHeader = ^sGBAHeader; + +const + GBA_HEADER : pGBAHeader = pointer($08000000); + +type + sNDSHeader = packed record + gameTitle: array [0..11] of cchar; + gameCode: array [0..3] of cchar; + makercode: array [0..1] of cchar; + unitCode: cuint8; + deviceType: cuint8; // type of device in the game card + deviceSize: cuint8; // device capacity (1<<n Mbit) + reserved1: array [0..8] of cuint8; + romversion: cuint8; + flags: cuint8; // auto-boot flag + + arm9romSource: cuint32; + arm9executeAddress: cuint32; + arm9destination: cuint32; + arm9binarySize: cuint32; + + arm7romSource: cuint32; + arm7executeAddress: cuint32; + arm7destination: cuint32; + arm7binarySize: cuint32; + + filenameSource: cuint32; + filenameSize: cuint32; + fatSource: cuint32; + fatSize: cuint32; + + arm9overlaySource: cuint32; + arm9overlaySize: cuint32; + arm7overlaySource: cuint32; + arm7overlaySize: cuint32; + + cardControl13: cuint32; // used in modes 1 and 3 + cardControlBF: cuint32; // used in mode 2 + bannerOffset: cuint32; + + secureCRC16: cuint16; + + readTimeout: cuint16; + + unknownRAM1: cuint32; + unknownRAM2: cuint32; + + bfPrime1: cuint32; + bfPrime2: cuint32; + romSize: cuint32; + + headerSize: cuint32; + zeros88: array [0..13] of cuint32; + gbaLogo: array [0..155] of cuint8; + logoCRC16: cuint16; + headerCRC16: cuint16; + + debugRomSource: cuint32; + debugRomSize: cuint32; + debugRomDestination: cuint32; + offset_0x16C: cuint32; + + zero: array [0..143] of cuint8; + end; + tNDSHeader = sNDSHeader; + pNDSHeader = ^tNDSHeader; + +const + NDSHeader : pNDSHeader = pointer($027FFE00); + + +type + sNDSBanner = packed record + version: cuint16; + crc: cuint16; + reserved: array [0..27] of cuint8; + icon: array [0..511] of cuint8; + palette: array [0..15] of cuint16; + titles: array [0..5, 0..127] of cuint16; + end; + tNDSBanner = sNDSBanner; + pNDSBanner = ^tNDSBanner; +{$endif NDS_INTERFACE} + + +{$ifdef ARM9} +{$ifdef NDS_INTERFACE} +const + BUS_OWNER_ARM9 = true; + BUS_OWNER_ARM7 = false; +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +// Changes only the gba rom bus ownership +procedure sysSetCartOwner(arm9: cbool); inline; +var + i: cint; +begin + if arm9 then + i := 0 + else + i := ARM7_OWNS_ROM; + REG_EXMEMCNT^ := (REG_EXMEMCNT^ and not ARM7_OWNS_ROM) or (i); +end; + +// Changes only the nds card bus ownership +procedure sysSetCardOwner(arm9: cbool); inline; +var + i: cint; +begin + if arm9 then + i := 0 + else + i := ARM7_OWNS_ROM; + REG_EXMEMCNT^ := (REG_EXMEMCNT^ and not ARM7_OWNS_CARD) or (i); +end; + +// Changes all bus ownerships +procedure sysSetBusOwners(arm9rom, arm9card: cbool); inline; +var + pattern: cuint16; + a9r, a9c: cint; +begin + pattern := REG_EXMEMCNT^ and not (ARM7_OWNS_CARD or ARM7_OWNS_ROM); + if arm9card then + a9c := 0 + else + a9c := ARM7_OWNS_CARD; + if arm9rom then + a9r := 0 + else + a9r := ARM7_OWNS_ROM; + + pattern := pattern or (a9c) or (a9r); + REG_EXMEMCNT^ := pattern; +end; +{$endif NDS_IMPLEMENTATION} +{$endif ARM9} + +{$ifdef NDS_INTERFACE} +{$ifdef ARM9} +procedure sysSetCartOwner(arm9: cbool); inline; +procedure sysSetCardOwner(arm9: cbool); inline; +procedure sysSetBusOwners(arm9rom, arm9card: cbool); inline; +{$endif ARM9} +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/nds.inc b/packages/libndsfpc/src/nds/nds.inc new file mode 100644 index 0000000000..42da1454f0 --- /dev/null +++ b/packages/libndsfpc/src/nds/nds.inc @@ -0,0 +1,126 @@ +(* + $Id: nds.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + Use this file as inclusion if you don't want to use the nds7/nds9 ppu library: + + program main; + + {$apptype arm9} // or arm7 + {$define arm9} // or arm7 + {$mode objfpc} + + + uses + ctypes; + + {$include nds.inc} + + begin + // do stuff + end. + ------------------------------------------------------------------------------ + + $Log$ + +*) +* +* +{$ifndef NDS_INC} +{$define NDS_INC} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +{$if not defined(ARM7) and not defined (ARM9)} + {$error Either ARM7 or ARM9 must be defined} +{$endif} + + +{$define NDS_INCLUSION} +{$define NDS_INTERFACE} +{$define NDS_IMPLEMENTATION} + +{$include helper.inc} + +{$include jtypes.inc} +{$include bios.inc} +{$include card.inc} +{$include dma.inc} +{$include interrupts.inc} +{$include ipc.inc} +{$include memory.inc} +{$include system.inc} +{$include timers.inc} + +{$ifdef ARM9} + {$include arm9/background.inc} + {$include arm9/boxtest.inc} + {$include arm9/cache.inc} + {$include arm9/console.inc} + {$include arm9/exceptions.inc} + {$include arm9/image.inc} + {$include arm9/input.inc} + {$include arm9/math.inc} + {$include arm9/pcx.inc} + { $include nds/arm9/postest.inc} // da rimuovere + {$include arm9/rumble.inc} + {$include arm9/sound.inc} + {$include arm9/trig_lut.inc} + {$include arm9/video.inc} + {$include arm9/videoGL.inc} + {$include arm9/sprite.inc} +{$endif ARM9} + +{$ifdef ARM7} + {$include arm7/audio.inc} + {$include arm7/clock.inc} + {$include arm7/serial.inc} + {$include arm7/touch.inc} +{$endif ARM7} + +{$ifdef ARM7} + {$linklib libnds7.a} +{$endif ARM7} +{$ifdef ARM9} + {$linklib libnds9.a} +{$endif ARM9} + +{$linklib libc.a} +{$linklib libgcc.a} +{$linklib libsysbase.a} + +{$endif NDS_INC} + diff --git a/packages/libndsfpc/src/nds/ndsinclude.inc b/packages/libndsfpc/src/nds/ndsinclude.inc new file mode 100644 index 0000000000..485cc4856b --- /dev/null +++ b/packages/libndsfpc/src/nds/ndsinclude.inc @@ -0,0 +1,39 @@ + +{$include helper.inc} +{$include jtypes.inc} +{$include bios.inc} +{$include card.inc} +{$include dma.inc} +{$include interrupts.inc} +{$include ipc.inc} +{$include memory.inc} +{$include system.inc} +{$include timers.inc} +{$include reload.inc} + +{$ifdef ARM9} + {$include arm9/background.inc} + {$include arm9/boxtest.inc} + {$include arm9/cache.inc} + {$include arm9/console.inc} + {$include arm9/exceptions.inc} + {$include arm9/image.inc} + {$include arm9/input.inc} + {$include arm9/math.inc} + {$include arm9/ndsmotion.inc} + {$include arm9/pcx.inc} + {$include arm9/rumble.inc} + {$include arm9/sound.inc} + {$include arm9/sprite.inc} + {$include arm9/trig_lut.inc} + {$include arm9/video.inc} + {$include arm9/videoGL.inc} + {$include arm9/postest.inc} +{$endif ARM9} + +{$ifdef ARM7} + {$include arm7/audio.inc} + {$include arm7/clock.inc} + {$include arm7/serial.inc} + {$include arm7/touch.inc} +{$endif ARM7} diff --git a/packages/libndsfpc/src/nds/registers_alt.inc b/packages/libndsfpc/src/nds/registers_alt.inc new file mode 100644 index 0000000000..f63b197b96 --- /dev/null +++ b/packages/libndsfpc/src/nds/registers_alt.inc @@ -0,0 +1,309 @@ +(* + $Id: registers_alt.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +const + REG_DISPCNT : pcuint32 = pointer($4000000); + +{$ifdef ARM9} + WAIT_CR = REG_EXMEMCNT; +{$else} + WAIT_CR = REG_EXMEMSTAT; +{$endif} + + DISP_SR = REG_DISPSTAT; + DISP_Y = REG_VCOUNT; + + REG_BGCTRL : pcuint16 = pointer($4000008); + REG_BG0CNT : pcuint16 = pointer($4000008); + REG_BG1CNT : pcuint16 = pointer($400000A); + REG_BG2CNT : pcuint16 = pointer($400000C); + REG_BG3CNT : pcuint16 = pointer($400000E); + + REG_BGOFFSETS : pcuint16 = pointer($4000010); + REG_BG0HOFS : pcuint16 = pointer($4000010); + REG_BG0VOFS : pcuint16 = pointer($4000012); + REG_BG1HOFS : pcuint16 = pointer($4000014); + REG_BG1VOFS : pcuint16 = pointer($4000016); + REG_BG2HOFS : pcuint16 = pointer($4000018); + REG_BG2VOFS : pcuint16 = pointer($400001A); + REG_BG3HOFS : pcuint16 = pointer($400001C); + REG_BG3VOFS : pcuint16 = pointer($400001E); + + REG_BG2PA : pcuint16 = pointer($4000020); + REG_BG2PB : pcuint16 = pointer($4000022); + REG_BG2PC : pcuint16 = pointer($4000024); + REG_BG2PD : pcuint16 = pointer($4000026); + + REG_BG2X : pcuint32 = pointer($4000028); + REG_BG2X_L : pcuint16 = pointer($4000028); + REG_BG2X_H : pcuint16 = pointer($400002A); + + REG_BG2Y : pcuint32 = pointer($400002C); + REG_BG2Y_L : pcuint16 = pointer($400002C); + REG_BG2Y_H : pcuint16 = pointer($400002E); + + REG_BG3PA : pcuint16 = pointer($4000030); + REG_BG3PB : pcuint16 = pointer($4000032); + REG_BG3PC : pcuint16 = pointer($4000034); + REG_BG3PD : pcuint16 = pointer($4000036); + + REG_BG3X : pcuint32 = pointer($4000038); + REG_BG3X_L : pcuint16 = pointer($4000038); + REG_BG3X_H : pcuint16 = pointer($400003A); + REG_BG3Y : pcuint32 = pointer($400003C); + REG_BG3Y_L : pcuint16 = pointer($400003C); + REG_BG3Y_H : pcuint16 = pointer($400003E); + + REG_WIN0H : pcuint16 = pointer($4000040); + REG_WIN1H : pcuint16 = pointer($4000042); + REG_WIN0V : pcuint16 = pointer($4000044); + REG_WIN1V : pcuint16 = pointer($4000046); + REG_WININ : pcuint16 = pointer($4000048); + REG_WINOUT : pcuint16 = pointer($400004A); + + REG_MOSAIC : pcuint32 = pointer($400004C); + REG_MOSAIC_L : pcuint32 = pointer($400004C); + REG_MOSAIC_H : pcuint32 = pointer($400004E); + + REG_BLDMOD : pcuint16 = pointer($4000050); + REG_COLV : pcuint16 = pointer($4000052); + REG_COLY : pcuint16 = pointer($4000054); + + SERIAL_CR = REG_SPICNT; + SERIAL_DATA = REG_SPIDATA; + SIO_CR = REG_SIOCNT; + R_CR = REG_RCNT; + + (* secondary screen *) + REG_DISPCNT_SUB : pcuint32 = pointer($4001000); + REG_BGCTRL_SUB : pcuint16 = pointer($4001008); + REG_BG0CNT_SUB : pcuint16 = pointer($4001008); + REG_BG1CNT_SUB : pcuint16 = pointer($400100A); + REG_BG2CNT_SUB : pcuint16 = pointer($400100C); + REG_BG3CNT_SUB : pcuint16 = pointer($400100E); + + REG_BGOFFSETS_SUB : pcuint16 = pointer($4001010); + REG_BG0HOFS_SUB : pcuint16 = pointer($4001010); + REG_BG0VOFS_SUB : pcuint16 = pointer($4001012); + REG_BG1HOFS_SUB : pcuint16 = pointer($4001014); + REG_BG1VOFS_SUB : pcuint16 = pointer($4001016); + REG_BG2HOFS_SUB : pcuint16 = pointer($4001018); + REG_BG2VOFS_SUB : pcuint16 = pointer($400101A); + REG_BG3HOFS_SUB : pcuint16 = pointer($400101C); + REG_BG3VOFS_SUB : pcuint16 = pointer($400101E); + + REG_BG2PA_SUB : pcuint16 = pointer($4001020); + REG_BG2PB_SUB : pcuint16 = pointer($4001022); + REG_BG2PC_SUB : pcuint16 = pointer($4001024); + REG_BG2PD_SUB : pcuint16 = pointer($4001026); + + REG_BG2X_SUB : pcuint32 = pointer($4001028); + REG_BG2Y_SUB : pcuint32 = pointer($400102C); + + REG_BG3PA_SUB : pcuint16 = pointer($4001030); + REG_BG3PB_SUB : pcuint16 = pointer($4001032); + REG_BG3PC_SUB : pcuint16 = pointer($4001034); + REG_BG3PD_SUB : pcuint16 = pointer($4001036); + + REG_BG3X_SUB : pcuint32 = pointer($4001038); + REG_BG3X_L_SUB : pcuint16 = pointer($4001038); + REG_BG3X_H_SUB : pcuint16 = pointer($400103A); + REG_BG3Y_SUB : pcuint32 = pointer($400103C); + REG_BG3Y_L_SUB : pcuint16 = pointer($400103C); + REG_BG3Y_H_SUB : pcuint16 = pointer($400103E); + + REG_WIN0H_SUB : pcuint16 = pointer($4001040); + REG_WIN1H_SUB : pcuint16 = pointer($4001042); + REG_WIN0V_SUB : pcuint16 = pointer($4001044); + REG_WIN1V_SUB : pcuint16 = pointer($4001046); + REG_WININ_SUB : pcuint16 = pointer($4001048); + REG_WINOUT_SUB : pcuint16 = pointer($400104A); + + REG_MOSAIC_SUB : pcuint32 = pointer($400104C); + REG_MOSAIC_L_SUB : pcuint32 = pointer($400104C); + REG_MOSAIC_H_SUB : pcuint32 = pointer($400104E); + + REG_BLDMOD_SUB : pcuint16 = pointer($4001050); + REG_COLV_SUB : pcuint16 = pointer($4001052); + REG_COLY_SUB : pcuint16 = pointer($4001054); + + (*common*) + REG_DMA : pcuint32 = pointer($40000B0); + + REG_DMA0SAD : pcuint32 = pointer($40000B0); + REG_DMA0SAD_L : pcuint16 = pointer($40000B0); + REG_DMA0SAD_H : pcuint16 = pointer($40000B2); + REG_DMA0DAD : pcuint32 = pointer($40000B4); + REG_DMA0DAD_L : pcuint16 = pointer($40000B4); + REG_DMA0DAD_H : pcuint16 = pointer($40000B6); + REG_DMA0CNT : pcuint32 = pointer($40000B8); + REG_DMA0CNT_L : pcuint16 = pointer($40000B8); + REG_DMA0CNT_H : pcuint16 = pointer($40000BA); + + REG_DMA1SAD : pcuint32 = pointer($40000BC); + REG_DMA1SAD_L : pcuint16 = pointer($40000BC); + REG_DMA1SAD_H : pcuint16 = pointer($40000BE); + REG_DMA1DAD : pcuint32 = pointer($40000C0); + REG_DMA1DAD_L : pcuint16 = pointer($40000C0); + REG_DMA1DAD_H : pcuint16 = pointer($40000C2); + REG_DMA1CNT : pcuint32 = pointer($40000C4); + REG_DMA1CNT_L : pcuint16 = pointer($40000C4); + REG_DMA1CNT_H : pcuint16 = pointer($40000C6); + + REG_DMA2SAD : pcuint32 = pointer($40000C8); + REG_DMA2SAD_L : pcuint16 = pointer($40000C8); + REG_DMA2SAD_H : pcuint16 = pointer($40000CA); + REG_DMA2DAD : pcuint32 = pointer($40000CC); + REG_DMA2DAD_L : pcuint16 = pointer($40000CC); + REG_DMA2DAD_H : pcuint16 = pointer($40000CE); + REG_DMA2CNT : pcuint32 = pointer($40000D0); + REG_DMA2CNT_L : pcuint16 = pointer($40000D0); + REG_DMA2CNT_H : pcuint16 = pointer($40000D2); + + REG_DMA3SAD : pcuint32 = pointer($40000D4); + REG_DMA3SAD_L : pcuint16 = pointer($40000D4); + REG_DMA3SAD_H : pcuint16 = pointer($40000D6); + REG_DMA3DAD : pcuint32 = pointer($40000D8); + REG_DMA3DAD_L : pcuint16 = pointer($40000D8); + REG_DMA3DAD_H : pcuint16 = pointer($40000DA); + REG_DMA3CNT : pcuint32 = pointer($40000DC); + REG_DMA3CNT_L : pcuint16 = pointer($40000DC); + REG_DMA3CNT_H : pcuint16 = pointer($40000DE); + + REG_TIME : pcuint16 = pointer($4000100); + REG_TM0D : pcuint16 = pointer($4000100); + REG_TM0CNT : pcuint16 = pointer($4000102); + REG_TM1D : pcuint16 = pointer($4000106); + REG_TM2D : pcuint16 = pointer($4000108); + REG_TM2CNT : pcuint16 = pointer($400010A); + REG_TM3D : pcuint16 = pointer($400010C); + REG_TM3CNT : pcuint16 = pointer($400010E); + + + REG_SIOCNT : pcuint16 = pointer($4000128); + REG_SIOMLT_SEND : pcuint16 = pointer($400012A); + + KEYS = REG_KEYINPUT; + KEYS_CR = REG_KEYCNT; + //??? + REG_RCNT : pcuint16 = pointer($4000134); + REG_HS_CTRL : pcuint16 = pointer($4000140); + + (* Interupt enable registers *) + IE = REG_IE; + _IF = REG_IF; + IME = REG_IME; + + (*controls power 0x30f is all on *) + POWER_CR = REG_POWERCNT; + + (* ram controllers 0x8 is enabled, other bits have to do with mapping *) + REG_VRAM_A_CR : pcuint8 = pointer($4000240); + REG_VRAM_B_CR : pcuint8 = pointer($4000241); + REG_VRAM_C_CR : pcuint8 = pointer($4000242); + REG_VRAM_D_CR : pcuint8 = pointer($4000243); + REG_VRAM_E_CR : pcuint8 = pointer($4000244); + REG_VRAM_F_CR : pcuint8 = pointer($4000245); + REG_VRAM_G_CR : pcuint8 = pointer($4000246); + REG_VRAM_H_CR : pcuint8 = pointer($4000248); + REG_VRAM_I_CR : pcuint8 = pointer($4000249); + REG_WRAM_CNT : pcuint8 = pointer($4000247); + + + + + (*3D graphics suff*) + REG_GFX_FIFO : pcuint32 = pointer($4000400); + REG_GFX_STATUS : pcuint32 = pointer($4000600); + REG_GFX_CONTROL : pcuint16 = pointer($4000060); + REG_COLOR : pcuint32 = pointer($4000480); + REG_VERTEX16 : pcuint32 = pointer($400048C); + REG_TEXT_COORD : pcuint32 = pointer($4000488); + REG_TEXT_FORMAT : pcuint32 = pointer($40004A8); + + + REG_CLEAR_COLOR : pcuint32 = pointer($4000350); + REG_CLEAR_DEPTH : pcuint16 = pointer($4000354); + + REG_LIGHT_VECTOR : pcuint32 = pointer($40004C8); + REG_LIGHT_COLOR : pcuint32 = pointer($40004CC); + REG_NORMAL : pcuint32 = pointer($4000484); + + REG_DIFFUSE_AMBIENT : pcuint32 = pointer($40004C0); + REG_SPECULAR_EMISSION : pcuint32 = pointer($40004C4); + REG_SHININESS : pcuint32 = pointer($40004D0); + + REG_POLY_FORMAT : pcuint32 = pointer($40004A4); + + REG_GFX_BEGIN : pcuint32 = pointer($4000500); + REG_GFX_END : pcuint32 = pointer($4000504); + REG_GFX_FLUSH : pcuint32 = pointer($4000540); + REG_GFX_VIEWPORT : pcuint32 = pointer($4000580); + + REG_MTX_CONTROL : pcuint32 = pointer($4000440); + REG_MTX_PUSH : pcuint32 = pointer($4000444); + REG_MTX_POP : pcuint32 = pointer($4000448); + REG_MTX_SCALE : pcint32 = pointer($400046C); + REG_MTX_TRANSLATE : pcint32 = pointer($4000470); + REG_MTX_RESTORE : pcuint32 = pointer($4000450); + REG_MTX_STORE : pcuint32 = pointer($400044C); + REG_MTX_IDENTITY : pcuint32 = pointer($4000454); + REG_MTX_LOAD4x4 : ^f32 = pointer($4000458); + REG_MTX_LOAD4x3 : ^f32 = pointer($400045C); + REG_MTX_MULT4x4 : ^f32 = pointer($4000460); + REG_MTX_MULT4x3 : ^f32 = pointer($4000464); + REG_MTX_MULT3x3 : ^f32 = pointer($4000468); + + // Card bus + + REG_CARD_CR1 : pcuint32 = pointer($040001A0); + REG_CARD_CR1H : pcuint8 = pointer($040001A1); + REG_CARD_CR2 : pcuint32 = pointer($040001A4); + REG_CARD_COMMAND : pcuint8 = pointer($040001A8); + + REG_CARD_DATA : pcuint32 = pointer($04100000); + REG_CARD_DATA_RD : pcuint32 = pointer($04100010); + + REG_CARD_1B0 : pcuint32 = pointer($040001B0); + REG_CARD_1B4 : pcuint32 = pointer($040001B4); + REG_CARD_1B8 : pcuint16 = pointer($040001B8); + REG_CARD_1BA : pcuint16 = pointer($040001BA); +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/reload.inc b/packages/libndsfpc/src/nds/reload.inc new file mode 100644 index 0000000000..2af937abb8 --- /dev/null +++ b/packages/libndsfpc/src/nds/reload.inc @@ -0,0 +1,84 @@ +(* + $Id: reload.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +type + COPYFUNC = function (const value: pcchar): pointer; + QUERYFUNC = function(value: cuint32): pcuint32; + + LOADER_DATA = record + VERSION: cuint32; // contains version information about loader + QUERY: QUERYFUNC; // used to retreive extended information from loader + ARM7FUNC: COPYFUNC; // a pointer to the ARM7 load function + ARM9FUNC: COPYFUNC; // a pointer to the ARM9 load function + PATH: pcchar; // THIS VALUE IS SET FOR YOU, DONT TOUCH IT + RESERVED: cuint32; // reserved for future expansion + end; + TLOADER_DATA = LOADER_DATA; + PLOADER_DATA = ^LOADER_DATA; + +const + LOADNDS : PLOADER_DATA = pointer($02800000-48); + BOOT_NDS = pcchar(-1); +{$endif NDS_INTERFACE} + + + +(* +dump this near the begining of your ARM7's main function + +LOADNDS->PATH = 0; + + +inside of your ARM7's main loop or VBlank IRQ or what-ever, add this code: + +if (LOADNDS->PATH != 0) { + LOADNDS->ARM7FUNC(LOADNDS->PATH); +} + + +////////////////////////////////////// + +in your ARM9 code, to return to the menu, call this function: + +WAIT_CR &= ~0x8080; +LOADNDS->ARM9FUNC(BOOT_NDS); + +*) diff --git a/packages/libndsfpc/src/nds/system.inc b/packages/libndsfpc/src/nds/system.inc new file mode 100644 index 0000000000..34edb63c0c --- /dev/null +++ b/packages/libndsfpc/src/nds/system.inc @@ -0,0 +1,225 @@ +(* + $Id: system.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_INTERFACE} +const + REG_DISPSTAT : pcuint16 = pointer($04000004); + DISP_IN_VBLANK = (1 shl 0); + DISP_IN_HBLANK = (1 shl 1); + DISP_YTRIGGERED = (1 shl 2); + DISP_VBLANK_IRQ = (1 shl 3); + DISP_HBLANK_IRQ = (1 shl 4); + DISP_YTRIGGER_IRQ = (1 shl 5); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +procedure SetYtrigger(Yvalue: cint); inline; +begin + REG_DISPSTAT^ := (REG_DISPSTAT^ and $007F ) or (Yvalue shl 8) or (( Yvalue and $100 ) shr 2); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + REG_VCOUNT : pcuint16 = pointer($04000006); + HALT_CR : pcuint16 = pointer($04000300); + REG_POWERCNT : pcuint16 = pointer($04000304); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +procedure powerON(Aon: cint); inline; +begin + REG_POWERCNT^ := REG_POWERCNT^ or Aon; +end; + +procedure powerSET(Aon: cint); inline; +begin + REG_POWERCNT^ := Aon; +end; + +procedure powerOFF(off: cint); inline; +begin + REG_POWERCNT^ := REG_POWERCNT^ and (not off); +end; +{$endif NDS_IMPLEMENTATION} + + +{$ifdef ARM9} +{$ifdef NDS_INTERFACE} +{$ifdef DOXYGEN} +type + ARM9_power = cint; +const + POWER_LCD : ARM9_power = 0; + POWER_2D_A : ARM9_power = 1; + POWER_MATRIX : ARM9_power = 2; + POWER_3D_CORE : ARM9_power = 3; + POWER_2D_B : ARM9_power = 4; + POWER_SWAP_LCDS : ARM9_power = 5; +{$else DOXYGEN} +const + POWER_LCD = (1 shl 0); + POWER_2D_A = (1 shl 1); + POWER_MATRIX = (1 shl 2); + POWER_3D_CORE = (1 shl 3); + POWER_2D_B = (1 shl 9); + POWER_SWAP_LCDS = (1 shl 15); + POWER_ALL_2D = (POWER_LCD or POWER_2D_A or POWER_2D_B); + POWER_ALL = (POWER_ALL_2D or POWER_3D_CORE or POWER_MATRIX); +{$endif DOXYGEN} +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +procedure lcdSwap(); inline; +begin + REG_POWERCNT^ := REG_POWERCNT^ xor POWER_SWAP_LCDS; +end; + +procedure lcdMainOnTop(); inline; +begin + REG_POWERCNT^ := REG_POWERCNT^ or cint(POWER_SWAP_LCDS); +end; + +procedure lcdMainOnBottom(); inline; +begin + REG_POWERCNT^ := REG_POWERCNT^ and (not cint(POWER_SWAP_LCDS)); +end; +{$endif NDS_IMPLEMENTATION} +{$endif ARM9} + +{$ifdef ARM7} +{$ifdef NDS_INTERFACE} +{$ifdef DOXYGEN} +type + ARM7_power = cint; +const + POWER_SOUND: ARM7_power = 0; + POWER_UNKNOWN: ARM7_power = 1; +{$else DOXYGEN} +const + POWER_SOUND = (1 shl 0); + POWER_UNKNOWN = (1 shl 1); +{$endif DOXYGEN} +procedure readUserSettings(); cdecl; external; +{$endif NDS_INTERFACE} +{$endif ARM7} + + +{$ifdef NDS_INTERFACE} +type + tPERSONAL_DATA = bitpacked record + RESERVED0: array [0..1] of cuint8; + + theme: cuint8; + birthMonth: cuint8; + birthDay: cuint8; + + RESERVED1: array [0..0] of cuint8; + + name: array [0..9] of cint16; + nameLen: cuint16; + + message: array [0..25] of cint16; + messageLen: cuint16; + + alarmHour: cuint8; + alarmMinute: cuint8; + + RESERVED2: array [0..3] of cuint8; + + calX1: cuint16; + calY1: cuint16; + calX1px: cuint8; + calY1px: cuint8; + + calX2: cuint16; + calY2: cuint16; + calX2px: cuint8; + calY2px: cuint8; + + + _user_data: packed record + language: 0..3; + gbaScreen: 0..1; + defaultBrightness: 0..2; + autoMode: 0..1; + RESERVED4: 0..1; + settingsLost: 0..1; + RESERVED2: 0..6; + end; + RESERVED3: cuint16; + rtcOffset: cuint32; + RESERVED4: cuint32; + end; + PERSONAL_DATA = tPERSONAL_DATA; + PPERSONAL_DATA = ^tPERSONAL_DATA; + +const + REG_KEYINPUT : pcuint16 = pointer($04000130); + REG_KEYCNT : pcuint16 = pointer($04000132); + PersonalData : PPERSONAL_DATA = pointer($27FFC80); + + +type + __argv = record + argvMagic: cint; // argv magic number, set to 0x5f617267 ('_arg') if valid + commandLine: pcchar; // base address of command line, set of null terminated strings + length: cint; // total length of command line + end; + Targv = __argv; + Pargv = ^Targv; + +const + libnds_argv: Pargv = pointer($027FFF70); + argvMagic = $5f617267; +{$endif NDS_INTERFACE} + + +{$ifdef NDS_INTERFACE} +procedure SetYtrigger(Yvalue: cint); inline; +procedure powerON(Aon: cint); inline; +procedure powerSET(Aon: cint); inline; +procedure powerOFF(off: cint); inline; +{$ifdef ARM9} +procedure lcdSwap(); inline; +procedure lcdMainOnTop(); inline; +procedure lcdMainOnBottom(); inline; +{$endif ARM9} +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds/timers.inc b/packages/libndsfpc/src/nds/timers.inc new file mode 100644 index 0000000000..2a601812d1 --- /dev/null +++ b/packages/libndsfpc/src/nds/timers.inc @@ -0,0 +1,130 @@ +(* + $Id: timers.inc 25 2007-12-10 21:06:46Z p4p3r0 $ + ------------------------------------------------------------------------------ + 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. + ------------------------------------------------------------------------------ + + + Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler + (http://www.freepascal.org) + + Copyright (C) 2006 Francesco Lombardi + Check http://sourceforge.net/projects/libndsfpc for updates + + ------------------------------------------------------------------------------ + + $Log$ + +*) + +{$ifdef NDS_IMPLEMENTATION} +function TIMER_FREQ(n: cint): cint; inline; +begin + TIMER_FREQ := cint(-$2000000 div (n)); +end; + +function TIMER_FREQ_64(n: cint): cint; inline; +begin + TIMER_FREQ_64 := cint(-($2000000 shr 6) div (n)); +end; + +function TIMER_FREQ_256(n: cint): cint; inline; +begin + TIMER_FREQ_256 := cint(-($2000000 shr 8) div (n)); +end; + +function TIMER_FREQ_1024(n: cint): cint; inline; +begin + TIMER_FREQ_1024 := cint(-($2000000 shr 10) div (n)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + //! Same as %TIMER_DATA(0). + TIMER0_DATA : pcuint16 = pointer($04000100); + //! Same as %TIMER_DATA(1). + TIMER1_DATA : pcuint16 = pointer($04000104); + //! Same as %TIMER_DATA(2). + TIMER2_DATA : pcuint16 = pointer($04000108); + //! Same as %TIMER_DATA(3). + TIMER3_DATA : pcuint16 = pointer($0400010C); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function TIMER_DATA(n: cuint): pcuint16; inline; +begin + TIMER_DATA := pcuint16($04000100 + (n shl 2)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const +// Timer control registers + //! Same as %TIMER_CR(0). + TIMER0_CR : pcuint16 = pointer($04000102); + //! Same as %TIMER_CR(1). + TIMER1_CR : pcuint16 = pointer($04000106); + //! Same as %TIMER_CR(2). + TIMER2_CR : pcuint16 = pointer($0400010A); + //! Same as %TIMER_CR(3). + TIMER3_CR : pcuint16 = pointer($0400010E); +{$endif NDS_INTERFACE} + +{$ifdef NDS_IMPLEMENTATION} +function TIMER_CR(n: cint): pcuint16; inline; +begin + TIMER_CR := pcuint16($04000102 + (n shl 2)); +end; +{$endif NDS_IMPLEMENTATION} + +{$ifdef NDS_INTERFACE} +const + //! Enables the timer. + TIMER_ENABLE = (1 shl 7); + + //! Causes the timer to request an Interupt on overflow. + TIMER_IRQ_REQ = (1 shl 6); + + //! When set will cause the timer to count when the timer below overflows (unavailable for timer 0). + TIMER_CASCADE = (1 shl 2); + + //! Causes the timer to count at 33.514Mhz. + TIMER_DIV_1 = (0); + //! Causes the timer to count at (33.514 / 64) Mhz. + TIMER_DIV_64 = (1); + //! Causes the timer to count at (33.514 / 256) Mhz. + TIMER_DIV_256 = (2); + //! Causes the timer to count at (33.514 / 1024)Mhz. + TIMER_DIV_1024 = (3); +{$endif NDS_INTERFACE} + +{$ifdef NDS_INTERFACE} +function TIMER_FREQ(n: cint): cint; inline; +function TIMER_FREQ_64(n: cint): cint; inline; +function TIMER_FREQ_256(n: cint): cint; inline; +function TIMER_FREQ_1024(n: cint): cint; inline; +function TIMER_DATA(n: cuint): pcuint16; inline; +function TIMER_CR(n: cint): pcuint16; inline; +{$endif NDS_INTERFACE} diff --git a/packages/libndsfpc/src/nds7.pp b/packages/libndsfpc/src/nds7.pp new file mode 100644 index 0000000000..4318e0754b --- /dev/null +++ b/packages/libndsfpc/src/nds7.pp @@ -0,0 +1,32 @@ +unit nds7; +{$mode objfpc} +{$apptype arm7} +{$define arm7} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes; + +{$linklib nds7} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include nds/ndsinclude.inc} +{$undef NDS_INTERFACE} + +implementation + +{$define NDS_IMPLEMENTATION} +{$include nds/ndsinclude.inc} +{$undef NDS_IMPLEMENTATION} + +end. diff --git a/packages/libndsfpc/src/nds9.pp b/packages/libndsfpc/src/nds9.pp new file mode 100644 index 0000000000..540fc72aa4 --- /dev/null +++ b/packages/libndsfpc/src/nds9.pp @@ -0,0 +1,32 @@ +unit nds9; +{$mode objfpc} +{$apptype arm9} +{$define arm9} + +{$J+} +{$INLINE ON} +{$MACRO ON} +{$PACKRECORDS C} + +interface + +uses + ctypes; + +{$linklib nds9} + +{$linklib c} +{$linklib gcc} +{$linklib sysbase} + +{$define NDS_INTERFACE} +{$include nds/ndsinclude.inc} +{$undef NDS_INTERFACE} + +implementation + +{$define NDS_IMPLEMENTATION} +{$include nds/ndsinclude.inc} +{$undef NDS_IMPLEMENTATION} + +end. |