コード例 #1
0
ファイル: gbsnd.cpp プロジェクト: Nebuleon/GameYob
void playSample(int channel, const void* data, SoundFormat format, u32 dataSize, u32 freq, u8 volume, u8 pan, bool loop, u16 loopPoint){ 
    if (freq > 0xffff) {
        printLog("Bad sample frequency %x\n", freq);
        freq = 0xffff;
    }
    FifoMessage msg;

    msg.type = SOUND_PLAY_MESSAGE;
    msg.SoundPlay.data = data;
    msg.SoundPlay.freq = freq;
    msg.SoundPlay.volume = volume;
    msg.SoundPlay.pan = pan;
    msg.SoundPlay.loop = loop;
    msg.SoundPlay.format = format;
    msg.SoundPlay.loopPoint = loopPoint;
    msg.SoundPlay.dataSize = dataSize >> 2;
    msg.SoundPlay.channel = channel;

    fifoSendDatamsg(FIFO_USER_01, sizeof(msg), (u8*)&msg);

    /*
	while(!fifoCheckValue32(FIFO_USER_01));
    int useless = fifoGetValue32(FIFO_USER_01);
    */
}
コード例 #2
0
void CommandStopPlay(void) {

    NTXMFifoMessage command;
    command.commandType = STOP_PLAY;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #3
0
void CommandMicOff(void)
{
    NTXMFifoMessage command;
    command.commandType = MIC_OFF;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #4
0
ファイル: arm9_main.c プロジェクト: 0xtob/dsmi
void midiToArm7(u8 message, u8 data1, u8 data2)
{
	MidiMsg midimsg;
	midimsg.msg = message;
	midimsg.data1 = data1;
	midimsg.data2 = data2;
	fifoSendDatamsg(FIFO_MIDI, sizeof(midimsg), (u8*)&midimsg);
}
コード例 #5
0
ファイル: input.c プロジェクト: swolchok/dspython
void inputGetAndSend(void){

	static bool penDown = false;
	static int sleepCounter = 0;

	touchPosition tempPos = {0};
	FifoMessage msg = {0};

	u16 keys= REG_KEYXY;

	msg.SystemInput.keys = keys;

	if(keys & KEY_TOUCH)
	{
		penDown = false;	
	}
	else
	{
		msg.SystemInput.keys |= KEY_TOUCH;

		if(penDown)
		{
			touchReadXY(&tempPos);	
			
			if(tempPos.rawx && tempPos.rawy)
			{
				msg.SystemInput.keys &= ~KEY_TOUCH;
				msg.SystemInput.touch = tempPos;
			}
			else
			{
				penDown = false;
			}
		}
		else
		{
			penDown = true;
		}
	}	

	if(keys & KEY_LID) 
		sleepCounter++;
	else
		sleepCounter = 0;

	//sleep if lid has been closed for 20 frames
	if(sleepCounter >= 20) 
	{
		systemSleep();
		sleepCounter = 0;
	}

	msg.type = SYS_INPUT_MESSAGE; //set message type

	fifoSendDatamsg(FIFO_SYSTEM, sizeof(msg), (u8*)&msg);
}
コード例 #6
0
void CommandSetPatternLoop(bool state)
{
    NTXMFifoMessage command;
    command.commandType = PATTERN_LOOP;

    PatternLoopCommand* c = &command.ptnLoop;
    c->state = state;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #7
0
void CommandStopSample(int channel)
{
    NTXMFifoMessage command;
    StopSampleSoundCommand *ss = &command.stopSample;

    command.commandType = STOP_SAMPLE;
    ss->channel = channel;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #8
0
void CommandSetSong(void *song)
{
    NTXMFifoMessage command;
    SetSongCommand* c = &command.setSong;

    command.commandType = SET_SONG;
    c->ptr = song;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #9
0
void CommandStartRecording(u16* buffer, int length)
{
    NTXMFifoMessage command;
    StartRecordingCommand* sr = &command.startRecording;

    command.commandType = START_RECORDING;
    sr->buffer = buffer;
    sr->length = length;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #10
0
void CommandStopInst(u8 channel)
{
    NTXMFifoMessage command;
    command.commandType = STOP_INST;

    StopInstCommand* c = &command.stopInst;

    c->channel = channel;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #11
0
void CommandStartPlay(u8 potpos, u16 row, bool loop)
{
    NTXMFifoMessage command;
    StartPlayCommand* c = &command.startPlay;

    command.commandType = START_PLAY;
    c->potpos = potpos;
    c->row = row;
    c->loop = loop;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #12
0
ファイル: fifocommand9.cpp プロジェクト: alekhin0w/libntxm
int CommandStopRecording(void)
{
    NTXMFifoMessage command;
    command.commandType = STOP_RECORDING;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);

    while(!fifoCheckValue32(FIFO_NTXM))
        swiDelay(1);

    return (int)fifoGetValue32(FIFO_NTXM);
}
コード例 #13
0
void CommandPlayInst(u8 inst, u8 note, u8 volume, u8 channel)
{
    NTXMFifoMessage command;
    command.commandType = PLAY_INST;

    PlayInstCommand* c = &command.playInst;

    c->inst    = inst;
    c->note    = note;
    c->volume  = volume;
    c->channel = channel;

    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #14
0
ファイル: sound.c プロジェクト: hl1itj/Team5
int soundPlayNoise(u16 freq, u8 volume, u8 pan){
	FifoMessage msg;

	msg.type = SOUND_NOISE_MESSAGE;
	msg.SoundPsg.freq = freq;
	msg.SoundPsg.volume = volume;
	msg.SoundPsg.pan = pan;

	fifoSendDatamsg(FIFO_SOUND, sizeof(msg), (u8*)&msg);

	while(!fifoCheckValue32(FIFO_SOUND));

	return (int)fifoGetValue32(FIFO_SOUND);
}
コード例 #15
0
void CommandPlaySample(Sample *sample, u8 note, u8 volume, u8 channel)
{
    NTXMFifoMessage command;
    PlaySampleCommand* ps = &command.playSample;

    command.commandType = PLAY_SAMPLE;

    ps->sample = sample;
    ps->note = note;
    ps->volume = volume;
    ps->channel = channel;


    fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);
}
コード例 #16
0
ファイル: sndbase.c プロジェクト: CaitSith2/SSEQPlayer
void PlaySeq(const char* seqFile, const char* bnkFile, const char* war1, const char* war2, const char* war3, const char* war4)
{
	StopSeq();
	free_seq();
	curr_seq.msg = SNDSYS_PLAYSEQ;

	LoadFile(&curr_seq.seq, seqFile);
	LoadFile(&curr_seq.bnk, bnkFile);
	LoadFile(curr_seq.war + 0, war1);
	LoadFile(curr_seq.war + 1, war2);
	LoadFile(curr_seq.war + 2, war3);
	LoadFile(curr_seq.war + 3, war4);

	fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);
}
コード例 #17
0
ファイル: ds-avr-arm7.c プロジェクト: Wbuanguna/ds-avr
//---------------------------------------------------------------------------------
void avrDataHandler(int bytes, void *user_data) {
//---------------------------------------------------------------------------------
	AvrFifoMessage msg;
	int value;

	fifoGetDatamsg(FIFO_AVR, bytes, (u8*)&msg);
	
	if(msg.type == PROFILE_MESSAGE) {
    	long int i;
    	
		for(i=0;i < (50000);i++) {
		    swiDelay(10000);
		}
    	
    	fifoSendValue32(FIFO_AVR, (u32)1337 );
	} else if(msg.type == CONFIG_MESSAGE) {
	   	shortwait = WAIT_1MS * msg.SPIConfig.m1;
	   	speed = msg.SPIConfig.m2;
	   	spi_debug = msg.SPIConfig.debug;
	} else if(msg.type == LED_FLASH_MESSAGE) {
	    send_chars(2, FLASH_LED_COMMAND, msg.LEDFlash.count);
	} else if (msg.type == ANALOG_READ_MESSAGE) {
		send_chars(2, ANALOG_READ_COMMAND, msg.AnalogRead.pin);
		swiDelay(10000);
		send_chars(3, NULL_COMMAND, 0, 0);

		fifoSendDatamsg(FIFO_AVR, sizeof(incoming), incoming);
		//value = incoming[1];
		//value |= (incoming[2] << 8);
		/*value = read_increment(1);
		swiDelay(COMMAND_WAIT);
		value |= (read_increment(1) << 8);*/
		
		//fifoSendValue32(FIFO_AVR, (u32)value);
	} else if (msg.type == IO_PORT_GET_MESSAGE) {
		value = ioport_get(msg.IOPortGetSet.address);
		fifoSendValue32(FIFO_AVR, (u32)value);
	} else if (msg.type == IO_PORT_SET_MESSAGE) {
		ioport_set(msg.IOPortGetSet.address, msg.IOPortGetSet.value);
	} else if (msg.type == PWM_MESSAGE) {
		if(msg.PWM.command == PWM_ON) {
			if(msg.PWM.output == PWM5) {
				reg_orequal(TCCR2B, _BV(CS22));
				//TCCR2B |= CS22
			}
		}
	}
}
コード例 #18
0
int CommandStopRecording(void)
{
    NTXMFifoMessage command;
    command.commandType = STOP_RECORDING;

	fifoSetValue32Handler(FIFO_NTXM, 0, 0);
	fifoSendDatamsg(FIFO_NTXM, sizeof(command), (u8*)&command);

    while(!fifoCheckValue32(FIFO_NTXM))
        //swiDelay(1);
		DSWaitForIRQ(~0);

    int x = (int)fifoGetValue32(FIFO_NTXM);
	fifoSetValue32Handler(FIFO_NTXM, CommandRecvHandler, 0);
	return x;
}
コード例 #19
0
ファイル: sound.c プロジェクト: hl1itj/Team5
int soundMicRecord(void *buffer, u32 bufferLength, MicFormat format, int freq, MicCallback callback){
	FifoMessage msg;

	msg.type = MIC_RECORD_MESSAGE;
	msg.MicRecord.format = format;
	msg.MicRecord.buffer = buffer;
	msg.MicRecord.freq = freq;
	msg.MicRecord.bufferLength = bufferLength;

	micCallback = callback;

	fifoSetDatamsgHandler(FIFO_SOUND, micBufferHandler, 0);

	fifoSendDatamsg(FIFO_SOUND, sizeof(msg), (u8*)&msg);

	while(!fifoCheckValue32(FIFO_SOUND));

	return (int)fifoGetValue32(FIFO_SOUND);
}
コード例 #20
0
ファイル: sd.twl.c プロジェクト: ahezard/libnds
//---------------------------------------------------------------------------------
bool sdio_WriteSectors(sec_t sector, sec_t numSectors,const void* buffer) {
//---------------------------------------------------------------------------------
	FifoMessage msg;

	DC_FlushRange(buffer,numSectors * 512);

	msg.type = SDMMC_SD_WRITE_SECTORS;
	msg.sdParams.startsector = sector;
	msg.sdParams.numsectors = numSectors;
	msg.sdParams.buffer = (void*)buffer;
	
	fifoSendDatamsg(FIFO_SDMMC, sizeof(msg), (u8*)&msg);

	fifoWaitValue32(FIFO_SDMMC);

	int result = fifoGetValue32(FIFO_SDMMC);
	
	return result == 0;
}
コード例 #21
0
ファイル: arm7_main.cpp プロジェクト: elhobbs/quake2dsi
void send_mp3_stop_message(void)
{
	do_mp3 = 0;
	
	fifo_msg msg;
	msg.type = kStopMP3;
	fifoSendDatamsg(FIFO_7to9,sizeof(msg),(u8 *)&msg);
	while(!fifoCheckValue32(FIFO_7to9));
	int ret = (int)fifoGetValue32(FIFO_7to9);

	/*while (quake_ipc_7to9->message == 0xffffffff);
	
	quake_ipc_7to9->message_type = kStopMP3;
	quake_ipc_7to9->message = 0xffffffff;
	
	while (quake_ipc_7to9->message == 0xffffffff);*/
	
	ARM7_PRINT("mp3 stop message sent\n");
}
コード例 #22
0
ファイル: gbsnd.cpp プロジェクト: Nebuleon/GameYob
void playNoise(int channel, u32 freq, u8 volume, u8 pan){
    if (freq > 0xffff) {
        //printLog("Bad noise frequency %x\n", freq);
        freq = 0xffff;
    }
    FifoMessage msg;

    msg.type = SOUND_NOISE_MESSAGE;
    msg.SoundPsg.freq = freq;
    msg.SoundPsg.volume = volume;
    msg.SoundPsg.pan = pan;
    msg.SoundPsg.channel = channel;

    fifoSendDatamsg(FIFO_USER_01, sizeof(msg), (u8*)&msg);

    /*
	while(!fifoCheckValue32(FIFO_USER_01));
    int useless = fifoGetValue32(FIFO_USER_01);
    */
}
コード例 #23
0
ファイル: dsi_sd.c プロジェクト: hl1itj/Team5
//---------------------------------------------------------------------------------
bool sdio_ReadSectors(sec_t sector, sec_t numSectors,void* buffer) {
//---------------------------------------------------------------------------------
	if (!REG_DSIMODE) return false;
	FifoMessage msg;

	DC_FlushRange(buffer,numSectors * 512);

	msg.type = SDMMC_SD_READ_SECTORS;
	msg.sdParams.startsector = sector;
	msg.sdParams.numsectors = numSectors;
	msg.sdParams.buffer = buffer;
	
	fifoSendDatamsg(FIFO_SDMMC, sizeof(msg), (u8*)&msg);

	while(!fifoCheckValue32(FIFO_SDMMC));

	int result = fifoGetValue32(FIFO_SDMMC);
	
	return result == 0;
}
コード例 #24
0
ファイル: sound.c プロジェクト: hl1itj/Team5
int soundPlaySample(const void* data, SoundFormat format, u32 dataSize, u16 freq, u8 volume, u8 pan, bool loop, u16 loopPoint){ 
	
	FifoMessage msg;

	msg.type = SOUND_PLAY_MESSAGE;
	msg.SoundPlay.data = data;
	msg.SoundPlay.freq = freq;
	msg.SoundPlay.volume = volume;
	msg.SoundPlay.pan = pan;
	msg.SoundPlay.loop = loop;
	msg.SoundPlay.format = format;
	msg.SoundPlay.loopPoint = loopPoint;
	msg.SoundPlay.dataSize = dataSize >> 2;

	fifoSendDatamsg(FIFO_SOUND, sizeof(msg), (u8*)&msg);

	while(!fifoCheckValue32(FIFO_SOUND));

	return (int)fifoGetValue32(FIFO_SOUND);
}
コード例 #25
0
ファイル: sndbase.c プロジェクト: CaitSith2/SSEQPlayer
void StopSeq()
{
	sndsysMsg msg;
	msg.msg = SNDSYS_STOPSEQ;
	fifoSendDatamsg(FIFO_SNDSYS, sizeof(msg), (u8*) &msg);
}
コード例 #26
0
ファイル: sndbase.c プロジェクト: CaitSith2/SSEQPlayer
void FadeSeq()
{
	sndsysMsg msg;
	msg.msg = SNDSYS_FADESEQ;
	fifoSendDatamsg(FIFO_SNDSYS, sizeof(msg), (u8*) &msg);
}
コード例 #27
0
ファイル: sndbase.c プロジェクト: CaitSith2/SSEQPlayer
void PlaySeqNDS(const char* ndsFile, const u32 SSEQOffset, const u32 SSEQSize, const u32 BANKOffset, const u32 BANKSize, const u32 WAVEARC1Offset, const u32 WAVEARC1Size, const u32 WAVEARC2Offset, const u32 WAVEARC2Size, const u32 WAVEARC3Offset, const u32 WAVEARC3Size, const u32 WAVEARC4Offset, const u32 WAVEARC4Size)
{
	StopSeq();
	swiWaitForVBlank();
	swiWaitForVBlank();
	//free_seq();
	curr_seq.msg = SNDSYS_PLAYSEQ;

	if((SSEQOffset==curr_seq_offset[0])&&(SSEQSize==curr_seq_size[0]))
	{
		iprintf("SSEQ Already Loaded.\n");
	}
	else
	{
		free_pdata(&curr_seq.seq);
		curr_seq_offset[0]=SSEQOffset;
		curr_seq_size[0]=SSEQSize;
		iprintf("Loading SSEQ.\n");
		LoadNDS(&curr_seq.seq, ndsFile, SSEQOffset, SSEQSize);
	}

	if((BANKOffset==curr_seq_offset[1])&&(BANKSize==curr_seq_size[1]))
	{
		iprintf("BANK Already Loaded.\n");
	}
	else
	{
		free_pdata(&curr_seq.bnk);
		curr_seq_offset[1]=BANKOffset;
		curr_seq_size[1]=BANKSize;
		iprintf("Loading BANK.\n");
		LoadNDS(&curr_seq.bnk, ndsFile, BANKOffset, BANKSize);
	}

	if((WAVEARC1Offset==curr_seq_offset[2])&&(WAVEARC1Size==curr_seq_size[2]))
	{
		if(WAVEARC1Offset != 0)
			iprintf("WAVEARC1 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 0);
		curr_seq_offset[2]=WAVEARC1Offset;
		curr_seq_size[2]=WAVEARC1Size;
		if(WAVEARC1Offset != 0)
		{
			iprintf("Loading WAVEARC1.\n");
			LoadNDS(curr_seq.war + 0, ndsFile, WAVEARC1Offset, WAVEARC1Size);
		}
	}
	
	if((WAVEARC2Offset==curr_seq_offset[3])&&(WAVEARC2Size==curr_seq_size[3]))
	{
		if(WAVEARC2Offset != 0)
			iprintf("WAVEARC2 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 1);
		curr_seq_offset[3]=WAVEARC2Offset;
		curr_seq_size[3]=WAVEARC2Size;
		if(WAVEARC2Offset != 0)
		{
			iprintf("Loading WAVEARC2.\n");
			LoadNDS(curr_seq.war + 1, ndsFile, WAVEARC2Offset, WAVEARC2Size);
		}
	}

	if((WAVEARC3Offset==curr_seq_offset[4])&&(WAVEARC3Size==curr_seq_size[4]))
	{
		if(WAVEARC3Offset != 0)
			iprintf("WAVEARC3 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 2);
		curr_seq_offset[4]=WAVEARC3Offset;
		curr_seq_size[4]=WAVEARC3Size;
		if(WAVEARC3Offset != 0)
		{
			iprintf("Loading WAVEARC3.\n");
			LoadNDS(curr_seq.war + 2, ndsFile, WAVEARC3Offset, WAVEARC3Size);
		}
	}

	if((WAVEARC4Offset==curr_seq_offset[5])&&(WAVEARC4Size==curr_seq_size[5]))
	{
		if(WAVEARC4Offset != 0)
			iprintf("WAVEARC4 Already Loaded\n");
	}
	else
	{
		free_pdata(curr_seq.war + 3);
		curr_seq_offset[5]=WAVEARC4Offset;
		curr_seq_size[5]=WAVEARC4Size;
		if(WAVEARC4Offset != 0)
		{
			iprintf("Loading WAVEARC4.\n");
			LoadNDS(curr_seq.war + 3, ndsFile, WAVEARC4Offset, WAVEARC4Size);
		}
	}

	fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);
}
コード例 #28
0
ファイル: template.c プロジェクト: CaitSith2/SSEQPlayer
int main(int _argc, char **_argv)
{
    consoleDemoInit();
    InstallSoundSys();

    argc=_argc;
    argv=_argv;
    if(!fatInitDefault())
    {
        iprintf("Filesystem FAIL");
        for(;;) swiWaitForVBlank();
    }

    CurrentFile = 0;

    ReadDIR();
    ShowDIR();

    CurrentSPS=malloc(768);
    if(readFrontend(CurrentSPS)) {
        ReadSPS();
    } else {
        free(CurrentSPS);
        CurrentSPS=NULL;
    }

    for(;;)
    {
        if(CurrentSSEQ != LastSSEQ)
        {
            LastSSEQ = CurrentSSEQ;
            scrollpos = 0;
            scrollposcounter = 10;
        }
        if(CurrentFile != LastFile)
        {
            LastFile = CurrentFile;
            scrollpos = 0;
            scrollposcounter = 10;
        }

        if(scrollposcounter==0)
        {
            scrollposcounter=10;
            if(!scrollposdirection)
            {
                //RIGHT
                if(scrollpos<scrollposmax)
                {
                    scrollpos++;
                }
                else
                {
                    scrollposdirection = 1;
                    scrollposcounter = 120;
                }
            }
            else
            {
                //LEFT
                if(scrollpos>0)
                {
                    scrollpos--;
                }
                else
                {
                    scrollposdirection = 0;
                    scrollposcounter = 120;
                }
            }
        }
        else
        {
            scrollposcounter--;
        }
        if(!PlayMode)
        {
            message_pointer = 0;	//Ignore any incoming debug messages.
            if(SSEQMode)
                ShowSSEQ();
            else
                ShowDIR();
        }
        swiWaitForVBlank();
        if(PlayMode)
        {
            j = message_pointer;
            for(i=0; i<j; i+=6)
            {
                if(message_data[i])
                {
#ifdef SNDSYS_DEBUG
                    iprintf("cmd = %.2X:%.2X",message_data[i+1],message_data[i+2]);
                    if(message_data[i]==3)
                        iprintf(":%.2X\n",message_data[i+3]);
                    else
                        iprintf("\n");
#endif
                    switch (message_data[i+1])
                    {
#ifdef SNDSYS_DEBUG
                    case 0x00:
                        iprintf("00 Unrecognized record: %d\n",message_data[i+2]);
                        break;
                    case 0x04:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("04 SEQUENCE IS MULTI-TRACK\n");
                        break;
                    case 0x03:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("03 SEQUENCE IS SINGLE-TRACK\n");
                        break;
                    case 0x05:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("05 CREATED TRACK %d\n",message_data[i+2]);
                        break;
#endif
                    case 0x06:
                        if(PlayMode)
                            iprintf("06 SEQUENCE STOPPED\n");
                        if(PlayMode && AutoPlay && !ManualStop)
                        {
                            if(CurrentSSEQ < SSEQCount - 1)
                            {
                                CurrentSSEQ++;
                                ReadSSEQ();
                            }

                        }
                        ManualStop = false;
                        break;
                    case 0x07:
                        if(PlayMode)
                            iprintf("07 Track has looped twice\n");
                        if(PlayMode && AutoPlay)
                        {
                            FadeSeq();
                        }
                        break;
                    case 0x08:
                        if(PlayMode)
                            iprintf("08 Track has ended\n");
                        if(PlayMode && AutoPlay)
                        {
                            if(CurrentSSEQ < SSEQCount - 1)
                            {
                                CurrentSSEQ++;
                                ReadSSEQ();
                            }
                        }
                        break;

                    case 0xC1: // Track Volume
                        iprintf("%X:", message_data[i+5]);
                        iprintf("C1     Track Volume: %d\n", message_data[i+2]);
                        break;

                    case 0xC2: // MASTER VOLUME
                        iprintf("%X:", message_data[i+5]);
                        iprintf("C2    MASTER VOLUME: %d\n", message_data[i+2]);
                        break;

#ifdef SNDSYS_DEBUG
                    case 0x94: // JUMP
                        iprintf("%X:",message_data[i+5]);
                        iprintf("94     POSITION JUMP:\n");
                        break;
                    case 0xC3: // TRANSPOSE
                        iprintf("C3         TRANSPOSE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xC8: // TIE
                        iprintf("C8               TIE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xC9: // PORTAMENTO
                        iprintf("C9        PORTAMENTO: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCA: // MODULATION DEPTH
                        iprintf("CA  MODULATION DEPTH: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCB: // MODULATION SPEED
                        iprintf("CB  MODULATION SPEED: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCC: // MODULATION TYPE
                        iprintf("CC   MODULATION TYPE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCD: // MODULATION RANGE
                        iprintf("CD  MODULATION RANGE: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCE: // PORTAMENTO ON/OFF
                        iprintf("CE PORTAMENTO ON/OFF: %.2X\n",message_data[i+2]);
                        break;
                    case 0xCF: // PORTAMENTO TIME
                        iprintf("CF   PORTAMENTO TIME: %.2X\n",message_data[i+2]);
                        break;
                    case 0xD4: //LOOP START
                        iprintf("%X:",message_data[i+5]);
                        iprintf("D4        LOOP START: %d\n",message_data[i+2]);
                        break;
                    case 0xD6: // PRINT VAR
                        iprintf("D6         PRINT VAR: %.2X\n",message_data[i+2]);
                        break;

                    case 0xE0: // MODULATION DELAY
                        iprintf("E0  MODULATION DELAY: %.2X %.2X\n",message_data[i+2],message_data[i+3]);
                        break;
                    case 0xE3: // SWEEP PITCH
                        iprintf("E3       SWEEP PITCH: %.2X %.2X\n",message_data[i+2],message_data[i+3]);
                        break;
                    case 0xFC:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("FC          LOOP END:\n");
                        break;
                    case 0xFF:
                        iprintf("%X:",message_data[i+5]);
                        iprintf("FF      END OF TRACK:\n");
                        break;
                    default:
                        iprintf("%.2X  Unrecognized cmd: %.2X %.2X %.2X",message_data[i+1],message_data[i+2],message_data[i+3],message_data[i+4]);
                        break;
#endif
                    }
                }
            }
            message_pointer -= j;
        }
        scanKeys();
        if (keysDown() & KEY_A)
        {
            if(PlayMode)
            {
                fifoSendDatamsg(FIFO_SNDSYS, sizeof(curr_seq), (u8*) &curr_seq);	//User may have stopped current sequence.
            }
            else
            {
                if(SSEQMode)
                {
                    ReadSSEQ();
                }
                else
                {
                    if (CurrentSPS != NULL)
                    {
                        free(CurrentSPS);
                    }

                    CurrentSPS = malloc(23 + strlen(DIRList[CurrentFile])+1);
                    strcpy(CurrentSPS, "/data/NDS Music Player/");
                    strcat(CurrentSPS, DIRList[CurrentFile]);
                    CurrentSPS[23 + strlen(DIRList[CurrentFile])]=0;

                    ReadSPS();
                }
            }
        }

        if (keysDown() & KEY_B)
        {
            if(PlayMode)
            {
                PlayMode = false;
                SSEQMode = true;
                ShowSSEQ();
            }
            else
            {
                if(SSEQMode)
                {
                    SSEQMode = false;
                    ShowDIR();
                }
                else
                {
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_X)
        {
            ManualStop = true;
            StopSeq();
        }
        if (keysDown() & KEY_Y)
        {
            ManualStop = true;
            FadeSeq();
        }

        if(keysDown() & KEY_SELECT)
        {
            AutoPlay = !AutoPlay;
            if(PlayMode)
            {
                if(AutoPlay)
                    iprintf("Auto Play enabled\n");
                else
                    iprintf("Auto Play disabled\n");
            }
        }

        if(keysDown() & KEY_START)
        {
            PauseSeq();
        }

        if (keysDown() & KEY_UP)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ > 0)
                    {
                        CurrentSSEQ--;
                    }
                    else
                    {
                        CurrentSSEQ = SSEQCount - 1;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile > 0)
                    {
                        CurrentFile--;
                    }
                    else
                    {
                        CurrentFile = FileCount;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_DOWN)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ < SSEQCount - 1)
                    {
                        CurrentSSEQ++;
                    }
                    else
                    {
                        CurrentSSEQ = 0;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile < FileCount)
                    {
                        CurrentFile++;
                    }
                    else
                    {
                        CurrentFile = 0;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_LEFT)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ >= 23)
                    {
                        CurrentSSEQ -= 23;
                    }
                    else
                    {
                        CurrentSSEQ = 0;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile >= 23)
                    {
                        CurrentFile -= 23;
                    }
                    else
                    {
                        CurrentFile = 0;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_RIGHT)
        {
            if(PlayMode)
            {
            }
            else
            {
                if(SSEQMode)
                {
                    if(CurrentSSEQ < (SSEQCount - 24))
                    {
                        CurrentSSEQ += 23;
                    }
                    else
                    {
                        CurrentSSEQ = SSEQCount - 1;
                    }
                    ShowSSEQ();
                }
                else
                {
                    if(CurrentFile < (FileCount - 24))
                    {
                        CurrentFile += 23;
                    }
                    else
                    {
                        CurrentFile = FileCount;
                    }
                    ShowDIR();
                }
            }
        }

        if (keysDown() & KEY_L)
        {
            if (PlayMode)
            {
                if(CurrentSSEQ > 0)
                {
                    CurrentSSEQ--;
                }
                else
                {
                    CurrentSSEQ = SSEQCount - 1;
                }
                ReadSSEQ();
            }
        }

        if (keysDown() & KEY_R)
        {
            if (PlayMode)
            {
                if(CurrentSSEQ < SSEQCount - 1)
                {
                    CurrentSSEQ++;
                }
                else
                {
                    CurrentSSEQ = 0;
                }
                ReadSSEQ();
            }
        }
    }
}
コード例 #29
0
ファイル: sndbase.c プロジェクト: CaitSith2/SSEQPlayer
void PauseSeq()
{
	sndsysMsg msg;
	msg.msg = SNDSYS_PAUSESEQ;
	fifoSendDatamsg(FIFO_SNDSYS, sizeof(msg), (u8*) &msg);
}