19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Lesser General Public
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2.1 of the License, or (at your option) any later version.
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Lesser General Public License for more details.
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Lesser General Public
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free Software
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h"
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef __SOUNDCOMMON_H
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define __SOUNDCOMMON_H
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <nds.h>
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define CLOCK (1 << 25)
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" {
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	NONE = 0,
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	INIT = 1,
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	MIX = 2,
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	MIXING = 4,
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	STOP = 8
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}CommandType;
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	FIFO_NONE = 0,
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	UPDATEON_ARM9 = 1,
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	MIXCOMPLETE_ONARM9 = 2,
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}FifoType;
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	s8 *mixbuffer;//,*soundbuffer;
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	u32 rate;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	u32 buffersize;
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	u32 cmd;
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	u8 channel,format;
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	u32 soundcursor,numsamples;
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	s32 prevtimer;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	s16 period;
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}S_SoundSystem;
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define soundsystem ((S_SoundSystem*)((u32)(IPC)+sizeof(TransferRegion)))
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef ARM9
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundSystemInit(u32 rate,u32 buffersize,u8 channel,u8 format);
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundStartMixer(void);
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SendCommandToArm7(u32 command);
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundVBlankIrq(void);
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundSwapAndMix(void);
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundSetTimer(int period);
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SoundFifoHandler(void);
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SendCommandToArm9(u32 command);
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
81