|
From: <c99...@us...> - 2007-07-21 17:52:07
|
Revision: 425
http://svn.sourceforge.net/cadcdev/?rev=425&view=rev
Author: c99koder
Date: 2007-07-21 10:52:01 -0700 (Sat, 21 Jul 2007)
Log Message:
-----------
NDS: arm7/arm9 streaming code (mono only)
Modified Paths:
--------------
tiki/nds/Makefile.rules
tiki/nds/src/audio/stream.cpp
tiki/nds/src/init_shutdown.cpp
tiki/nds/src/platgl.cpp
Added Paths:
-----------
tiki/nds/arm7_template/
tiki/nds/arm7_template/Makefile
tiki/nds/arm7_template/source/
tiki/nds/arm7_template/source/arm7main.c
tiki/nds/arm7_template/source/dssoundstream.h
tiki/nds/arm7_template/source/sound7.c
Modified: tiki/nds/Makefile.rules
===================================================================
--- tiki/nds/Makefile.rules 2007-07-18 23:45:51 UTC (rev 424)
+++ tiki/nds/Makefile.rules 2007-07-21 17:52:01 UTC (rev 425)
@@ -27,7 +27,7 @@
CXXFLAGS+=-DARM9
CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork
CFLAGS=$(CXXFLAGS)
-CXXFLAGS+=-fno-rtti -fno-exceptions
+CXXFLAGS+=-fno-rtti
LDFLAGS=-specs=ds_arm9.specs -mthumb -mthumb-interwork -mno-fpu -L$(DEVKITPRO)/lib -lgcc
Added: tiki/nds/arm7_template/Makefile
===================================================================
--- tiki/nds/arm7_template/Makefile (rev 0)
+++ tiki/nds/arm7_template/Makefile 2007-07-21 17:52:01 UTC (rev 425)
@@ -0,0 +1,138 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
+endif
+
+include $(DEVKITARM)/ds_rules
+
+#---------------------------------------------------------------------------------
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# INCLUDES is a list of directories containing extra header files
+# DATA is a list of directories containing binary files
+# all directories are relative to this makefile
+#---------------------------------------------------------------------------------
+BUILD := build
+SOURCES := source
+INCLUDES := include build
+DATA :=
+TARGET := tikiarm7
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH := -mthumb-interwork
+
+CFLAGS := -g -Wall -O2\
+ -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
+ -ffast-math \
+ $(ARCH)
+
+CFLAGS += $(INCLUDE) -DARM7
+CXXFLAGS := $(CFLAGS)
+
+
+ASFLAGS := -g $(ARCH)
+LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map
+
+LIBS := -lnds7
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS := $(LIBNDS)
+
+
+#---------------------------------------------------------------------------------
+# no real need to edit anything past this point unless you need to add additional
+# rules for different file extensions
+#---------------------------------------------------------------------------------
+ifneq ($(BUILD),$(notdir $(CURDIR)))
+#---------------------------------------------------------------------------------
+
+export ARM7BIN := $(TOPDIR)/$(TARGET).arm7
+export ARM7ELF := $(CURDIR)/$(TARGET).arm7.elf
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
+
+export CC := $(PREFIX)gcc
+export CXX := $(PREFIX)g++
+export AR := $(PREFIX)ar
+export OBJCOPY := $(PREFIX)objcopy
+
+CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
+CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
+SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
+
+export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
+
+export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD)
+
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+#---------------------------------------------------------------------------------
+# use CXX for linking C++ projects, CC for standard C
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(CPPFILES)),)
+#---------------------------------------------------------------------------------
+ export LD := $(CC)
+#---------------------------------------------------------------------------------
+else
+#---------------------------------------------------------------------------------
+ export LD := $(CXX)
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
+
+.PHONY: $(BUILD) clean
+
+#---------------------------------------------------------------------------------
+$(BUILD):
+ @[ -d $@ ] || mkdir -p $@
+ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+ @echo clean ...
+ @rm -fr $(BUILD) *.elf
+
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS := $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(ARM7BIN) : $(ARM7ELF)
+ @$(OBJCOPY) -O binary $< $@
+ @echo built ... $(notdir $@)
+
+
+$(ARM7ELF) : $(OFILES)
+ @echo linking $(notdir $@)
+ @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
+
+
+#---------------------------------------------------------------------------------
+# you need a rule like this for each extension you use as binary data
+#---------------------------------------------------------------------------------
+%.bin.o : %.bin
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
Property changes on: tiki/nds/arm7_template/Makefile
___________________________________________________________________
Name: svn:eol-style
+ native
Added: tiki/nds/arm7_template/source/arm7main.c
===================================================================
--- tiki/nds/arm7_template/source/arm7main.c (rev 0)
+++ tiki/nds/arm7_template/source/arm7main.c 2007-07-21 17:52:01 UTC (rev 425)
@@ -0,0 +1,180 @@
+/*
+ Tiki
+
+ arm7main.c
+
+ Based on the libnds arm7 template and the ARM9/ARM7 streaming code from
+ http://forum.gbadev.org/viewtopic.php?t=10739
+*/
+
+#include <nds.h>
+#include <stdlib.h>
+#include "dssoundstream.h"
+
+//---------------------------------------------------------------------------------
+void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol, u8 pan, u8 format) {
+//---------------------------------------------------------------------------------
+ SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate);
+ SCHANNEL_SOURCE(channel) = (u32)data;
+ SCHANNEL_LENGTH(channel) = bytes >> 2 ;
+ SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
+}
+
+
+//---------------------------------------------------------------------------------
+s32 getFreeSoundChannel() {
+//---------------------------------------------------------------------------------
+ int i;
+ for (i=0; i<16; i++) {
+ if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i;
+ }
+ return -1;
+}
+
+int vcount;
+touchPosition first,tempPos;
+
+//---------------------------------------------------------------------------------
+void VcountHandler() {
+//---------------------------------------------------------------------------------
+ static int lastbut = -1;
+
+ uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0;
+
+ but = REG_KEYXY;
+
+ // Check if the lid has been closed.
+ if(but & BIT(7)) {
+ // Save the current interrupt sate.
+ u32 ie_save = REG_IE;
+ // Turn the speaker down.
+ swiChangeSoundBias(0,0x400);
+ // Save current power state.
+ int power = readPowerManagement(PM_CONTROL_REG);
+ // Set sleep LED.
+ writePowerManagement(PM_CONTROL_REG, PM_LED_CONTROL(1));
+ // Register for the lid interrupt.
+ REG_IE = IRQ_LID;
+
+ // Power down till we get our interrupt.
+ swiSleep(); //waits for PM (lid open) interrupt
+
+ REG_IF = ~0;
+ // Restore the interrupt state.
+ REG_IE = ie_save;
+ // Restore power state.
+ writePowerManagement(PM_CONTROL_REG, power);
+
+ // Turn the speaker up.
+ swiChangeSoundBias(1,0x400);
+ }
+
+ if (!( (but ^ lastbut) & (1<<6))) {
+
+ tempPos = touchReadXY();
+
+ if ( tempPos.x == 0 || tempPos.y == 0 ) {
+ but |= (1 <<6);
+ lastbut = but;
+ } else {
+ x = tempPos.x;
+ y = tempPos.y;
+ xpx = tempPos.px;
+ ypx = tempPos.py;
+ z1 = tempPos.z1;
+ z2 = tempPos.z2;
+ }
+
+ } else {
+ lastbut = but;
+ but |= (1 <<6);
+ }
+
+ if ( vcount == 80 ) {
+ first = tempPos;
+ } else {
+ if ( abs( xpx - first.px) > 10 || abs( ypx - first.py) > 10 ||
+ (but & ( 1<<6)) ) {
+
+ but |= (1 <<6);
+ lastbut = but;
+
+ } else {
+ IPC->mailBusy = 1;
+ IPC->touchX = x;
+ IPC->touchY = y;
+ IPC->touchXpx = xpx;
+ IPC->touchYpx = ypx;
+ IPC->touchZ1 = z1;
+ IPC->touchZ2 = z2;
+ IPC->mailBusy = 0;
+ }
+ }
+ IPC->buttons = but;
+ vcount ^= (80 ^ 130);
+ SetYtrigger(vcount);
+
+}
+
+//---------------------------------------------------------------------------------
+void VblankHandler(void) {
+//---------------------------------------------------------------------------------
+
+ u32 i;
+
+ SoundVBlankIrq();
+
+ //sound code :)
+ TransferSound *snd = IPC->soundData;
+ IPC->soundData = 0;
+
+ if (0 != snd) {
+
+ for (i=0; i<snd->count; i++) {
+ s32 chan = getFreeSoundChannel();
+
+ if (chan >= 0) {
+ startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
+ }
+ }
+ }
+
+}
+void FiFoHandler(void)
+//---------------------------------------------------------------------------------
+{
+ while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) )
+ {
+ SoundFifoHandler();
+ }
+}
+//---------------------------------------------------------------------------------
+int main(int argc, char ** argv) {
+//---------------------------------------------------------------------------------
+
+ // Reset the clock if needed
+ rtcReset();
+
+ //enable sound
+ powerON(POWER_SOUND);
+ SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
+ IPC->soundData = 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);
+
+ SoundSetTimer(0);
+
+ // Keep the ARM7 idle
+ while (1){
+ swiWaitForVBlank();
+ }
+}
+
+
Property changes on: tiki/nds/arm7_template/source/arm7main.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: tiki/nds/arm7_template/source/dssoundstream.h
===================================================================
--- tiki/nds/arm7_template/source/dssoundstream.h (rev 0)
+++ tiki/nds/arm7_template/source/dssoundstream.h 2007-07-21 17:52:01 UTC (rev 425)
@@ -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/arm7_template/source/dssoundstream.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: tiki/nds/arm7_template/source/sound7.c
===================================================================
--- tiki/nds/arm7_template/source/sound7.c (rev 0)
+++ tiki/nds/arm7_template/source/sound7.c 2007-07-21 17:52:01 UTC (rev 425)
@@ -0,0 +1,123 @@
+/*
+ Tiki
+
+ sound7.c
+
+ Based on the ARM9/ARM7 streaming code from
+ http://forum.gbadev.org/viewtopic.php?t=10739
+*/
+
+#include <nds.h>
+#include <arm7/serial.h>
+#include "dssoundstream.h"
+
+void SoundVBlankIrq(void)
+{
+ //REG_IME = 0;
+ int channel,i;
+
+ if(soundsystem->cmd & INIT)
+ {
+ SoundSetTimer(soundsystem->period);
+ soundsystem->cmd &= ~INIT;
+ }
+ else if(soundsystem->cmd & MIXING)
+ {
+ SoundSwapAndMix();
+ }
+ if(soundsystem->cmd & MIX)
+ {
+ channel = soundsystem->channel;
+
+ if(soundsystem->format == 8)
+ {
+ SCHANNEL_CR(0) = 0;
+ SCHANNEL_TIMER(0) = 0x10000 - soundsystem->period;
+ SCHANNEL_SOURCE(0) = (u32)soundsystem->mixbuffer;
+ SCHANNEL_REPEAT_POINT(0) = 0;
+ SCHANNEL_LENGTH(0) = soundsystem->buffersize >> 2;
+ SCHANNEL_CR(0) = SCHANNEL_ENABLE | SOUND_REPEAT | SOUND_VOL(127) | SOUND_PAN(64) | SOUND_8BIT;
+ }
+ if(soundsystem->format == 16)
+ {
+ SCHANNEL_CR(0) = 0;
+ SCHANNEL_TIMER(0) = 0x10000 - soundsystem->period;
+ SCHANNEL_SOURCE(0) = (u32)soundsystem->mixbuffer;
+ SCHANNEL_REPEAT_POINT(0) = 0;
+ SCHANNEL_LENGTH(0) = soundsystem->buffersize >> 2;
+ SCHANNEL_CR(0) = SCHANNEL_ENABLE | SOUND_REPEAT | SOUND_VOL(127) | SOUND_PAN(64) | SOUND_16BIT;
+ }
+
+ soundsystem->cmd &= ~MIX;
+ soundsystem->cmd |= MIXING;
+ }
+ //REG_IME = 1;
+}
+void SoundSetTimer(int period)
+{
+ if(!period)
+ {
+ TIMER0_DATA = 0;
+ TIMER0_CR = 0;
+ TIMER1_DATA = 0;
+ TIMER1_CR = 0;
+ }
+ else
+ {
+ TIMER0_DATA = 0x10000 - (period * 2);
+ TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1;
+
+ TIMER1_DATA = 0;
+ TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_DIV_1;
+ }
+}
+
+void SoundSwapAndMix(void)
+{
+ s32 curtimer,numsamples,remaining,tries;
+
+ curtimer = TIMER1_DATA;
+
+ numsamples = curtimer - soundsystem->prevtimer;
+
+ if(numsamples < 0) numsamples += 65536;
+
+ soundsystem->prevtimer = curtimer;
+ soundsystem->numsamples = numsamples;
+
+ SendCommandToArm9(UPDATEON_ARM9);
+}
+void SoundFifoHandler(void)
+{
+ u32 command;
+
+ if (!(REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY))
+ {
+ command = REG_IPC_FIFO_RX;
+
+ switch(command)
+ {
+ case FIFO_NONE:
+ break;
+ case MIXCOMPLETE_ONARM9:
+ //REG_IME = 0;
+ soundsystem->soundcursor += soundsystem->numsamples;
+ if(soundsystem->format == 8)
+ while (soundsystem->soundcursor > soundsystem->buffersize) soundsystem->soundcursor -= soundsystem->buffersize;
+ else
+ while (soundsystem->soundcursor > (soundsystem->buffersize >> 1)) soundsystem->soundcursor -= (soundsystem->buffersize >> 1);
+ //REG_IME = 1;
+ break;
+ }
+ }
+}
+void SendCommandToArm9(u32 command)
+{
+ while (REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL);
+ if (REG_IPC_FIFO_CR & IPC_FIFO_ERROR)
+ {
+ REG_IPC_FIFO_CR |= IPC_FIFO_SEND_CLEAR;
+ }
+
+ REG_IPC_FIFO_TX = command;
+}
Property changes on: tiki/nds/arm7_template/source/sound7.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: tiki/nds/src/audio/stream.cpp
===================================================================
--- tiki/nds/src/audio/stream.cpp 2007-07-18 23:45:51 UTC (rev 424)
+++ tiki/nds/src/audio/stream.cpp 2007-07-21 17:52:01 UTC (rev 425)
@@ -4,13 +4,18 @@
stream.cpp
Copyright (C)2005 Cryptic Allusion, LLC
+
+ Portions based on the ARM9/ARM7 streaming code from
+ http://forum.gbadev.org/viewtopic.php?t=10739
*/
#include "pch.h"
#include "Tiki/stream.h"
-
#include <string.h>
+#include <nds.h>
+#include "soundcommon.h"
+
using namespace Tiki::Audio;
using namespace Tiki::Thread;
@@ -20,8 +25,85 @@
TIKI_OBJECT_RECEIVER("stop", Stream::objectStop)
TIKI_OBJECT_END(Stream)
+std::list<Stream *> streams;
+void MixTikiStream(Stream *s, void *stream,u32 len)
+{
+ int samples = len;
+ memset(stream,0,len);
+ if(s->isPlaying()) {
+ if(s->getData((uint16*)stream,&samples) != Stream::GDSuccess) {
+ s->stop();
+ }
+ }
+}
+
+void TikiStreamFiFoHandler(void)
+{
+ u32 command,remain;
+ std::list<Stream *>::iterator streams_iter;
+
+ while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) )
+ {
+ command = REG_IPC_FIFO_RX;
+
+ switch(command)
+ {
+ case FIFO_NONE:
+ break;
+ case UPDATEON_ARM9:
+ REG_IME = 0;
+ for(streams_iter = streams.begin(); streams_iter != streams.end(); streams_iter++) {
+ if(soundsystem->format == 8)
+ {
+ if((soundsystem->soundcursor + soundsystem->numsamples) > soundsystem->buffersize)
+ {
+ MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor],soundsystem->buffersize - soundsystem->soundcursor);
+ remain = soundsystem->numsamples - (soundsystem->buffersize - soundsystem->soundcursor);
+ MixTikiStream((*streams_iter),soundsystem->mixbuffer,remain);
+ }
+ else
+ {
+ MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor],soundsystem->numsamples);
+ }
+ }
+ else
+ {
+ if((soundsystem->soundcursor + soundsystem->numsamples) > (soundsystem->buffersize >> 1))
+ {
+ MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor << 1],(soundsystem->buffersize >> 1) - soundsystem->soundcursor);
+ remain = soundsystem->numsamples - ((soundsystem->buffersize >> 1) - soundsystem->soundcursor);
+ MixTikiStream((*streams_iter),soundsystem->mixbuffer,remain);
+ }
+ else
+ {
+ MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor << 1],soundsystem->numsamples);
+ }
+ }
+ }
+ REG_IME = 1;
+ SendCommandToArm7(MIXCOMPLETE_ONARM9);
+ break;
+ }
+ }
+}
+
+void SendCommandToArm7(u32 command)
+{
+ while (REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL);
+ if (REG_IPC_FIFO_CR & IPC_FIFO_ERROR)
+ {
+ REG_IPC_FIFO_CR |= IPC_FIFO_SEND_CLEAR;
+ }
+
+ REG_IPC_FIFO_TX = command;
+}
+
bool Stream::initGlobal() {
+ irqSet(IRQ_FIFO_NOT_EMPTY,&TikiStreamFiFoHandler);
+ irqEnable(IRQ_FIFO_NOT_EMPTY);
+
+ REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ;
return true;
}
@@ -30,18 +112,31 @@
Stream::Stream() {
// Default our members.
- m_bufSize = 0x4000;
+ m_bufSize = 16384;
m_chnCount = 2;
m_freq = 44100;
m_queueing = false;
m_state = StateStopped;
m_volume = 0.8f;
+
+ streams.push_back(this);
}
Stream::~Stream() {
+ streams.remove(this);
}
bool Stream::create() {
+ soundsystem->rate = m_freq;
+ soundsystem->buffersize = m_bufSize * sizeof(short);
+ soundsystem->mixbuffer = (s8*)malloc(soundsystem->buffersize);
+ soundsystem->format = 16;
+ soundsystem->channel = 0;
+ soundsystem->prevtimer = 0;
+ soundsystem->soundcursor = 0;
+ soundsystem->numsamples = 0;
+ soundsystem->period = 0x1000000 / m_freq;
+ soundsystem->cmd = INIT | MIX;
return true;
}
@@ -79,11 +174,12 @@
}
void Stream::pause() {
+ stop();
m_state = StatePaused;
}
void Stream::resume() {
- m_state = StatePlaying;
+ start();
}
void Stream::setVolume(float vol) {
Modified: tiki/nds/src/init_shutdown.cpp
===================================================================
--- tiki/nds/src/init_shutdown.cpp 2007-07-18 23:45:51 UTC (rev 424)
+++ tiki/nds/src/init_shutdown.cpp 2007-07-21 17:52:01 UTC (rev 425)
@@ -19,9 +19,26 @@
namespace Tiki {
bool init(int argc, char **argv) {
- REG_POWERCNT = POWER_ALL;
+ // Turn on everything
+ powerON(POWER_ALL);
+
+ // Setup the Main screen for 3D
+ videoSetMode(MODE_0_3D);
+ vramSetBankA(VRAM_A_TEXTURE);
+ lcdMainOnBottom();
+
+ // IRQ basic setup
irqInit();
+
+ // initialize the geometry engine
+ glInit();
+
+ // initialize libfat
fatInitDefault();
+
+ // initialize parallax
+ GL::Plxcompat::plx_mat3d_init(640, 480);
+ Audio::Stream::initGlobal();
return Hid::init();
}
Modified: tiki/nds/src/platgl.cpp
===================================================================
--- tiki/nds/src/platgl.cpp 2007-07-18 23:45:51 UTC (rev 424)
+++ tiki/nds/src/platgl.cpp 2007-07-21 17:52:01 UTC (rev 425)
@@ -36,6 +36,8 @@
}
void tiki_scene_finish_hook() {
+ glFlush(0);
+ swiWaitForVBlank();
}
void tiki_scene_begin_opaque_hook() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|