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;
}
Example #2
0
void glDefaultMemorySetting(void)
{
  videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_2D | DISPLAY_SPR_2D_BMP_256);
  videoSetModeSub(MODE_2_2D | DISPLAY_BG2_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_2D | DISPLAY_SPR_2D_BMP_256);
//  videoSetModeSub(MODE_2_2D | DISPLAY_BG2_ACTIVE | DISPLAY_SPR_2D | DISPLAY_SPR_2D_BMP_256);
  
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_SPRITE_0x06400000, VRAM_C_MAIN_BG_0x06020000,VRAM_D_SUB_SPRITE);
  vramSetBankE(VRAM_E_LCD);
  vramSetBankF(VRAM_F_LCD);
  vramSetBankG(VRAM_G_LCD);
  vramSetBankH(VRAM_H_SUB_BG);
  vramSetBankI(VRAM_I_LCD);
}
Example #3
0
static void NDS_VideoQuit(_THIS)
{
    videoSetMode(DISPLAY_SCREEN_OFF);
    videoSetModeSub(DISPLAY_SCREEN_OFF);
    vramSetBankA(VRAM_A_LCD);
    vramSetBankB(VRAM_B_LCD);
    vramSetBankC(VRAM_C_LCD);
    vramSetBankD(VRAM_D_LCD);
    vramSetBankE(VRAM_E_LCD);
    vramSetBankF(VRAM_F_LCD);
    vramSetBankG(VRAM_G_LCD);
    vramSetBankH(VRAM_H_LCD);
    vramSetBankI(VRAM_I_LCD);
}
Example #4
0
void setupGraphics(void){
	// setup de vram
	vramSetBankE( VRAM_E_MAIN_BG );
	vramSetBankF( VRAM_F_MAIN_SPRITE ); 
	// generate the first blank tile by clearing it to zero
	int n;
	for( n = 0; n < 16; n++ )
		BG_GFX[n] = 0;
	
	//Cargar sprites
	dmaCopyHalfWords( 3, gfx_stage1Tiles, tile2bgram(1), gfx_stage1TilesLen );

	// Copiar paleta a la memoria
	dmaCopyHalfWords( 3, gfx_stage1Pal, pal2bgram(1), gfx_stage1PalLen );

	// set backdrop color
	BG_PALETTE[0] = backdrop_colour;

	// libnds prefixes the register names with REG_
	REG_BG0CNT = BG_MAP_BASE(1);

    for( n = 0; n < 1024; n++ )
        bg0map[n] = 0;
	
	int i, j;
	// cargamos desde j=4 ya que los tiles de antes contienen basura
	// por razones desconocidas
	for ( i = 0; i < 32; i++)
		for (j=4; j<29; j++)
			bg0map[ i + j*32 ] = (i+j*32+1) | 1 << 12;


	// Si reducimos este valor la imagen baja y aparecen pixeles de basura
	// que no deberían estar. Si se hace algún tipo de elevación vertical
	// habra que tener cuidado.
	REG_BG0VOFS = 40;
	
	//Cargar sprites
	dmaCopyHalfWords( 3, gfx_ballTiles, tile2objram(tiles_ball), gfx_ballTilesLen );

	// Copiar paleta a la memoria
	dmaCopyHalfWords( 3, gfx_ballPal, pal2objram(pal_ball), gfx_ballPalLen );

	// deshabilitar sprites
	for( n = 0; n < 128; n++ )
			sprites[n].attr0 = ATTR0_DISABLED;

	videoSetMode( MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT );

}
Example #5
0
void initVideo() {
	// initialize VRAM banks
	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
	vramSetBankC(VRAM_C_SUB_BG_0x06200000);
	vramSetBankD(VRAM_D_SUB_SPRITE);
	vramSetBankE(VRAM_E_LCD);
	vramSetBankF(VRAM_F_LCD);
	vramSetBankG(VRAM_G_LCD);
	vramSetBankH(VRAM_H_LCD);
	vramSetBankI(VRAM_I_LCD);
	
	// set video modes
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_5_2D);
}
Example #6
0
/* Definir el sistema de vídeo */
void initVideo() {
	/*  Poner en marcha el motor gráfico 2D. */
    powerOn(POWER_ALL_2D);

    /*  Mapear la memoria VRAM para mostrar gráficos en las dos pantallas. */
    vramSetPrimaryBanks(VRAM_A_MAIN_BG_0x06000000,
    			VRAM_B_MAIN_BG_0x06020000,
                VRAM_C_SUB_BG,
                VRAM_D_SUB_SPRITE);
    vramSetBankE(VRAM_E_MAIN_SPRITE);

    /* Reserva el banco F para poder escribir en él la paleta de colores extendida */
    vramSetBankF(VRAM_F_LCD);

    /*  Establecer el modo de vídeo de las pantallas principal y secundaria. */
    videoSetMode(MODE_5_2D);
    videoSetModeSub(MODE_5_2D);
}
Example #7
0
void gamestate::videoInit() {
    powerOn(POWER_ALL_2D); //Turn on the 2D graphics core.

    lcdMainOnBottom(); // Place the main screen on the bottom physical screen

    /* Configure the VRAM and background control registers. */
    // This stuff is copied from pataters tutorial (because it works... 0o)
    /*
     * Map VRAM to display a background on the main and sub screens.
     *
     * The vramSetMainBanks function takes four arguments, one for each of the
     * major VRAM banks. We can use it as shorthand for assigning values to
     * each of the VRAM bank's control registers.
     *
     * We map  banks A and B to main screen background memory. This gives us
     * 256KB, which is a healty amount for 16-bit graphics.
     *
     * We map bank C to sub screen background memory.
     *
     * We map bank D to LCD. This setting is generally used for when we aren't
     * using a particular bank.
     *
     * We map bank E to main screen sprite memory (aka object memory).
     */
    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_LCD);

    vramSetBankE(VRAM_E_MAIN_SPRITE);

    /* Set the video mode on the main screen. */
    videoSetMode(MODE_5_2D | // Set the graphics mode to Mode 5
                 DISPLAY_BG2_ACTIVE |
                 DISPLAY_BG3_ACTIVE | // Enable BG3 for display
                 DISPLAY_SPR_ACTIVE | // Enable sprites for display
                 DISPLAY_SPR_1D );    // Enable 1D tiled sprites

    /* Set the video mode on the sub screen. */
    videoSetModeSub(MODE_5_2D | // Set the graphics mode to Mode 5
                    DISPLAY_BG3_ACTIVE); // Enable BG3 for display
    // Sets background registers
    consoleDemoInit(); // Need this for debug-output (iprintf)
}
Example #8
0
void Render::InitVideo()
{
    /*
     *  Map VRAM to display a background on the main and sub screens.
     * 
     *  The vramSetMainBanks function takes four arguments, one for each of the
     *  major VRAM banks. We can use it as shorthand for assigning values to
     *  each of the VRAM bank's control registers.
     *
     *  We map banks A and B to main screen  background memory. This gives us
     *  256KB, which is a healthy amount for 16-bit graphics.
     *
     *  We map bank C to sub screen background memory.
     *
     *  We map bank D to LCD. This setting is generally used for when we aren't
     *  using a particular bank.
     *
     *  We map bank E to main screen sprite memory (aka object memory).
     */
	 
	 vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_SUB_SPRITE);

    vramSetBankE(VRAM_E_MAIN_SPRITE);
	vramSetBankF(VRAM_F_MAIN_SPRITE);
	vramSetBankI(VRAM_I_SUB_SPRITE);
	
	/*  Set the video mode on the main screen. */
    videoSetMode(MODE_5_2D | // Set the graphics mode to Mode 5
                 DISPLAY_BG2_ACTIVE | // Enable BG2 for display
                 DISPLAY_BG3_ACTIVE | // Enable BG3 for display
                 DISPLAY_SPR_ACTIVE | // Enable sprites for display
                 DISPLAY_SPR_1D       // Enable 1D tiled sprites
                 );

	//Set the video mode on the sub screen. 
	videoSetModeSub(MODE_5_2D | // Set the graphics mode to Mode 5
                    DISPLAY_BG3_ACTIVE |  // Enable BG3 for display
					DISPLAY_SPR_ACTIVE |  // Enable sprites for display
					DISPLAY_SPR_1D);

}
Example #9
0
void hasieratuBideoa() {
    /*  Bi pantailatan irudiak erakutsi ahal izateko memoria mapeatu. */

    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_E_LCD);

    vramSetBankE(VRAM_E_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    /*  Pantaila nagusirako bideo modua ezarri */
    videoSetMode(MODE_5_2D | // 5. bideo modua ezarri
                 DISPLAY_BG2_ACTIVE | // 2. fondoa aktibatu
                 DISPLAY_BG3_ACTIVE); // 3. fondoa aktibatu

    /*  2. mailako pantaila bideo modua ezarri */
    videoSetModeSub(MODE_5_2D | // 5. bideo modua ezarri
                    DISPLAY_BG3_ACTIVE); // 3. fondoa aktibatu
}
Example #10
0
void initGl2D(void) {

	videoSetMode(MODE_0_3D);
	vramSetBankA(VRAM_A_TEXTURE);
	vramSetBankE(VRAM_E_TEX_PALETTE);

	glInit();
	glEnable( GL_TEXTURE_2D );
	glClearColor( 0, 0, 0, 31 ); 	// BG must be opaque for AA to work
	glClearPolyID( 63 ); 			// BG must have a unique polygon ID for AA to work
	glClearDepth( GL_MAX_DEPTH );
	glViewport(0,0,255,191);		// set the viewport to screensize
	glColor( 0x7FFF ); 				// max color
	glPolyFmt( POLY_ALPHA(31) | POLY_CULL_NONE );  // geen dingen laten verdwijnen
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();				// reset view
	glOrthof32( 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1 << 12, 1 << 12 );
	gluLookAt(	0.0, 0.0, 1.0,		//camera possition
	            0.0, 0.0, 0.0,		//look at
	            0.0, 1.0, 0.0);		//up
}
Example #11
0
Display::Display(){

// INIT
//-------------------------------------------------------------------------
	frame = 0;
	srand((int)NULL);

	// Main Init
	videoSetMode(MODE_5_2D | DISPLAY_BG_EXT_PALETTE);
	oamInit(&oamMain, SpriteMapping_1D_128, true);

	// Sub Init
	videoSetModeSub(MODE_5_2D | DISPLAY_BG_EXT_PALETTE);
	oamInit(&oamSub, SpriteMapping_1D_128, true);
//-------------------------------------------------------------------------
	

// FONT LOADING
//-------------------------------------------------------------------------
	ConsoleFont font;
	font.gfx				= (u16*)fontTiles;
	font.pal				= (u16*)fontPal;
	font.numChars			= 95;
	font.numColors			=  16;
	font.bpp				= 4;
	font.asciiOffset		= 32;
	font.convertSingleColor = true;
//-------------------------------------------------------------------------


// MAIN BACKGROUNDS
//-------------------------------------------------------------------------
	//BG Palettes
	vramSetBankE(VRAM_E_LCD);
	dmaCopy(fontPal,	VRAM_E_EXT_PALETTE[0], 512);
	dmaCopy(bgMainPal,	VRAM_E_EXT_PALETTE[2], 512);
	dmaCopy(padsBgMainPal,	VRAM_E_EXT_PALETTE[3], 512);
	vramSetBankE(VRAM_E_BG_EXT_PALETTE);

	//BG0 : Text
	mainbg0 = bgInit(0, BgType_Text4bpp, BgSize_T_256x256, 1, 0);
	consoleInit(&this->mainConsole, 0, BgType_Text4bpp, BgSize_T_256x256, 1, 0, true, false);
	consoleSetFont(&this->mainConsole, &font);
	bgSetPriority(this->mainbg0, 0);

	//BG2
	mainbg2 = bgInit(2, BgType_Rotation, BgSize_R_256x256, 7,	1);
	dmaCopy(bgMainTiles,	bgGetGfxPtr(mainbg2), bgMainTilesLen);
	dmaCopy(bgMainMap,		bgGetMapPtr(mainbg2), bgMainMapLen);
	bgSetPriority(this->mainbg2, 3);
	bgHide(mainbg2);

	//BG3
	mainbg3 = bgInit(3, BgType_Rotation, BgSize_R_256x256, 12,	2);
	dmaCopy(padsBgMainTiles,	bgGetGfxPtr(mainbg3), padsBgMainTilesLen);
	dmaCopy(padsBgMainMap,		bgGetMapPtr(mainbg3), padsBgMainMapLen);
	bgSetPriority(this->mainbg3, 2);
	bgHide(mainbg3);
//-------------------------------------------------------------------------
	

// MAIN SPRITES
//-------------------------------------------------------------------------
	//Palettes
	vramSetBankF(VRAM_F_LCD);
	dmaCopy(dotSpritePal,			VRAM_F_EXT_SPR_PALETTE[0], 512);
	dmaCopy(ledSpritePal,			VRAM_F_EXT_SPR_PALETTE[1], 512);
	dmaCopy(banksSpritePal,			VRAM_F_EXT_SPR_PALETTE[2], 512);
	dmaCopy(octaveSelectSpritePal,	VRAM_F_EXT_SPR_PALETTE[3], 512);
	vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
	
	//Sprites loading
	dotSprite			= new Sprite(1, dotSpriteTiles,				0, SpriteSize_64x32, 3);
	ledSprite			= new Sprite(1, ledSpriteTiles,				1, SpriteSize_16x16, 4);
	banksSprite			= new Sprite(1, banksSpriteTiles,			2, SpriteSize_16x16, 8);
	octaveSelectSprite	= new Sprite(1, octaveSelectSpriteTiles,	3, SpriteSize_32x16, 1);
//-------------------------------------------------------------------------


// SUB BACKGROUNDS
//-------------------------------------------------------------------------
	//BG Palettes
	vramSetBankH(VRAM_H_LCD);
	dmaCopy(fontPal, VRAM_H_EXT_PALETTE[0], 512);
	dmaCopy(slidersBg2SubPal, VRAM_H_EXT_PALETTE[2], 512);
	dmaCopy(slidersBg3SubPal, VRAM_H_EXT_PALETTE[3], 512);
	vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);

	//BG0 : Text
	subbg0 = bgInitSub(0, BgType_Text4bpp, BgSize_T_256x256, 4, 0);
	consoleInit(&subConsole, 0, BgType_Text4bpp, BgSize_T_256x256, 2, 0, false, true);
	consoleSetFont(&subConsole, &font);
	bgSetPriority(subbg0, 1);

	//BG2
	subbg2 = bgInitSub(2, BgType_Rotation, BgSize_R_256x256, 5,1);
	bgSetPriority(subbg2, 3);

	//BG3
	subbg3 = bgInitSub(3, BgType_Rotation, BgSize_R_256x256, 6,2);
	bgSetPriority(subbg3, 2);
	bgHide(subbg3);
//-------------------------------------------------------------------------
	

// SUB SPRITES
//-------------------------------------------------------------------------
	//Palettes
	vramSetBankI(VRAM_I_LCD);
	dmaCopy(kaossBrickSpritePal,	VRAM_I_EXT_SPR_PALETTE[0], 512);
	dmaCopy(padSpritePal,			VRAM_I_EXT_SPR_PALETTE[1], 512);
	dmaCopy(modeSpritePal,			VRAM_I_EXT_SPR_PALETTE[2], 512);
	dmaCopy(sliderCursorSpritePal,	VRAM_I_EXT_SPR_PALETTE[3], 512);
	dmaCopy(muteSpritePal,			VRAM_I_EXT_SPR_PALETTE[4], 512);
	dmaCopy(editParamsSpritePal,	VRAM_I_EXT_SPR_PALETTE[5], 512);
	vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);

	//Sprites loading	
	kaossBrickSprite	= new Sprite(0, kaossBrickSpriteTiles,		0, SpriteSize_32x32, 16);
	padSprite			= new Sprite(0, padSpriteTiles,				1, SpriteSize_64x64, 2);
	modesSprite			= new Sprite(0, modeSpriteTiles,			2, SpriteSize_64x64, 4);
	sliderCursorSprite	= new Sprite(0, sliderCursorSpriteTiles,	3, SpriteSize_32x16, 6);
	muteSprite			= new Sprite(0, muteSpriteTiles,			4, SpriteSize_32x32, 2);
	paramsEditSprite	= new Sprite(0, editParamsSpriteTiles,		5, SpriteSize_16x16, 8);
//-------------------------------------------------------------------------


// STRUCTURES INITIALISATION
//-------------------------------------------------------------------------
	kaossBricksState = new u8**[4];
	for (u8 b = 0; b < 4; ++b){
		kaossBricksState[b] = new u8*[8];
		for (u8 i = 0; i < 8; ++i){
			kaossBricksState[b][i] = new u8[8];
			for (u8 j = 0; j < 8; ++j)
				kaossBricksState[b][i][j] = 0;
		}
	}
	slidersBg2Map	= new unsigned short[768];
	slidersBg3Map	= new unsigned short[768];
//-------------------------------------------------------------------------
	consoleSelect(&mainConsole);
	consoleClear();

	dmaCopy(bgSplashTiles,	bgGetGfxPtr(subbg2), bgSplashTilesLen);
	dmaCopy(bgSplashMap,	bgGetMapPtr(subbg2), bgSplashMapLen);

	echo(0, GREY, 12, 10, "Connecting...");
	echo(0, WHITE, 23, 6, "midicontrolds.blogspot.com");
}
Example #12
0
void setupGraphics(void){
	// setup de vram
	vramSetBankE( VRAM_E_MAIN_BG );
	vramSetBankF( VRAM_F_MAIN_SPRITE ); 
	// generate the first blank tile by clearing it to zero
	int n;

	for( n=0; n<16; n++)
		BG_GFX[n] = 0;

	consoleDemoInit();
	
	//Cargar sprites
	dmaCopyHalfWords( 3, gfx_tilesetTiles, tile2bgram(bg0), gfx_tilesetTilesLen );

	// Copiar paleta a la memoria
	dmaCopyHalfWords( 3, gfx_tilesetPal, pal2bgram(pal_bg0), gfx_tilesetPalLen );

	// set backdrop color
	BG_PALETTE[0] = backdrop_colour;

	// libnds prefixes the register names with REG_
	REG_BG0CNT = 1 << 14 | 1 << 8; /** IMPORTANTE */

    	for( n = 0; n < 2048; n++ )
        	bg0map[n] = 0; /** IMPORTANTE */
	
	int i, j;
	// Suelo
	// Bloque 1: 	8  9
	//		10 11
	// Bloque 2:	12 13
	//		14 15
	for ( i = 0; i < 32; i++){
		for (j=25; j<29; j+=2)
			if ( (i+j-1)%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+8+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+12+i%2) | pal_bg0 << 12;
		for (j=26; j<29; j+=2)
			if ( (i+j-1)%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+10+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+14+i%2) | pal_bg0 << 12;

	}

	// Plataforma
	// 4 5
	// 6 7
	for ( i = 0; i < 32; i++){
		bg0map[ i + 23*32 ] = (bg0+4+i%2) | pal_bg0 << 12;
		bg0map[ i + 24*32 ] = (bg0+6+i%2) | pal_bg0 << 12;
	}

	// Rocas
	// Roca 1:	16 17
	// 		18 19
	// Roca 2:	20 21
	// 		22 23
	for ( i = 0; i < 8; i++){
		for (j=19; j<23; j+=2)
			if ( i%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+16+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+20+i%2) | pal_bg0 << 12;
		for (j=20; j<23; j+=2)
			if ( i%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+18+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+22+i%2) | pal_bg0 << 12;

	}

	for ( i = 0; i < 4; i++){
		for (j=15; j<19; j+=2)
			if ( i%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+16+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+20+i%2) | pal_bg0 << 12;
		for (j=16; j<19; j+=2)
			if ( i%4 < 2 )
				bg0map[ i + j*32 ] = (bg0+18+i%2) | pal_bg0 << 12;
			else
				bg0map[ i + j*32 ] = (bg0+22+i%2) | pal_bg0 << 12;

	}

	// Escaleras
	// 24 25
	for ( i = 0; i < 2; i++){
		for (j=0; j<15; j++)
			bg0map[ i + j*32 ] = (bg0+24+i%2) | pal_bg0 << 12;
	}

	for( n = 1024; n < 2048; n++ )
        	bg0map[n] = (bg0+24) | pal_bg0 << 12;	

	REG_BG0VOFS = 40;
	
	//Cargar sprites
	dmaCopyHalfWords( 3, gfx_ballTiles, tile2objram(tiles_ball), gfx_ballTilesLen );

	// Copiar paleta a la memoria
	dmaCopyHalfWords( 3, gfx_ballPal, pal2objram(pal_ball), gfx_ballPalLen );

	// deshabilitar sprites
	for( n = 0; n < 128; n++ )
			sprites[n].attr0 = ATTR0_DISABLED;

	videoSetMode( MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT );

}
Example #13
0
void initProgram()
{
	//------------------------
	// start initializing crap
	//------------------------
	defaultExceptionHandler(); // set up the exception handler

    powerON(POWER_ALL_2D); // turn on everything

	#ifndef DEBUG_MODE
	fb_init(); // initialize top screen video
	#else
	debugInit();
	#endif
	bg_init(); // initialize bottom screen video

	setNewOrientation(ORIENTATION_0);

	// set up extra vram banks to be scratch memory
	vramSetBankE(VRAM_E_LCD);
	vramSetBankF(VRAM_F_LCD);
	vramSetBankG(VRAM_G_LCD);
	vramSetBankH(VRAM_H_LCD);
	vramSetBankI(VRAM_I_LCD);

	fb_setBGColor(30653);
	bg_setBGColor(0);
	drawStartSplash();

	lcdMainOnTop(); // set fb to top screen
	fb_swapBuffers();
	bg_swapBuffers();

	// out of order for competition
	irqInit(); // initialize irqs

    irqSet(IRQ_VBLANK, startvBlank);
	irqEnable(IRQ_VBLANK);

	setMode(INITFAT);
	setSoundInterrupt(); // initialize fifo irq

	setGenericSound(11025, 127, 64, 1);
	waitForInit(); // wait until arm7 has loaded and gone to sleep
	initComplexSound(); // initialize sound variables
	initWifi();
	fixGautami();

	setCursorProperties(0, 2, 0, 0);
	initCapture();
	initClipboard();

	// set defaults to english in case we can't load the langauge file for
	// some reason also takes care of partial translations.
	initLanguage();
	initRandomList();
	fixAndTags();

	resetKeyboard();
	setDate();

	if(!DRAGON_InitFiles())
	{
		// oops, no cf card!
		setMode(DISPLAYCOW);

		setFont(font_arial_11);
		setColor(0xFFFF);

		bg_dispSprite(96, 5, errmsg, 0);
		bg_setClipping(5,25,250,181);
		bg_dispString(0,0,l_nofat);
		bg_swapBuffers();

		while(1)
		{
			// wee, la la la!
		  // More or less, we aren't going to do nothing here
		}
	}

	//--------------------------------------------------------------------
	//finished init, now check to make sure the DSOrganize dir is there...
	//--------------------------------------------------------------------

	findDataDirectory();
	makeDirectories();

	if(DRAGON_FileExists("DSOrganize") != FE_DIR)
	{
		setMode(DISPLAYCOW);

		// oops, not there, we must create!
		DRAGON_mkdir("DSOrganize");
		DRAGON_chdir("DSOrganize");
		DRAGON_mkdir("DAY");
		DRAGON_mkdir("HELP");
		DRAGON_mkdir("LANG");
		DRAGON_mkdir("RESOURCES");
		DRAGON_mkdir("REMINDER");
		DRAGON_mkdir("SCRIBBLE");
		DRAGON_mkdir("TODO");
		DRAGON_mkdir("VCARD");
		DRAGON_mkdir("ICONS");
		DRAGON_mkdir("CACHE");
		DRAGON_mkdir("COOKIES");
		DRAGON_mkdir("HOME");
		DRAGON_chdir("/");

		makeDefaultSettings();

		setFont(font_arial_11);
		setColor(0xFFFF);

		bg_dispSprite(96, 5, errmsg, 0);
		bg_setClipping(5,25,250,181);
		bg_dispString(0,0, l_createdir);
		bg_swapBuffers();

		while(!keysDown())
		{
			scanKeys();
		}
	}

	setMode(INITPLUGIN);

	//-------------------------------------------------------------------
	//finished creating dirs, now check to make sure if they extracted it
	//did their extracting program actually get all the dirs?
	//-------------------------------------------------------------------

	DRAGON_chdir(d_base);

	if(DRAGON_FileExists("Day") != FE_DIR)
	{
		DRAGON_mkdir("DAY");
	}
	if(DRAGON_FileExists("Help") != FE_DIR)
	{
		DRAGON_mkdir("HELP");
	}
	if(DRAGON_FileExists("Lang") != FE_DIR)
	{
		DRAGON_mkdir("LANG");
	}
	if(DRAGON_FileExists("Reminder") != FE_DIR)
	{
		DRAGON_mkdir("REMINDER");
	}
	if(DRAGON_FileExists("Scribble") != FE_DIR)
	{
		DRAGON_mkdir("SCRIBBLE");
	}
	if(DRAGON_FileExists("Todo") != FE_DIR)
	{
		DRAGON_mkdir("TODO");
	}
	if(DRAGON_FileExists("VCard") != FE_DIR)
	{
		DRAGON_mkdir("VCARD");
	}
	if(DRAGON_FileExists("Icons") != FE_DIR)
	{
		DRAGON_mkdir("ICONS");
	}
	if(DRAGON_FileExists("Cache") != FE_DIR)
	{
		DRAGON_mkdir("CACHE");
	}
	if(DRAGON_FileExists("Cookies") != FE_DIR)
	{
		DRAGON_mkdir("COOKIES");
	}
	if(DRAGON_FileExists("Home") != FE_DIR)
	{
		DRAGON_mkdir("HOME");
	}

	DRAGON_chdir("/");

	//-------------------------------------------
	//how about we load the settings for them eh?
	//-------------------------------------------
	loadSettings();

	DRAGON_chdir(d_base);

	if(DRAGON_FileExists("startup.wav") == FE_FILE)
	{
		char tStr[256];

		sprintf(tStr, "%sstartup.wav", d_base);
		loadWavToMemory();
		loadSound(tStr);
	}

	DRAGON_chdir("/");
	initStartScreen();

    irqSet(IRQ_VBLANK, vBlank);
	fb_setBGColor(genericFillColor);
	bg_setBGColor(genericFillColor);
}
Example #14
0
int main(void) 
{
	mmInitDefaultMem((mm_addr)soundbank_bin);

	//set video mode and map vram to the background
	videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE | 
                 DISPLAY_SPR_1D_LAYOUT | 
                 DISPLAY_SPR_ACTIVE);
    
	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
    vramSetBankB(VRAM_B_MAIN_SPRITE);

	//set video mode and map vram to the background
	videoSetModeSub(MODE_1_2D | DISPLAY_BG1_ACTIVE | 
                 DISPLAY_SPR_1D_LAYOUT | 
                 DISPLAY_SPR_ACTIVE);

	vramSetBankD(VRAM_D_MAIN_BG_0x06000000);
    vramSetBankE(VRAM_E_MAIN_SPRITE);

    lcdMainOnBottom();

#ifdef BBDEBUG
    consoleDemoInit();
#endif

    sound s;
    s.load_bank(0);

    sprites spr;
	machine m(&s);
    machine_view mv(&spr);
#ifndef BBDEBUG
    thread_view tv;
#endif
    cursor c(&m,&spr);
    pointer p(&spr);
    iprintf("%d\n",list::unit_test());

    int frame=0;
    int x=0;
    int y=0;
    int tx=0;
    int ty=0;
    int dx=0;
    int dy=0;
    int touchedlast=0;

    int tempo=2;
    int bank=0;
    u8 flip=0;
    u8 flip_count=1;
	irqEnable( IRQ_VCOUNT );

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

        u32 t=tempo;
        //t=t/(flip+1);
        //iprintf("%d\n",t);
        
        if (tempo==0 || frame%t==0) 
        {
            m.run();
            /*    flip_count--;
            if (flip_count==0)
            {
                flip_count=4;
                if (flip) flip=0;
                else flip=1;
                }*/
        }
		scanKeys();
        frame++;
        touchPosition touch;
        touchRead(&touch);

        if (keysDown() & KEY_UP) m.slow_down_closest(c.get_cursor_addr());
        if (keysDown() & KEY_DOWN) m.speed_up_closest(c.get_cursor_addr());
        if (tempo<0) tempo=0;

        if (keysDown() & KEY_L) sound_check(m);

        if (keysDown() & KEY_LEFT) { bank--; s.load_bank(bank); }
        if (keysDown() & KEY_RIGHT) { bank++; s.load_bank(bank); }
 
        if(keysDown() & KEY_TOUCH)
        {
            tx=touch.px;
            ty=touch.py;
            if (!c.touch(tx,ty,&p))
            {
                touchedlast=1;
            }
        }
        else if(keysHeld() & KEY_TOUCH)
		{				
            if (!c.menu_shown() &&
                !c.drag(touch.px+x,touch.py+y,(touch.px+x)/16,(touch.py+y)/16))
            {
                if (touchedlast>0) touchedlast++;
                x+=tx-touch.px;
                y+=ty-touch.py;
                tx=touch.px;
                ty=touch.py;
            }
        }

        if (keysUp() & KEY_TOUCH)
        {
            if (touchedlast>0 && touchedlast<5)
            {
                int lx=(tx+x)/16;
                int ly=(ty+y)/16;
                c.set_pos(lx,ly,lx*16,ly*16);
            }
            touchedlast=0;
        }       

        if (keysUp() & KEY_A)
        {
            for (u32 i=0; i<HEAP_SIZE; i++)
            {
                m.poke(i,rand());
            }
        }
        
        c.update(x,y);
        if (c.menu_shown()) 
        {
            dx=c.get_x()-128;
            dy=c.get_y()-82;
            if (dx!=x) x+=(dx-x)*0.1;
            if (dy!=y) y+=(dy-y)*0.1; 
        }

        p.update(x,y,&m);
        REG_BG0HOFS = x;
        REG_BG0VOFS = y;
        spr.update();
        mv.update(x,y,&m);
        s.update();
#ifndef BBDEBUG
        tv.update(&m);
#endif
        BG_PALETTE_SUB[0]=13<<10;
		swiWaitForVBlank();
        BG_PALETTE_SUB[0]=31;

	}
		
	return 0;
}