From: <c99...@us...> - 2007-07-29 03:21:18
|
Revision: 429 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=429&view=rev Author: c99koder Date: 2007-07-28 20:21:16 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Tiki: NDS: Keep interrupts enabled during sound mixing, move wifi update into its own timer, include missing header file Modified Paths: -------------- tiki/nds/arm7_template/source/arm7main.c tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/plathid.cpp Added Paths: ----------- tiki/nds/include/dssoundstream.h Modified: tiki/nds/arm7_template/source/arm7main.c =================================================================== --- tiki/nds/arm7_template/source/arm7main.c 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/arm7_template/source/arm7main.c 2007-07-29 03:21:16 UTC (rev 429) @@ -152,6 +152,7 @@ } void arm7_synctoarm9() { // send fifo message + SendCommandToArm9(0x87654321); } //--------------------------------------------------------------------------------- Added: tiki/nds/include/dssoundstream.h =================================================================== --- tiki/nds/include/dssoundstream.h (rev 0) +++ tiki/nds/include/dssoundstream.h 2007-07-29 03:21:16 UTC (rev 429) @@ -0,0 +1,66 @@ +/* + Tiki + + dssoundstream.h + + based on the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 +*/ + +#ifndef __NDSSOUND_H +#define __NDSSOUND_H + +#include <nds.h> + +#define CLOCK (1 << 25) + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + NONE = 0, + INIT = 1, + MIX = 2, + MIXING = 4, + STOP = 8 +}CommandType; + +typedef enum +{ + FIFO_NONE = 0, + UPDATEON_ARM9 = 1, + MIXCOMPLETE_ONARM9 = 2 +}FifoType; + +typedef struct +{ + s8 *mixbuffer; + u32 rate; + u32 buffersize; + u32 cmd; + u8 channel,format; + u32 soundcursor,numsamples; + s32 prevtimer; + s16 period; +}S_SoundSystem; + +#define soundsystem ((S_SoundSystem*)((u32)(IPC)+sizeof(TransferRegion))) + +#ifdef ARM9 +extern void SoundSystemInit(u32 rate,u32 buffersize,u8 channel,u8 format); +extern void SoundStartMixer(void); +extern void SendCommandToArm7(u32 command); +#else +extern void SoundVBlankIrq(void); +extern void SoundSwapAndMix(void); +extern void SoundSetTimer(int period); +extern void SoundFifoHandler(void); +extern void SendCommandToArm9(u32 command); +#endif + +#ifdef __cplusplus +} +#endif +#endif Property changes on: tiki/nds/include/dssoundstream.h ___________________________________________________________________ Name: svn:eol-style + native Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/audio/stream.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -52,8 +52,11 @@ { case FIFO_NONE: break; + case 0x87654321: + Wifi_Sync(); + break; case UPDATEON_ARM9: - REG_IME = 0; + //REG_IME = 0; for(streams_iter = streams.begin(); streams_iter != streams.end(); streams_iter++) { if(soundsystem->format == 8) { @@ -82,12 +85,11 @@ } } } - REG_IME = 1; + //REG_IME = 1; SendCommandToArm7(MIXCOMPLETE_ONARM9); break; } } - Wifi_Sync(); } void SendCommandToArm7(u32 command) @@ -114,7 +116,7 @@ Stream::Stream() { // Default our members. - m_bufSize = 16384; + m_bufSize = 4096; m_chnCount = 2; m_freq = 44100; m_queueing = false; Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/init_shutdown.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -16,12 +16,16 @@ #include <nds.h> #include <fat.h> #include <dswifi9.h> +#include <dssoundstream.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 + SendCommandToArm7(0x87654321); } - +// wifi timer function, to update internals of sgIP +void Timer_50ms(void) { + Wifi_Timer(50); +} namespace Tiki { bool init(int argc, char **argv) { @@ -46,7 +50,8 @@ GL::Plxcompat::plx_mat3d_init(256, 192); Audio::Stream::initGlobal(); Hid::init(); - + irqSet(IRQ_TIMER3, Timer_50ms); // setup timer IRQ + irqEnable(IRQ_TIMER3); { // send fifo message to initialize the arm7 wifi REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO @@ -59,6 +64,10 @@ 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 + + // set timer3 + *((volatile u16 *)0x0400010C) = -6553; // 6553.1 * 256 cycles = ~50ms; + *((volatile u16 *)0x0400010E) = 0x00C2; // enable, irq, 1/256 clock while(Wifi_CheckInit()==0) { // wait for arm7 to be initted successfully swiWaitForVBlank(); Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/plathid.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -117,12 +117,11 @@ } oldkeys = keys; - Wifi_Timer(50); __timecounter += 15000; } bool platInit() { - irqSet(IRQ_VCOUNT,&TikiVBlank); + irqSet(IRQ_VBLANK,&TikiVBlank); irqEnable(IRQ_VBLANK | IRQ_VCOUNT); NDSjs = new JsDevice; NDSmouse = new MouseDevice; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |