static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
	display->driverdata = mode->driverdata;

#ifdef USE_HW_RENDERER

	videoSetMode(MODE_5_3D);
	videoSetModeSub(MODE_5_2D);

	/* initialize gl2d */
	glScreen2D();
	
    vramSetBankA(VRAM_A_TEXTURE);
	vramSetBankB(VRAM_B_TEXTURE );
    vramSetBankC(VRAM_C_SUB_BG_0x06200000);
	vramSetBankE(VRAM_E_TEX_PALETTE);

    powerOn(POWER_ALL_2D);

    irqInit();
    irqEnable(IRQ_VBLANK);

    // sub sprites hold the bottom image when 3D directed to top
    initSubSprites();
 
    // sub background holds the top image when 3D directed to bottom
    bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
#else

	/* Select mode 5 for both screens. Can do Extended Rotation
	 * Background on both (BG 2 and 3). */
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_5_2D);

    vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankB(VRAM_B_TEXTURE );
    vramSetBankC(VRAM_C_SUB_BG_0x06200000);
	vramSetBankE(VRAM_E_TEX_PALETTE);

    powerOn(POWER_ALL_2D);

    irqInit();
    irqEnable(IRQ_VBLANK);

#endif

    return 0;
}
Exemple #2
0
/**
 * @brief   Low level HAL driver initialization.
 *
 * @notapi
 */
void hal_lld_init(void) {

  /* Reset of all peripherals.
     Note, GPIOs are not reset because initialized before this point in
     board files.*/
  rccResetAHB(~STM32_GPIO_EN_MASK);
  rccResetAPB1(0xFFFFFFFF);
  rccResetAPB2(0xFFFFFFFF);

  /* PWR clock enabled.*/
  rccEnablePWRInterface(true);

  /* Initializes the backup domain.*/
  hal_lld_backup_domain_init();

  /* DMA subsystems initialization.*/
#if defined(STM32_DMA_REQUIRED)
  dmaInit();
#endif

  /* IRQ subsystem initialization.*/
  irqInit();

  /* Programmable voltage detector enable.*/
#if STM32_PVD_ENABLE
  PWR->CR |= PWR_CR_PVDE | (STM32_PLS & STM32_PLS_MASK);
#endif /* STM32_PVD_ENABLE */

  /* SYSCFG clock enabled here because it is a multi-functional unit shared
     among multiple drivers.*/
  rccEnableAPB2(RCC_APB2ENR_SYSCFGEN, true);
}
//---------------------------------------------------------------------------------
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();
}
//---------------------------------------------------------------------------------
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();
}
Exemple #5
0
/**
 * @brief   Low level HAL driver initialization.
 *
 * @notapi
 */
void hal_lld_init(void) {

  /* Reset of all peripherals except those on IOP.*/
  rccResetAHB(~RCC_AHBRSTR_MIFRST);
  rccResetAPB1(~RCC_APB1RSTR_PWRRST);
  rccResetAPB2(~0);

  /* PWR clock enabled.*/
  rccEnablePWRInterface(true);

  /* Initializes the backup domain.*/
  hal_lld_backup_domain_init();

  /* DMA subsystems initialization.*/
#if defined(STM32_DMA_REQUIRED)
  dmaInit();
#endif

  /* IRQ subsystem initialization.*/
  irqInit();

  /* Programmable voltage detector enable.*/
#if STM32_PVD_ENABLE
  PWR->CR |= PWR_CR_PVDE | (STM32_PLS & STM32_PLS_MASK);
#endif /* STM32_PVD_ENABLE */
}
Exemple #6
0
int main(int argc, char **argv)
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR ;
    
    u32 old_reg = readPowerManagement(PM_CONTROL_REG);
    writePowerManagement(PM_CONTROL_REG, old_reg |PM_LED_ON); // enable fast
    
	// Reset the clock if needed
	rtcReset();

	// Turn on Sound
	powerON(POWER_SOUND);

	// Set up sound defaults.
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	// Set up the interrupt handler
	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	irqEnable(IRQ_VBLANK);

     // Setup FIFO
     
 	irqSet(IRQ_FIFO_NOT_EMPTY,FifoInterruptHandler);
	irqEnable(IRQ_FIFO_NOT_EMPTY);     
    REG_IPC_FIFO_CR =  IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ ;
    
	// Keep the ARM7 out of main RAM
	while (1)
		swiWaitForVBlank();
	
	return 0;
}
Exemple #7
0
void Menu::Init()
{			
    iprintf("Menu.Init\n");
			
	KSIN1 = u8(K1 *(360/57.3f));
	KSIN2 = u8(K2 *(360/57.3f));
	KSIN3 = u8(K3 *(360/57.3f));	
	
	for (int i = 0; i< ((2048) - 1); i++)
	{
        lsin1[i] = sin(i/(float)K1) * 32+32;
        lsin2[i] = sin(i/(float)K2) * 16+16;
        lsin3[i] = sin(i/(float)K3) * 20+20;
    }    
	
	for (int i=0; i<256; i++)
	{
	    u8 r = (u8)(abs(int(16 - 15 * sin(i * M_PI / 16.0f))));
		u8 g = (u8)(abs(int(16 - 15 * sin(i * M_PI / 12.0f))));
		u8 b = (u8)(abs(int(16 - 15 * sin(i * M_PI / 18.0f))));
		pal[i] = RGB15(r,g,b);
	}

	irqInit();
	irqEnable(IRQ_VBLANK);
	
	videoSetMode(MODE_FB0);
	vramSetBankA(VRAM_A_LCD);
}
Exemple #8
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 #9
0
/**
 * @brief   Low level HAL driver initialization.
 *
 * @notapi
 */
void hal_lld_init(void) {

  /* Reset of all peripherals.*/
  rccResetAPB1(0xFFFFFFFF);
  rccResetAPB2(0xFFFFFFFF);

  /* PWR and BD clocks enabled.*/
  rccEnablePWRInterface(true);
  rccEnableBKPInterface(true);

  /* Initializes the backup domain.*/
  hal_lld_backup_domain_init();

  /* DMA subsystems initialization.*/
#if defined(STM32_DMA_REQUIRED)
  dmaInit();
#endif

  /* IRQ subsystem initialization.*/
  irqInit();

  /* Programmable voltage detector enable.*/
#if STM32_PVD_ENABLE
  PWR->CR |= PWR_CR_PVDE | (STM32_PLS & STM32_PLS_MASK);
#endif /* STM32_PVD_ENABLE */
}
Exemple #10
0
void wifi_init()
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

    /*
     * Our half of the ARM7 Wifi handshaking:
     * Send it a pointer to the shared memory area for Wifi.
     */
    REG_IPC_FIFO_TX = IPC_MSG_WIFI_INIT;
    REG_IPC_FIFO_TX = Wifi_Init(WIFIINIT_OPTION_USELED);

    /* Disable TIMER3 before setting up its IRQ handler */
    TIMER3_CR = 0;

    irqInit(); 
    irqSet(IRQ_VBLANK, vblank_irq_handler);
    irqEnable(IRQ_VBLANK);
    irqSet(IRQ_TIMER3, wifi_timer_handler);
    irqEnable(IRQ_TIMER3);
    irqSet(IRQ_FIFO_NOT_EMPTY, fifo_irq_handler);
    irqEnable(IRQ_FIFO_NOT_EMPTY);

    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;
    Wifi_SetSyncHandler(wifi_sync_handler);

    /* Program TIMER3 for 50ms intervals */
    TIMER3_DATA = TIMER_FREQ_256(1000 / WIFI_TIMER_MS);
    TIMER3_CR = TIMER_DIV_256 | TIMER_IRQ_REQ;

    /* Poll for the ARM7 init to finish */
    while (!Wifi_CheckInit()) {
	swiWaitForVBlank();
    }
}
Exemple #11
0
int main()
{
	irqInit();
	irqEnable(IRQ_VBLANK);
	consoleInit(0, 4, 0, NULL, 0, 15);
	BG_COLORS[0]=RGB8(58,110,165);
	BG_COLORS[241]=RGB5(31,31,31);

	SetMode(MODE_0 | BG0_ON);

	/* verify that the overlays are indeed overlapping */
	printf("overlay1_test: %p\noverlay2_test: %p\n", overlay1_test, overlay2_test);
	
	/* set overlay 1 and run code from it */
	memcpy(__iwram_overlay_start, __load_start_iwram1, (int)__load_stop_iwram1 - (int)__load_start_iwram1);
	overlay1_test();
	
	/* set overlay 2 and run code from it */
	memcpy(__iwram_overlay_start, __load_start_iwram2, (int)__load_stop_iwram2 - (int)__load_start_iwram2);
	overlay2_test();
	
	/* back to normal */
	memcpy(__iwram_overlay_start, __load_start_iwram0, (int)__load_stop_iwram0 - (int)__load_start_iwram0);
	while(1);
}
Exemple #12
0
/**
 * @brief   Low level HAL driver initialization.
 *
 * @notapi
 */
void hal_lld_init(void) {

  /* Reset of all peripherals. AHB3 is not reseted because it could have
     been initialized in the board initialization file (board.c).
     Note, GPIOs are not reset because initialized before this point in
     board files.*/
  rccResetAHB1(~STM32_GPIO_EN_MASK);
#if !defined(STM32F410xx)
  rccResetAHB2(~0);
#endif
  rccResetAPB1(~RCC_APB1RSTR_PWRRST);
  rccResetAPB2(~0);

  /* PWR clock enabled.*/
  rccEnablePWRInterface(true);

  /* Initializes the backup domain.*/
  hal_lld_backup_domain_init();

  /* DMA subsystems initialization.*/
#if defined(STM32_DMA_REQUIRED)
  dmaInit();
#endif

  /* IRQ subsystem initialization.*/
  irqInit();

  /* Programmable voltage detector enable.*/
#if STM32_PVD_ENABLE
  PWR->CR |= PWR_CR_PVDE | (STM32_PLS & STM32_PLS_MASK);
#endif /* STM32_PVD_ENABLE */
}
Exemple #13
0
/**
 * @brief   Low level HAL driver initialization.
 *
 * @notapi
 */
void hal_lld_init(void) {

  /* Reset of all peripherals.*/
  rccResetAHB(0xFFFFFFFF);
  rccResetAPB1(0xFFFFFFFF);
  rccResetAPB2(0xFFFFFFFF);

  /* PWR clock enabled.*/
  rccEnablePWRInterface(FALSE);

  /* Initializes the backup domain.*/
  hal_lld_backup_domain_init();

  /* DMA subsystems initialization.*/
#if defined(STM32_DMA_REQUIRED)
  dmaInit();
#endif

  /* IRQ subsystem initialization.*/
  irqInit();

  /* Programmable voltage detector enable.*/
#if STM32_PVD_ENABLE
  PWR->CR |= PWR_CR_PVDE | (STM32_PLS & STM32_PLS_MASK);
#endif /* STM32_PVD_ENABLE */

  /* SYSCFG clock enabled here because it is a multi-functional unit shared
     among multiple drivers.*/
  rccEnableAPB2(RCC_APB2ENR_SYSCFGEN, TRUE);

#if STM32_HAS_USB
  /* USB IRQ relocated to not conflict with CAN.*/
  SYSCFG->CFGR1 |= SYSCFG_CFGR1_USB_IT_RMP;
#endif
}
Exemple #14
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;
}
Exemple #15
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 #16
0
int main()
{
//	REG_WAITCNT = 0x46d6; // lets set some cool waitstates...
	REG_WAITCNT = 0x46da; // lets set some cool waitstates...
	
	irqInit();
	irqEnable(IRQ_VBLANK);
	consoleInit(0, 4, 0, NULL, 0, 15);

	BG_COLORS[0] = RGB5(0, 0, 0);
	BG_COLORS[241] = RGB5(31, 31, 31);
	REG_DISPCNT = MODE_0 | BG0_ON;

	gbfs_init(1);
	
	pimp_sample_bank sb;
	FILE *fp = fopen("dxn-oopk.xm", "rb");
	if (!fp)
	{
		fprintf(stderr, "file not found\n");
		return 1;
	}
	pimp_module *mod = load_module_xm(fp, &sb);
	fclose(fp);
	fp = NULL;
	
	if (NULL == mod)
	{
		fprintf(stderr, "failed to load module\n");
		return 1;
	}

	pimp_gba_init(mod, sb.data);
	pimp_gba_set_callback(callback);

	irqSet(IRQ_TIMER3, timer3);
	irqEnable(IRQ_TIMER3);
	REG_TM3CNT_L = 0;
	REG_TM3CNT_H = TIMER_START | TIMER_IRQ | 2;
	
	irqSet(IRQ_VBLANK, vblank);
	irqEnable(IRQ_VBLANK);
	
	while (1)
	{
		VBlankIntrWait();
		scanKeys();
		int keys = keysDown();
		if (keys & KEY_UP)    pimp_gba_set_pos(0, pimp_gba_get_order() - 1);
		if (keys & KEY_DOWN)  pimp_gba_set_pos(0, pimp_gba_get_order() + 1);
		if (keys & KEY_RIGHT) pimp_gba_set_pos(pimp_gba_get_row() + 8, pimp_gba_get_order());
		if (keys & KEY_LEFT)  pimp_gba_set_pos(pimp_gba_get_row() - 8, pimp_gba_get_order());
		iprintf("%d %d\n", pimp_gba_get_order(), pimp_gba_get_row());
	}
	
	pimp_gba_close();
	return 0;
}
Exemple #17
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 #18
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 #19
0
//-----------------------------------------------------------
// setup interrupt handler with vblank irq enabled
//-----------------------------------------------------------
void setupInterrupts( void )
//-----------------------------------------------------------
{
	// initialize interrupt handler
	irqInit();
	
	// enable vblank interrupt (required for swiWaitForVBlank!)
	irqEnable( IRQ_VBLANK );
}
Exemple #20
0
int main()
{
	int fadeToggle = 1;

	irqInit();
	irqSet( IRQ_TIMER1, kradInterrupt );
	// not really needed, as kragInit also enables IRQ_TIMER1
	irqEnable( IRQ_TIMER1 );
	REG_IME = 1;

	SetMode( MODE_0 | BG0_ON );

	kragInit( KRAG_INIT_STEREO );       // init krawall
	krapCallback( callback );
	krapPlay( &mod_secondpm, 0, 0 );    // play module

	while( 1 ) {
		// wait for line 0
		while( !REG_VCOUNT );
		while( REG_VCOUNT );

		// rasterbar start
		BG_COLORS[0] = rasterbar_color;
		kramWorker();			// do the stuff
		// rasterbar stop
		BG_COLORS[0] = 0;

		scanKeys();
		int keys_pressed = keysDown();

		if( keys_pressed & KEY_A ) {
			if( krapIsPaused() ) {
				// if resuming, force volume to max
				krapSetMusicVol( 128, 0 );
				krapUnpause();
			}
			else
				krapPause( 1 );
		}

		if( keys_pressed & KEY_B ) {
			if( fadeToggle ) {
				// see callback function, when silence is reached
				// the tune is paused
				krapSetMusicVol( 0, 1 );
			}
			else {
				krapSetMusicVol( 128, 1 );
			}
			fadeToggle ^= 1;
		}

	}

	return 0;
}
Exemple #21
0
void
InitDebug(void)
{
#ifdef DEBUG
	irqInit();
	initSpi();
	initDebug();
	BreakPoint();
#endif
}
int main(void)
{
  // irqs are nice
  irqInit();
  irqEnable(IRQ_VBLANK);

  titlescreen();
  gamescreen();
  //doorminigame();

  return 0;
}
Exemple #23
0
/***************************************************
 エントリ
 ***************************************************/
int
main (void)
{
  // ゲームパックウェイト&キャッシュ
  *((vu16 *) 0x04000204) = 0x4317;

  // BG初期化
  init_bg ();
  // スプライト初期化
  init_sprite ();
  // キー初期化
  init_key ();
  // サウンド初期化
  DirectSoundInitialize ();

  // キャラクタ初期化
  init_sprite_chr ();

  // ハイスコア初期化
  init_hiscore ();

  // ゲーム初期化
  init_game ();

  // タイトル
  init_title ();

  // 割り込み初期化
  irqInit ();
  // サウンド用ハンドラ MUSIC / SE
  irqSet (IRQ_TIMER0, IRQ_Music);
  irqSet (IRQ_TIMER1, IRQ_Sound);
  irqEnable (IRQ_VBLANK | IRQ_TIMER0 | IRQ_TIMER1);

  // タイトル
  PlayMusic (MUSIC_TITLE, PLAY_LOOP_ON);

  // メインループ
  while (1)
  {
    // キー入力
    scanKeys ();

    // ゲーム本体
    game ();

    // 割り込み待ち
    VBlankIntrWait ();
  }
}
Exemple #24
0
int main(void)
{
	irqInit();
	irqEnable(IRQ_VBLANK);

	consoleDemoInit();

	iprintf("\x1b[10;10HHello World!\n");

	while (1)
	{
		VBlankIntrWait();
	}
}
Exemple #25
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;
}
Exemple #26
0
int main()
{
    irqInit();
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

    irqSet(IRQ_VBLANK, vblank_irq_handler);
    irqEnable(IRQ_VBLANK);
    irqSet(IRQ_FIFO_NOT_EMPTY, fifo_irq_handler);
    irqEnable(IRQ_FIFO_NOT_EMPTY);

    while (1) {
	swiWaitForVBlank();
    }
}
Exemple #27
0
int main(void) {
	irqInit();
	irqEnable(IRQ_VBLANK);
	code_init();

	AgbMain();

	// SoundDriverInit();
	// SoundDriverMode();

	while (1) {
		VBlankIntrWait();
		// SoundDriverVsync();
	}
}
Exemple #28
0
//---------------------------------------------------------------------------------
// Reset the DS registers to sensible defaults
//---------------------------------------------------------------------------------
void __attribute__((weak)) initSystem(void) {
//---------------------------------------------------------------------------------
	register int i;
	// stop timers and dma
	for (i=0; i<4; i++) 
	{
		DMA_CR(i) = 0;
		DMA_SRC(i) = 0;
		DMA_DEST(i) = 0;
		TIMER_CR(i) = 0;
		TIMER_DATA(i) = 0;
	}


	// clear video display registers
	dmaFillWords(0, (void*)0x04000000, 0x56);
	dmaFillWords(0, (void*)0x04001008, 0x56);

	videoSetModeSub(0);

	vramDefault();

	VRAM_E_CR = 0;
	VRAM_F_CR = 0;
	VRAM_G_CR = 0;
	VRAM_H_CR = 0;
	VRAM_I_CR = 0;

	irqInit();
	fifoInit();

	fifoSetValue32Handler(FIFO_PM, powerValueHandler, 0);
	fifoSetDatamsgHandler(FIFO_SYSTEM, systemMsgHandler, 0);

	if(REG_DSIMODE) {
		fifoSendValue32(FIFO_PM,PM_DSI_HACK);
		__dsimode = true;
	}
	__transferRegion()->buttons = 0xffff;

	punixTime = (time_t*)memUncached((void *)&__transferRegion()->unixTime);

	__syscalls.exit = __libnds_exit;
	extern  char *fake_heap_end;
	__transferRegion()->bootcode = (struct __bootstub *)fake_heap_end;
	irqEnable(IRQ_VBLANK);

}
t_gba		*gba_init(const s32 mode, const u8 repeat)
{
  t_gba		*gba;

  if ((gba = malloc(sizeof(*gba))) == NULL)
    return (NULL);
  irqInit();
  irqEnable(IRQ_VBLANK);
  REG_IME = 1;
  gba->screen = (u16*)0x6000000;
  SetMode(mode);
  gba->key = NULL;
  gba->key_param = NULL;
  gba->key_repeat = repeat;
  return (gba);
}
Exemple #30
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();
}