Exemple #1
0
int main()
{
	irqInit();
	fifoInit();

	readUserSettings();
	initClockIRQ();

	SetYtrigger(80);

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VCountHandler);
	irqSet(IRQ_VBLANK, 0);
	irqEnable(IRQ_VBLANK|IRQ_VCOUNT|IRQ_NETWORK);

	powerOn(POWER_SOUND);
	REG_SOUNDCNT = SOUND_ENABLE | SOUND_VOL(127);

	static Player oPlayer;
	Player_Init(& oPlayer);

	while ( 1 )
	{
		swiWaitForVBlank();

		Player_Execute(& oPlayer);
	}

	return 0;
}
Exemple #2
0
int main()
{
	readUserSettings();
	ledBlink(0);

	irqInit();
	initClockIRQ();
	fifoInit();

	SetYtrigger(80);

	installWifiFIFO();
	//installSoundFIFO();
	installSystemFIFO();
	installFeOSFIFO();

	coopIrqSet(IRQ_VCOUNT, VCountHandler);

	irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

	setPowerButtonCB(powerButtonCB);

	while (!exitflag)
	{
		coopWaitForVBlank();
		FeOS_VBlankFunc();
		if (!(REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R)))
			break;
		Wifi_Update();
	}
	return 0;
}
//---------------------------------------------------------------------------------
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);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);  
	
	irqSet(IRQ_TIMER0, playTimerHandler);
	irqEnable(IRQ_TIMER0);
	
	player = new Player(playTimerHandler);
	player->registerTickCallback(onTick);
	player->registerPatternChangeCallback(onPatternChange);

	// Keep the ARM7 idle
	while (1) swiWaitForVBlank();
}
//---------------------------------------------------------------------------------
int main() {
//---------------------------------------------------------------------------------
	irqInit();
	fifoInit();

	// read User Settings from firmware
	readUserSettings();

	// Start the RTC tracking IRQ
	initClockIRQ();

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	mmInstall(FIFO_MAXMOD);

	installSystemFIFO();
	
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);   

	// Keep the ARM7 mostly idle
	while (1) swiWaitForVBlank();
}
Exemple #5
0
//---------------------------------------------------------------------------------
int main( ) {
    //---------------------------------------------------------------------------------
    readUserSettings( );

    irqInit( );
    // Start the RTC tracking IRQ
    initClockIRQ( );
    fifoInit( );
    touchInit( );

    mmInstall( FIFO_MAXMOD );

    SetYtrigger( 80 );

    installWifiFIFO( );
    installSoundFIFO( );

    installSystemFIFO( );

    irqSet( IRQ_VCOUNT, VcountHandler );
    irqSet( IRQ_VBLANK, VblankHandler );

    irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK );

    setPowerButtonCB( powerButtonCB );

    // Keep the ARM7 mostly idle
    while( !exitflag ) {
        if( 0 == ( REG_KEYINPUT & ( KEY_SELECT | KEY_START | KEY_L | KEY_R ) ) ) {
            exitflag = true;
        }
        swiWaitForVBlank( );
    }
    return 0;
}
Exemple #6
0
int main(void) {
  REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;
IPC->mailData=0;
IPC->mailSize=0; 
  PA_SoundBusyInit = 0;

  
	PA_Init();
	irqInit();
	irqSet(IRQ_VBLANK, PA_VBL);
	irqEnable(IRQ_VBLANK);
	irqSet(IRQ_TIMER0, timer0);
	irqEnable(IRQ_TIMER0);	
	
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);
//	irqSet(IRQ_TIMER3, ProcessMicrophoneTimerIRQ);
//	irqEnable(IRQ_TIMER3);	

	//swiWaitForVBlank();
	//swiWaitForVBlank();
	
	//supprime pour test
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt
	irqEnable(IRQ_WIFI);
  
	//swiWaitForVBlank();
	//swiWaitForVBlank();
  
 //supprime pour test
  SndInit7 ();
    
  u32 fifo_temp;   

while(1) { // wait for magic number
	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; // give next value to wifi_init
Wifi_Init(fifo_temp);

irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
irqEnable(IRQ_FIFO_NOT_EMPTY);
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9

  // Keep the ARM7 out of main RAM

  while (1) {
	swiWaitForVBlank();
	}
  return 0;
}
Exemple #7
0
int main() {
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;
	IPC->mailData=0;
	IPC->mailSize=0; 
	PA_SoundBusyInit = 0;

  
	PA_Init();
	irqInit();
	irqSet(IRQ_VBLANK, PA_VBL);
	irqEnable(IRQ_VBLANK);
	irqSet(IRQ_TIMER2, timer2);
	irqEnable(IRQ_TIMER2);
	
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);
	
	//supprime pour test
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt
	irqEnable(IRQ_WIFI);
  
	//supprime pour test
	SndInit7 ();
	
	// Initialize AS_Lib
	AS_Init();
    
	u32 fifo_temp;   
	while(1) { // wait for magic number
		while (REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY)
		{
			AS_MP3Engine();
			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; // give next value to wifi_init
	Wifi_Init(fifo_temp);

	irqSet(IRQ_FIFO_NOT_EMPTY, arm7_fifo); // set up fifo irq
	irqEnable(IRQ_FIFO_NOT_EMPTY);
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

	Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9

	while (1) {
		AS_MP3Engine();
		swiWaitForVBlank();
	}
	
	return 0;
}
Exemple #8
0
//---------------------------------------------------------------------------------
void VcountHandler() {
//---------------------------------------------------------------------------------
	static int lastbut = -1;
	
	uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0;

	but = REG_KEYXY;

	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);

}
Exemple #9
0
//---------------------------------------------------------------------------------
int main() {
	u32 i=0;
//---------------------------------------------------------------------------------
	readUserSettings();

	irqInit();
	// Start the RTC tracking IRQ
	initClockIRQ();
	fifoInit();

	//mmInstall(FIFO_MAXMOD);
	InstallSoundSys();

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);
	
	setPowerButtonCB(powerButtonCB);   

	// Keep the ARM7 mostly idle
	while (!exitflag) {
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
		swiWaitForVBlank();
		if(seq_status==STATUS_FADING)
		{
			if(i<24)
			{
				i+=10;
			}
			else
			{
				i-=24;
				ADSR_mastervolume--;
				if(!ADSR_mastervolume)
					StopSeq();
			}
		}
	}
	return 0;
}
bool _interruptController::init()
{
	// Reset stack count
	_interruptController::criticalCount = 0;
	
	// Set the number of scanlines after which the Vertical Count Interrupt is fired
	SetYtrigger( 0 );
	
	// Set handler for Vertical Blank Interrupt
	irqSet( IRQ_VBLANK , &_interruptController::vblHandler );
	
	// Enable Interrupts
	irqEnable( IRQ_VBLANK | IRQ_VCOUNT );
	
	return true;
}
Exemple #11
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
    // read User Settings from firmware
    readUserSettings();
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & prepare fifo asap
    rtcReset();

    //enable sound
    powerON(POWER_SOUND);
    writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
    SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

    irqInit();

    // Start the RTC tracking IRQ
    initClockIRQ();

    SetYtrigger(80);
    irqSet(IRQ_VCOUNT, VcountHandler);
    irqSet(IRQ_VBLANK, VblankHandler);
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt

    irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_WIFI);

    {   // sync with arm9 and init wifi
        u32 fifo_temp;

        while(1) { // wait for magic number
            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; // give next value to wifi_init
        Wifi_Init(fifo_temp);

        irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
        irqEnable(IRQ_FIFO_NOT_EMPTY);
        REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

        Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9
    } // arm7 wifi init complete


    // Keep the ARM7 mostly idle
    while (1) swiWaitForVBlank();
}
Exemple #12
0
int main(int argc, char ** argv)
{
	u32 fifo_temp;   
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

	// 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);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);

	irqSet(IRQ_TIMER0, tob_ProcessMicrophoneTimerIRQ);
	tob_MIC_On();

	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,arm7_fifo);
	irqEnable(IRQ_FIFO_NOT_EMPTY);
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

	Wifi_SetSyncHandler(arm7_synctoarm9);

	// Keep the ARM7 idle
	while(1) swiWaitForVBlank();
}
Exemple #13
0
//---------------------------------------------------------------------------------
int main() {
//---------------------------------------------------------------------------------
	irqInit();
	fifoInit();

	int channel = -1;

	// read User Settings from firmware
	readUserSettings();

	// Start the RTC tracking IRQ
	initClockIRQ();

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	mmInstall(FIFO_MAXMOD);

	installSystemFIFO();
	
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);   


	//sound play




	// ARM 7 sweeps up FIFO_USER_01 and plays the notes left there.
	while (1) {
		/* while (fifoGetDatamsg(FIFO_USER_01, int buffersize, u8 * destbuffer) != -1)
		channel = getFreePSGChannel();
		BIT(24);
		BIT(25);
		swiWaitForVBlank(); */


	}
}
Exemple #14
0
//---------------------------------------------------------------------------------
int main() {
//---------------------------------------------------------------------------------
	// clear sound registers
	dmaFillWords(0, (void*)0x04000400, 0x100);

	REG_SOUNDCNT |= SOUND_ENABLE;
	writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
	powerOn(POWER_SOUND);

	readUserSettings();
	ledBlink(0);

	irqInit();
	// Start the RTC tracking IRQ
	initClockIRQ();
	fifoInit();

	mmInstall(FIFO_MAXMOD);

	SetYtrigger(80);

	installWifiFIFO();
	installSoundFIFO();

	installSystemFIFO();

	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_VBLANK, VblankHandler);

	irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

	setPowerButtonCB(powerButtonCB);

	// Keep the ARM7 mostly idle
	while (!exitflag) {
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
		swiWaitForVBlank();
	}
	return 0;
}
Exemple #15
0
int
main()
{
    irqInit();
    fifoInit();
    readUserSettings();
    initClockIRQ();
    SetYtrigger(80);
    installSystemFIFO();

    irqSet(IRQ_VCOUNT, isrVCount);
    irqEnable(IRQ_VCOUNT);

    SoundEngine::init();

    while (1) {
        swiWaitForVBlank();
    }

    return 0;
}
Exemple #16
0
int ARM7_MAIN(void)
{
    readUserSettings();

    // init irq
    irqInit();
    initClockIRQ();

    // init irq callback
    irqSet(IRQ_VCOUNT, IRQ_VCount);
    irqSet(IRQ_VBLANK, IRQ_VBlank);
    irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

    // init fifo system
    fifoInit();

    // install fifo subsystems
    installWifiFIFO();
    installSoundFIFO();
    installSystemFIFO();
    mmInstall(FIFO_MAXMOD);

    // init fifo callback for arm9 communication
    fifoSetDatamsgHandler(FIFO_USER_01, I_PollArm9Messages, 0);

    SetYtrigger(80);
    setPowerButtonCB(powerButtonCB);   

    // Keep the ARM7 mostly idle
    while(!exitflag)
    {
        if(0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R)))
            exitflag = true;

	    swiIntrWait(1, IRQ_FIFO_NOT_EMPTY | IRQ_VBLANK);
    }

	return 0;
}
Exemple #17
0
void VcountHandler()
{
	static int lastbut = -1;
	uint8 ct[sizeof(IPC->time.rtc)];
	
	uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0;

	but = REG_KEYXY;

	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;
		}
	}
    // Read the time
    rtcGetTime((uint8 *)ct);
    BCDToInteger((uint8 *)&(ct[1]), 7); 
	u8 i;
	u8 *temp;
	temp = (u8*)&IPC->time.rtc;
	for(i=0; i<sizeof(ct); i++)
	{
		temp[i] = ct[i];
	} 

	IPC->buttons		= but;
	vcount ^= (80 ^ 130);
	SetYtrigger(vcount);
}
Exemple #18
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
	readUserSettings();
	
	irqInit();
	initClockIRQ();
	fifoInit();
	
	SetYtrigger(80);
#ifdef USE_WIFI
	installWifiFIFO();
#endif
	//installSoundFIFO();
	installSystemFIFO();

 	//TIMER_CR(0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_1;

	vcount = 80;
	irqSet(IRQ_VBLANK, VblankHandler);
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqSet(IRQ_HBLANK, hblank_handler);

	irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_HBLANK);
	
	setPowerButtonCB(powerButtonCB);   
	
	fifoSetDatamsgHandler(FIFO_9to7, fifo_DataHandler, 0);

//	irqSet(IRQ_LID, lid);
//	irqEnable(IRQ_LID);
	
#ifdef IPC_IN_TIMER
	irqSet(IRQ_TIMER0, handle_ipc);
	TIMER_DATA(0) = TIMER_FREQ_256(20 * 60);
 	TIMER_CR(0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_256;
#endif
	
#ifdef USE_WIFI
#ifndef WIFI_ON_DEMAND
	wifi_go();
#endif
#endif

#ifdef USE_ADHOC
	IPC_Init() ;
	LWIFI_Init() ;
#endif
	
	// Keep the ARM7 idle
	while (!exitflag)
	{
		//ARM7_PRINT("arm7 ");
		if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
			exitflag = true;
		}
#ifdef USE_ADHOC
		LWIFI_IPC_UpdateNOIRQ() ;
#endif
		if (do_mp3 != 0)
		{
#ifdef USE_MP3
			ds_enable_interrupts(0);
			if (helix_initialised == 0)
			{
				ARM7_PRINT("beginning helix init\n");
				helix_init();
				ARM7_PRINT("helix init done\n");
				
				helix_initialised = 1;
			}
			
			char helix_argv1[100];
			char helix_argv2[100];
			memset(helix_argv1, 0, 100);
			memset(helix_argv2, 0, 100);
			strcpy(helix_argv1, "/jones.mp3");
//			sprintf(helix_argv1, "/quake soundtrack/0%d-AudioTrack 0%d.mp3", mp3_track_no, mp3_track_no);
//			strcpy(helix_argv2, "/jones.pcm");
			
			char *proper_helix_argv[3];
			proper_helix_argv[0] = NULL;
			proper_helix_argv[1] = helix_argv1;
//			proper_helix_argv[1] = (char *)track_name;
			proper_helix_argv[2] = helix_argv2;
			
			ARM7_PRINT("Starting Helix...\n");
			decoder_stopped = 0;
			
			ds_enable_interrupts(1);		
			helix_main(3, proper_helix_argv);
			ds_enable_interrupts(0);
			
			decoder_stopped = 1;
			ARM7_PRINT("out of helix\n");
//			ARM7_HALT();
			send_mp3_stop_message();
			
			ds_enable_interrupts(1);
#endif
		}

//		if (REG_KEYXY & (1 << 7))
//		{
//			while (quake_ipc_7to9->message == 0xffffffff);
//			
//			quake_ipc_7to9->message_type = kLidHasClosed;
//			quake_ipc_7to9->message = 0xffffffff;
//			
//			while (quake_ipc_7to9->message == 0xffffffff);
//			
//			ARM7_PRINT("ARM7: waiting...\n");
//			while (REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY);
//			ARM7_PRINT("ARM7: disabling interrupts\n");
//			
//			irqDisable(IRQ_HBLANK);
//			irqDisable(IRQ_VBLANK);
//			irqDisable(IRQ_VCOUNT);
//			
////			irqEnable(IRQ_LID);
//			
//			powerOFF(POWER_SOUND);
//			
//			swiWaitForVBlank();			//wake up when the lid re-enables the interrupt
//		}
		
		if (arm7_initialised && ((hblanks & 0x3f) == 0))
		{
			arm7_initialised = 1;
			//ARM7_PRINT("ping");
			//while (quake_ipc_7to9->message == 0xffffffff);
			
			//quake_ipc_7to9->message_type = kPing;
			//quake_ipc_7to9->message = 0xffffffff;
			//while (quake_ipc_7to9->message == 0xffffffff);
		}
			
//		int total = 0;
//		for (int count = 0 ; count < 16; count++)
//			if (!is_channel_enabled(count))
//				total++;
//		if (free_time == kFreeTime)
//			ARM7_PRINTF("%d channels free\n", total);
		
//		if (free_time == kFreeTime)
//			if (needs_defrag())
//			{
//				ARM7_PRINT("NEEDS DEFRAG\n");
//				defrag(&free_time);
//			}
		
//		swiWaitForVBlank();

#ifdef IPC_IN_MAIN_THREAD
		//handle_ipc();
#endif
//		if (arm7_initialised == true)
//		{
////			temp_test();
//			
//			arm7_initialised = false;
//			ARM7_PRINT("installing exception handler\n");
//			install();
//			register unsigned int sp asm ("13");
//			ARM7_PRINT("done\nlet\'s try and crash it\n");
//			/*ARM7_PRINT_NUMBER(sp);*/
//			
////			asm("LDR r12,=MyReg2\n"
////				"STMIA r12,{r0-r15}\n"
////					:
////					:
////					: "r12");
//			
////			ARM7_PRINT_NUMBER(MyReg2[12]);
//			
////			for (int count = 0; count < 16; count++)
////				ARM7_PRINT_NUMBER(MyReg2[count]);
////			ARM7_PRINT("\n");
////			while(1);
////			asm (".word 0xffffffff");
////			asm (".word 0x0");
//			
//			
////			Exception();
//	
////			asm (".word 0xe6000010");
//			
////			asm("LDR r12,=MyReg2\n"
////				"STMIA r12,{r0-r15}\n"
////					:
////					:
////					: "r12");
////			
////			for (int count = 0; count < 8; count++)
////			{
////				ARM7_PRINT_NUMBER(MyReg[count + 8]);
////				ARM7_PRINT_NUMBER(MyReg2[count + 8]);
////			}
//			
//			
////			asm ("mcr 15,0,r0,c0,c0,0");
////			asm ("bkpt");
////			*(int *)0 = 0;
////			asm ("b debugger_hit");
////			debugger_hit();
////			debugger_handle_breakpoint(0,0,0);
//			
////			asm (".word 0xe6000010");
////			asm (".short 0xe801");
//			ARM7_PRINT("shouldn\'t make it here\n");
//			ARM7_PRINT_NUMBER(ProperCPSR);
//			while(1);
//		}
		swiIntrWait(1, 1);
	}
}
Exemple #19
0
/**********************************************************************************
 * main
 *
 * Program Entry Point
 **********************************************************************************/
int main( void ) {
//---------------------------------------------------------------------------------

    //----------------------------------------------------------------
    // print out some stuff
    //----------------------------------------------------------------
    consoleDemoInit();
    iprintf( "\n    Maxmod Streaming Example   \n");

    //----------------------------------------------------------------
    // initialize maxmod without any soundbank (unusual setup)
    //----------------------------------------------------------------
    mm_ds_system sys;
    sys.mod_count 			= 0;
    sys.samp_count			= 0;
    sys.mem_bank			= 0;
    sys.fifo_channel		= FIFO_MAXMOD;
    mmInit( &sys );

    //----------------------------------------------------------------
    // open stream
    //----------------------------------------------------------------
    mm_stream mystream;
    mystream.sampling_rate	= 25000;					// sampling rate = 25khz
    mystream.buffer_length	= 1200;						// buffer length = 1200 samples
    mystream.callback		= on_stream_request;		// set callback function
    mystream.format			= MM_STREAM_16BIT_STEREO;	// format = stereo 16-bit
    mystream.timer			= MM_TIMER0;				// use hardware timer 0
    mystream.manual			= true;						// use manual filling
    mmStreamOpen( &mystream );

    //----------------------------------------------------------------
    // when using 'automatic' filling, your callback will be triggered
    // every time half of the wave buffer is processed.
    //
    // so:
    // 25000 (rate)
    // ----- = ~21 Hz for a full pass, and ~42hz for half pass
    // 1200  (length)
    //----------------------------------------------------------------
    // with 'manual' filling, you must call mmStreamUpdate
    // periodically (and often enough to avoid buffer underruns)
    //----------------------------------------------------------------

    SetYtrigger( 0 );
    irqEnable( IRQ_VCOUNT );

    while( 1 )
    {
        // wait until line 0
        swiIntrWait( 0, IRQ_VCOUNT);

        // update stream
        mmStreamUpdate();

        // restore backdrop (some lines were drawn with another colour to show cpu usage)
        BG_PALETTE_SUB[0] = bg_colour;

        // wait until next frame
        swiWaitForVBlank();

        // set backdrop to show cpu usage
        BG_PALETTE_SUB[0] = cpu_colour;
    }

    return 0;
}