From: <c99...@us...> - 2007-07-28 06:27:23
|
Revision: 427 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=427&view=rev Author: c99koder Date: 2007-07-27 23:27:21 -0700 (Fri, 27 Jul 2007) Log Message: ----------- NDS: Enable optimizations, wifi, and use an interrupt for a higher-resolution Tiki::gettime() Modified Paths: -------------- tiki/nds/Makefile.rules tiki/nds/arm7_template/source/arm7main.c tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/plathid.cpp tiki/nds/src/tikitime.cpp Modified: tiki/nds/Makefile.rules =================================================================== --- tiki/nds/Makefile.rules 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/Makefile.rules 2007-07-28 06:27:21 UTC (rev 427) @@ -12,7 +12,7 @@ $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitARM) endif -TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -lfat -lnds9 +TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -ldswifi9 -lfat -lnds9 CXXFLAGS=-I$(DEVKITPRO)/libnds/include @@ -25,7 +25,7 @@ CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/include CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/lib CXXFLAGS+=-DARM9 -CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork +CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -O2 CFLAGS=$(CXXFLAGS) CXXFLAGS+=-fno-rtti Modified: tiki/nds/arm7_template/source/arm7main.c =================================================================== --- tiki/nds/arm7_template/source/arm7main.c 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/arm7_template/source/arm7main.c 2007-07-28 06:27:21 UTC (rev 427) @@ -9,6 +9,7 @@ #include <nds.h> #include <stdlib.h> +#include <dswifi7.h> #include "dssoundstream.h" //--------------------------------------------------------------------------------- @@ -138,20 +139,26 @@ } } } - + Wifi_Update(); } void FiFoHandler(void) //--------------------------------------------------------------------------------- { while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) ) { + Wifi_Sync(); SoundFifoHandler(); } } + +void arm7_synctoarm9() { // send fifo message +} + //--------------------------------------------------------------------------------- int main(int argc, char ** argv) { //--------------------------------------------------------------------------------- - + u32 fifo_temp; + // Reset the clock if needed rtcReset(); @@ -159,16 +166,33 @@ powerON(POWER_SOUND); SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); IPC->soundData = 0; + IPC->mailBusy = 0; irqInit(); irqSet(IRQ_VBLANK, VblankHandler); SetYtrigger(80); vcount = 80; irqSet(IRQ_VCOUNT, VcountHandler); - REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; - irqSet(IRQ_FIFO_NOT_EMPTY, FiFoHandler); - irqEnable(IRQ_VBLANK | IRQ_VCOUNT|IRQ_FIFO_NOT_EMPTY); + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; + irqEnable(IRQ_VBLANK | IRQ_VCOUNT); + irqSet(IRQ_WIFI, Wifi_Interrupt); + irqEnable(IRQ_WIFI); + + // trade some mail, to get a pointer from arm9 + while(1) { + while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); + fifo_temp=REG_IPC_FIFO_RX; + if(fifo_temp==0x12345678) break; + } + while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); + fifo_temp=REG_IPC_FIFO_RX; + Wifi_Init(fifo_temp); + irqSet(IRQ_FIFO_NOT_EMPTY,FiFoHandler); + irqEnable(IRQ_FIFO_NOT_EMPTY); + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; + + Wifi_SetSyncHandler(arm7_synctoarm9); SoundSetTimer(0); // Keep the ARM7 idle Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/audio/stream.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -14,6 +14,7 @@ #include <string.h> #include <nds.h> +#include <dswifi9.h> #include "dssoundstream.h" using namespace Tiki::Audio; @@ -86,6 +87,7 @@ break; } } + Wifi_Sync(); } void SendCommandToArm7(u32 command) Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/init_shutdown.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -15,7 +15,13 @@ #include <nds.h> #include <fat.h> +#include <dswifi9.h> +// notification function to send fifo message to arm7 +void arm9_synctoarm7() { // send fifo message + //This is a NO-OP because the sound streaming code will constantly communicate with the ARM7 over the FIFO anyway +} + namespace Tiki { bool init(int argc, char **argv) { @@ -37,9 +43,30 @@ fatInitDefault(); // initialize parallax - GL::Plxcompat::plx_mat3d_init(640, 480); + GL::Plxcompat::plx_mat3d_init(256, 192); Audio::Stream::initGlobal(); - return Hid::init(); + Hid::init(); + + { // send fifo message to initialize the arm7 wifi + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO + + u32 Wifi_pass= Wifi_Init(WIFIINIT_OPTION_USELED); + REG_IPC_FIFO_TX=0x12345678; + REG_IPC_FIFO_TX=Wifi_pass; + + irqEnable(IRQ_FIFO_NOT_EMPTY); + + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; // enable FIFO IRQ + + Wifi_SetSyncHandler(arm9_synctoarm7); // tell wifi lib to use our handler to notify arm7 + + while(Wifi_CheckInit()==0) { // wait for arm7 to be initted successfully + swiWaitForVBlank(); + } + + } // wifi init complete - wifi lib can now be used! + + return true; } void shutdown() { Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/plathid.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -1,7 +1,10 @@ #include "pch.h" #include "Tiki/glhdrs.h" #include "Tiki/hid.h" +#include <dswifi9.h> +volatile uint64 __timecounter = 0; + namespace Tiki { namespace Hid { #define CONTROLLER_BUTTON_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ @@ -64,11 +67,13 @@ CONTROLLER_KEY_MAP(oldkeys, keys, KEY_B, Event::KeyEsc); oldkeys = keys; + Wifi_Timer(50); + __timecounter += 15000; } bool platInit() { - irqSet(IRQ_VBLANK,&TikiVBlank); - irqEnable(IRQ_VBLANK); + irqSet(IRQ_VCOUNT,&TikiVBlank); + irqEnable(IRQ_VBLANK | IRQ_VCOUNT); return true; } Modified: tiki/nds/src/tikitime.cpp =================================================================== --- tiki/nds/src/tikitime.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/tikitime.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -13,16 +13,12 @@ #include <unistd.h> #include <nds.h> +extern volatile uint64 __timecounter; + namespace Tiki { namespace Time { uint64 gettime() { - timeval tv; - gettimeofday(&tv, NULL); - - uint64 rv = tv.tv_sec; rv *= 1000000; - rv += tv.tv_usec; - - return rv; + return __timecounter; } void sleep(uint64 us) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |