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
void __attribute__((noreturn)) __sassert(const char* file, int line, const char* cond, const char* msg)
{
	if (isUserMode()) FeOS_swi_assertfail(file, line, cond, msg);

	videoReset();
	videoSetMode(MODE_0_2D);
	videoSetModeSub(MODE_0_2D);
	PrintConsole* conmain = consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 0, 1, true, true);
	memcpy(&oConSub, consoleGetDefault(), sizeof(PrintConsole));
	PrintConsole* consub = consoleInit(&oConSub, 0, BgType_Text4bpp, BgSize_T_256x256, 0, 1, false, true);
	InstallConThunks();

	consoleSelect(conmain);

	BG_PALETTE[0] = RGB15(31,0,31);
	BG_PALETTE[255] = RGB15(31,31,31);
	BG_PALETTE_SUB[0] = RGB15(31,0,31);
	BG_PALETTE_SUB[255] = RGB15(31,31,31);

	iprintf("\x1b[5CKernel assertion failure!\n\nCondition: %s\n\n%s:%d\n\nMessage: %s\n", cond, file, line, msg);

	consoleSelect(consub);

	iprintf("\x1b[5CStacktrace coming soon\n\nInstead, here's a kitten:\n\n");

	const char** i;
	for (i = meow; *i; i ++)
		iprintf("%s\n", *i);

	for (;;)
		swiWaitForVBlank();
}
Graphics::Graphics(void) {
	//irqInit(); 
	//irqSet(IRQ_VBLANK, 0); 
	setColor(RGB15(20,31,10) | (1<<15));
			 
	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	//videoSetModeSub(MODE_2_2D | DISPLAY_BG3_ACTIVE);
			
	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankB(VRAM_B_MAIN_BG);
	//vramSetBankC(VRAM_C_SUB_BG);
			
			
	REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0);
	REG_BG3PA  = 1 << 8;
	REG_BG3PB  = 0;
	REG_BG3PC  = 0;
	REG_BG3PD  = 1 << 8;
	videoRam   = BG_BMP_RAM(0);
			
			
	//REG_BG3CNT_SUB = BG_BMP16_256x256 | BG_BMP_BASE(0);
	//REG_BG3PA_SUB = 1<< 8;
	//REG_BG3PB_SUB = 0;
	//REG_BG3PC_SUB = 0;
	//REG_BG3PD_SUB = 1 << 8;
	//memClone   = BG_BMP_RAM_SUB(2);
}
Exemple #4
0
int
main(void)
{
					// Initialize Bottom Screen for printf()
	PrintConsole topScreen;
        videoSetMode(MODE_0_2D);
        vramSetBankA(VRAM_A_MAIN_BG);
        consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
        consoleSelect(&topScreen);

        videoSetModeSub(MODE_5_2D);
    	vramSetBankC(VRAM_C_SUB_BG);
        bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
    decompress(drunkenlogoBitmap, BG_GFX_SUB,  LZ77Vram);
	
	
	xTaskCreate(Key_Press,
					     (const signed char * const)"Key_Press",
					     2048,
					     (void *)NULL,
					     tskIDLE_PRIORITY + 2,
					     NULL);
	
	xTaskCreate(Touch_Press,
					     (const signed char * const)"Touch_Press",
					     2048,
					     (void *)NULL,
					     tskIDLE_PRIORITY + 1,
					     NULL);
	vTaskStartScheduler();		// Never returns
	while(1)
		;
	return 0;
}
int main(void) {

    // set the mode for 2 text layers and two extended background layers
	videoSetMode(MODE_5_2D);

	// set the sub background up for text display (we could just print to one
	// of the main display text backgrounds just as easily
	videoSetModeSub(MODE_0_2D); //sub bg 0 will be used to print text

	vramSetBankA(VRAM_A_MAIN_BG);

	consoleDemoInit();

	iprintf("\n\n\tHello DS devers\n");
	iprintf("\twww.drunkencoders.com\n");
	iprintf("\t16 bit bitmap demo");

	// set up our bitmap background
	bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
	
	decompress(drunkenlogoBitmap, BG_GFX,  LZ77Vram);
	
	while(1) {
		swiWaitForVBlank();
	}
	return 0;
}
Exemple #6
0
void init_consoles(void)
{
	/* debug console on top */
	mainConsole = consoleDemoInit();
	debugConsole = (PrintConsole *) malloc(sizeof(PrintConsole));

	if (!debugConsole)
		exit(1);

	memcpy(debugConsole, consoleGetDefault(), sizeof(PrintConsole));
	videoSetMode(MODE_0_2D);
	vramSetBankA(VRAM_A_MAIN_BG);

	consoleInit(debugConsole, debugConsole->bgLayer, BgType_Text4bpp,
		    BgSize_T_256x256, debugConsole->mapBase,
		    debugConsole->gfxBase, true, true);
#ifdef DEBUG
	printf("Test debug console\n");
#endif
	consoleSelect(mainConsole);
#ifdef DEBUG
	printf("Test main console\n");
#endif
	return;
}
Exemple #7
0
void initEditor(void)
{
	lcdMainOnBottom();
	videoSetMode(MODE_5_3D);
	videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	
	vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_SUB_BG,VRAM_D_TEXTURE);	
	
	glInit();
	
	glEnable(GL_TEXTURE_2D);
	// glEnable(GL_ANTIALIAS);
	glEnable(GL_BLEND);
	glEnable(GL_OUTLINE);
	
	glClearPolyID(63);
	glClearDepth(0x7FFF);
	glViewport(0,0,255,191);
	
	initVramBanks(1);
	initTextures();
	
	initRoomEdition();
	NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree());

	fadeIn();
}
Exemple #8
0
void Outro_ConfigureHardware()
{
	/* Configure video hardware */
	videoSetMode(MODE_3_2D);

	vramSetBankF(VRAM_F_MAIN_BG_0x06000000);
}
Exemple #9
0
int main(void)
{
	videoSetMode(MODE_5_2D);	
	consoleDemoInit();
	scanKeys();
	int c = keysHeld();
	Sfondo();
	CreaPG();
	while(true) 
	{
		swiWaitForVBlank();			
		if(c!=0)
		{
			KeysPress(c);
			//iprintf("-key:%i\n",c);
			c = 0;
		}
		else 
		{//Nessun tasto premuto
			scanKeys();
			c = keysHeld();
		}
	}
	return 0;	
}
//This function initializes the device to a "default" setting. 
//You may begin sending GL commands to the DS after this function executes
void blu_impl::GFX_Init3DDevice(){
videoSetMode(MODE_0_3D);

// initialize the geometry engine
glInit();

// enable antialiasing
glEnable(GL_ANTIALIAS);

// setup the rear plane
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(0x7FFF);

// Set our viewport to be the same size as the screen
glViewport(0,0,255,191);

// this controls your camera 
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, 256.0 / 192.0, 0.1, 100);

//ds specific, several attributes can be set here       
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
// Set the current matrix to be the model matrix
glMatrixMode(GL_MODELVIEW);
}
Exemple #11
0
void bsp_start (void)
{
  /* initialize irq management */
  BSP_rtems_irq_mngt_init ();

  /* setup console mode for lower screen */
  irqEnable (IRQ_VBLANK);
  videoSetMode (0);
  videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE);
  vramSetBankC (VRAM_C_SUB_BG);

  SUB_BG0_CR = BG_MAP_BASE (31);
  BG_PALETTE_SUB[255] = RGB15 (31, 31, 31);
  consoleInitDefault ((u16 *) SCREEN_BASE_BLOCK_SUB (31),
                      (u16 *) CHAR_BASE_BLOCK_SUB (0), 16);

  /* print status message */
  printk ("[+] kernel console started\n");

  /* set the cpu mode to system user */
  arm_cpu_mode = 0x1f;

  /* configure clock period */
  Configuration.microseconds_per_tick = 10000;  /* us */

  defaultExceptionHandler ();
}
void CGbaLoader::LoadBorder(void)
{
  videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

  // for the main screen
  REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
  REG_BG3PA = 1 << 8; //scale x
  REG_BG3PB = 0; //rotation x
  REG_BG3PC = 0; //rotation y
  REG_BG3PD = 1 << 8; //scale y
  REG_BG3X = 0; //translation x
  REG_BG3Y = 0; //translation y

  memset((void*)BG_BMP_RAM(0),0,0x18000);
  memset((void*)BG_BMP_RAM(8),0,0x18000);

  cBMP15 frameBMP=createBMP15FromFile(SFN_GBAFRAME);
  if(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
  {
    DC_FlushRange(frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(0),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(8),SCREEN_WIDTH*SCREEN_HEIGHT*2);
  }
}
Exemple #13
0
    void onInit()
    {
        setBrightness(3, -16);
        videoSetMode(MODE_5_2D);
        videoSetModeSub(MODE_0_2D);

        vramSetBankA(VRAM_A_MAIN_BG);
        vramSetBankC(VRAM_C_SUB_BG);

        int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);

        dmaCopy(splashBitmap, bgGetGfxPtr(bg3), 256*256);
        dmaCopy(splashPal, BG_PALETTE, 256*2);

        for(int i = 0; i < 128; i++)
        {
            setBrightness(3, -16+(i/8));
            swiWaitForVBlank();
        }
        for(int i = 0; i < 128; i++)
        {
            setBrightness(3, -(i/8));
            swiWaitForVBlank();
        }
    }
Exemple #14
0
int main(int argc, char** argv){
	irqSet(IRQ_VBLANK, &vblank);

	#ifdef TEXTMODE
		videoSetMode(MODE_0_2D);
		videoSetModeSub(MODE_0_2D);

		vramSetBankA(VRAM_A_MAIN_BG);
		vramSetBankC(VRAM_C_SUB_BG);
	#endif//TEXTMODE

	Display::init();

	keysSetRepeat(30, 12);

	srand(time(NULL));

	Player P1(FGrave);
	Player P2(FMidori);

	ControlLocal	C1(P1);
	ControlAI		C2(P2);

	//DisplayPlayerOverview a(0, 0, 0, 32, 1, P1);
	//DisplayContainer b(0, 0, 1, 32, 21, P1.hand());

	//DisplayCard c(1, 0, 0, 32, 24, P1.hand().at(0), false);

	Game(&C1, &C2);

	while(1){
		update();
	}
	return 0;
}
Exemple #15
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 #16
0
void gbaFrame(void)
{
  u16* frame=NULL;
  cBMP15 frameBMP=createBMP15FromFile("/GBA/gbaframe.bmp");
  if(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
  {
    frame=(u16*)malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2);
    memcpy(frame,frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2); //tricky thing
  }

  videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

  // for the main screen
  BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
  BG3_XDX = 1 << 8; //scale x
  BG3_XDY = 0; //rotation x
  BG3_YDX = 0; //rotation y
  BG3_YDY = 1 << 8; //scale y
  BG3_CX = 0; //translation x
  BG3_CY = 0; //translation y

  if(frame)
  {
    dmaCopy(frame,(void*)BG_BMP_RAM(0),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    dmaCopy(frame,(void*)BG_BMP_RAM(8),SCREEN_WIDTH*SCREEN_HEIGHT*2);
    free(frame);
  }
  else
  {
    memset((void*)BG_BMP_RAM(0),0,0x18000);
    memset((void*)BG_BMP_RAM(8),0,0x18000);
  }
}
Exemple #17
0
void resetMemory2_ARM9() 
{
 	register int i;
 
	//clear out ARM9 DMA channels
	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;
	}
 
	VRAM_CR = 0x80808080;
	VRAM_E_CR = 0x80;
	VRAM_F_CR = 0x80;
	VRAM_G_CR = 0x80;
	VRAM_H_CR = 0x80;
	VRAM_I_CR = 0x80;
	
	// clear vram
	u16 * vram = 0x6800000;
	zeroMemory(vram, 656 * 1024 );
	// clear video palette
	zeroMemory( BG_PALETTE, 2048 );//BG_PALETTE[0] = RGB15(1,1,1);
	zeroMemory( BG_PALETTE_SUB, 2048 );
	// clear video object attribution memory
	zeroMemory( OAM, 2048 );
	zeroMemory( OAM_SUB, 2048 );
	// clear video object data memory
	zeroMemory( SPRITE_GFX, 128 * 1024 );
	zeroMemory( SPRITE_GFX_SUB, 128 * 1024 );
	// clear main display registers
	zeroMemory( (void*)0x04000000, 0x6c );
	// clear sub display registers
	zeroMemory( (void*)0x04001000, 0x6c );
	
	// clear maths registers
	zeroMemory( (void*)0x04000280, 0x40 );
 
	REG_DISPSTAT = 0;
	videoSetMode(0);
	videoSetModeSub(0);
	VRAM_A_CR = 0;
	VRAM_B_CR = 0;
	VRAM_C_CR = 0;
	VRAM_D_CR = 0;
	VRAM_E_CR = 0;
	VRAM_F_CR = 0;
	VRAM_G_CR = 0;
	VRAM_H_CR = 0;
	VRAM_I_CR = 0;
	VRAM_CR   = 0x03000000;
	REG_POWERCNT  = 0x820F;
 
	//set shared ram to ARM7
	WRAM_CR = 0x03;
 
}
Exemple #18
0
int main() {
		
	// Setup the Main screen for 3D 
	videoSetMode(MODE_0_3D);
		
	// initialize the geometry engine
	glInit();
	
	// enable antialiasing
	glEnable(GL_ANTIALIAS);
	
	// setup the rear plane
	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(0x7FFF);
	
	// Set our viewport to be the same size as the screen
	glViewport(0,0,255,191);
	
	// setup the view
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(70, 256.0 / 192.0, 0.1, 100);
	
	
	//ds specific, several attributes can be set here	
	glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
	
	while (1) 
	{
		// Set the current matrix to be the model matrix
		glMatrixMode(GL_MODELVIEW);
		
		glColor3f(1, 1, 1);									// Set the color..not in nehe source...ds gl default will be black
		
		//Push our original Matrix onto the stack (save state)
		glPushMatrix();	

		DrawGLScene();
		
		// Pop our Matrix from the stack (restore state)
		glPopMatrix(1);

		//a handy little built in function to wait for a screen refresh
		swiWaitForVBlank();

		// flush to screen	
		glFlush(0);

		scanKeys();

		int pressed = keysDown();

		if(pressed & KEY_START) break;	
	}
	
	return 0;
}
Exemple #19
0
void video_init()
{
    powerSET(POWER_LCD | POWER_2D_B);
    lcdMainOnBottom();
    videoSetMode(0);
    consoleDemoInit();

    iprintf("Wifi EEPROM Dumper\nMicah Dowty <*****@*****.**>\n\n");
}
Exemple #20
0
    boxUI::boxUI( ) {
        IO::swapScreens( );
        IO::vramSetup( );
        videoSetMode( MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE
                      | DISPLAY_SPR_1D | DISPLAY_SPR_EXT_PALETTE );
        dmaFillWords( 0, bgGetGfxPtr( IO::bg2 ), 256 * 192 );
        dmaFillWords( 0, bgGetGfxPtr( IO::bg2sub ), 256 * 192 );

        bgUpdate( );
        swiWaitForVBlank( );
        IO::NAV->draw( );
        drawAllBoxStatus( );

        IO::initOAMTable( false );
        u16 tileCnt = 0;

        tileCnt = IO::loadSprite( BACK_ID, BACK_ID, 0, tileCnt, SCREEN_WIDTH - 28,
                                  SCREEN_HEIGHT - 28, 32, 32, BackPal, BackTiles, BackTilesLen,
                                  false, false, false, OBJPRIORITY_1, false );
        tileCnt
            = IO::loadSprite( ARROW_ID, 0, 1, tileCnt, 0, 0, 16, 16, box_arrowPal, box_arrowTiles,
                              box_arrowTilesLen, false, false, true, OBJPRIORITY_0, false );
        tileCnt += 64;
        tileCnt = IO::loadSprite( PAGE_ICON_START + ( 0 ), 0, PAGE_ICON_START + ( 0 ), tileCnt, 20,
                                  0, 32, 32, time_iconPal, time_iconTiles, time_iconTilesLen, false,
                                  false, true, OBJPRIORITY_0, false );
        tileCnt = IO::loadSprite( PAGE_ICON_START + ( 1 ), 0, PAGE_ICON_START + ( 1 ), tileCnt, 40,
                                  0, 32, 32, memoPal, memoTiles, memoTilesLen, false, false, true,
                                  OBJPRIORITY_0, false );
        tileCnt = IO::loadSprite( PAGE_ICON_START + ( 2 ), 0, PAGE_ICON_START + ( 2 ), tileCnt, 0,
                                  0, 32, 32, PKMNPal, PKMNTiles, PKMNTilesLen, false, false, true,
                                  OBJPRIORITY_0, false );
        tileCnt = IO::loadSprite( PAGE_ICON_START + ( 3 ), 0, PAGE_ICON_START + ( 3 ), tileCnt, 50,
                                  0, 32, 32, atksPal, atksTiles, atksTilesLen, false, false, true,
                                  OBJPRIORITY_0, false );
        tileCnt = IO::loadSprite( PAGE_ICON_START + ( 4 ), 0, PAGE_ICON_START + ( 4 ), tileCnt, 60,
                                  0, 32, 32, ContestPal, ContestTiles, ContestTilesLen, false,
                                  false, true, OBJPRIORITY_0, false );
        for( u8 i = 0; i < 5; ++i ) {
            IO::OamTop->oamBuffer[ PAGE_ICON_START + i ].x = 48 + 32 * i;
            IO::OamTop->oamBuffer[ PAGE_ICON_START + i ].y = 256 - 10;
        }
        IO::updateOAM( false );
        IO::initOAMTable( true );

        BG_PALETTE[ COLOR_IDX ] = GREEN;
        BG_PALETTE[ WHITE_IDX ] = WHITE;
        BG_PALETTE[ GRAY_IDX ]  = GRAY;
        BG_PALETTE[ BLACK_IDX ] = BLACK;
        BG_PALETTE[ RED_IDX ]   = RED;

        BG_PALETTE_SUB[ COLOR_IDX ] = GREEN;
        BG_PALETTE_SUB[ WHITE_IDX ] = WHITE;
        BG_PALETTE_SUB[ GRAY_IDX ]  = GRAY;
        BG_PALETTE_SUB[ BLACK_IDX ] = BLACK;
        BG_PALETTE_SUB[ RED_IDX ]   = RED;
    }
Exemple #21
0
void initMenu(void)
{
	lcdMainOnTop();
	videoSetMode(MODE_5_3D);
	videoSetModeSub(MODE_5_2D);
	
	vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_SUB_BG,VRAM_D_TEXTURE);	
	
	initD3D();

	glInit();
	
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_ANTIALIAS);
	glEnable(GL_BLEND);
	glEnable(GL_OUTLINE);
	
	glClearPolyID(63);
	glClearDepth(0x7FFF);
	glViewport(0,0,255,191);
	
	initVramBanks(2);
	initTextures();

	initMenuScene();

	initMenuButtons();

	//TEMP
	glLight(0, RGB15(31,31,31), cosLerp(4096), 0, sinLerp(4096));

	glMaterialf(GL_AMBIENT, RGB15(8,8,8));
	glMaterialf(GL_DIFFUSE, RGB15(24,24,24));
	glMaterialf(GL_SPECULAR, RGB15(0,0,0));
	glMaterialf(GL_EMISSION, RGB15(0,0,0));

	glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP?
	glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP?

	applyCameraState(&menuCamera,&cameraStates[4]);
	tempState=cameraStates[4];
	testTransition=startCameraTransition(&cameraStates[1],&cameraStates[4],64);

	setupMenuPage(startMenuPage, startMenuPageLength);

	logoMain=createTexture("logo.pcx", "menu");
	logoRotate=createTexture("rotate_logo.pcx", "menu");
	logoAlpha=31;

	glSetOutlineColor(0,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(1,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(7,RGB15(0,0,0)); //TEMP?

	NOGBA("END mem free : %dko (%do)",getMemFree()/1024,getMemFree());
	fadeIn();
}
Exemple #22
0
void init_displays()
{
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_0_2D);

	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankB(VRAM_B_MAIN_BG);

	lcdMainOnBottom();
}
bool Game::Init()
{
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_5_2D);

	mmInitDefault("assets/soundbank.bin");

	std::cout << "Game Init success\n";
	return true;
}
Exemple #24
0
	void Game::initVram()
	{
		videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE |
			DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT);
		vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
		vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
		videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE|
			DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT);
		vramSetBankC(VRAM_C_SUB_BG_0x06200000);
		vramSetBankD(VRAM_D_SUB_SPRITE);
	}
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	//set the mode for 2 text layers and two extended background layers
	videoSetMode(MODE_5_2D); 

	//set the first two banks as background memory and the third as sub background memory
	//D is not used..if you need a bigger background then you will need to map
	//more vram banks consecutivly (VRAM A-D are all 0x20000 bytes in size)
	vramSetPrimaryBanks(	VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, 
		VRAM_C_SUB_BG , VRAM_D_LCD); 

	consoleDemoInit();

	iprintf("\n\n\tHello DS devers\n");
	iprintf("\twww.drunkencoders.com\n");
	iprintf("\tdouble buffer demo");


	int bg = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);

	u16 colorMask = 0x1F;

	u16* backBuffer = (u16*)bgGetGfxPtr(bg) + 256*256;

	while(1) 
	{
		//draw a box (60,60,196,136)
		for(int iy = 60; iy < 196 - 60; iy++)
			for(int ix = 60; ix < 256 - 60; ix++) 
				backBuffer[iy * 256 + ix] = (rand() & colorMask) | BIT(15);

		swiWaitForVBlank();
		scanKeys();
		if (keysDown()&KEY_START) break;

		//swap the back buffer to the current buffer
		backBuffer = (u16*)bgGetGfxPtr(bg);

		//swap the current buffer by changing the base. Each base
		//represents 16KB of offset and each screen is 256x256x2 (128KB)
		//this requires a map base seperation of 8 (could get away with smaller
		//as the screen is really only showing 256x192 (96KB or map base 6)
		if(bgGetMapBase(bg) == 8)
		{
			bgSetMapBase(bg, 0);
		}
		else
		{
			bgSetMapBase(bg, 8);
		}

		colorMask ^= 0x3FF;
	}
}
Exemple #26
0
// Initializes the hardware and sets up the backgrounds
void prepare_screens()
{
	videoSetMode(MODE_0_2D);
	videoSetModeSub(MODE_0_2D);

	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankC(VRAM_C_SUB_BG);

	consoleInit(&top_screen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
	consoleInit(&bottom_screen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
}
Exemple #27
0
void iconTitleInit (void) {
	// initialize video mode
	videoSetMode(MODE_4_2D);

	// initialize VRAM banks
	vramSetPrimaryBanks(VRAM_A_MAIN_BG,
	                    VRAM_B_MAIN_SPRITE,
	                    VRAM_C_LCD,
	                    VRAM_D_LCD);

	// initialize bg2 as a rotation background and bg3 as a bmp background
	// http://mtheall.com/vram.html#T2=3&RNT2=96&MB2=3&TB2=0&S2=2&T3=6&MB3=1&S3=1
	bg2 = bgInit(2, BgType_Rotation, BgSize_R_512x512,   3, 0);
	bg3 = bgInit(3, BgType_Bmp16,    BgSize_B16_256x256, 1, 0);

	// initialize rotate, scale, and scroll
	bgSetRotateScale(bg3, 0, 1<<8, 1<<8);
	bgSetScroll(bg3, 0, 0);
	bgSetRotateScale(bg2, 0, 8*(1<<8)/6, 1<<8);
	bgSetScroll(bg2, -TITLE_POS_X, -TITLE_POS_Y);

	// clear bg2's map: 512x512 pixels is 64x64 tiles is 4KB
	dmaFillHalfWords(0, bgGetMapPtr(bg2), 4096);
	// load compressed font into bg2's tile data
	decompress(font6x8Tiles, bgGetGfxPtr(bg2), LZ77Vram);

	// load compressed bitmap into bg3
	decompress(hbmenu_bannerBitmap, bgGetGfxPtr(bg3), LZ77Vram);

	// load font palette
	dmaCopy(font6x8Pal, BG_PALETTE, font6x8PalLen);

	// apply the bg changes
	bgUpdate();

	// initialize OAM
	oamInit(&oamMain, SpriteMapping_1D_128, false);
	sprite = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_16Color);
	dmaFillHalfWords(0, sprite, sizeof(banner.icon));
	oamSet(&oamMain, 0, ICON_POS_X, ICON_POS_Y, 0, 0,
	       SpriteSize_32x32, SpriteColorFormat_16Color, sprite,
	       -1, 0, 0, 0, 0, 0);

	// oam can only be updated during vblank
	swiWaitForVBlank();
	oamUpdate(&oamMain);

	// everything's ready :)
	writeRow (0,"...initializing...");
	writeRow (1,"===>>> HBMenu+ <<<===");
	writeRow (2,"(this text should disappear...");
	writeRow (3,"...otherwise, trouble!)");
}
void advMultipleLayers(void)
{
	videoSetMode(MODE_5_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	
	//initialize the backgrounds
	int bg1 = bgInit(0, BgType_Text8bpp, BgSize_ER_256x256, 0,1);
	int bg2 = bgInit(1, BgType_Text8bpp, BgSize_ER_256x256, 1,1);
	int bg3 = bgInit(2, BgType_ExRotation, BgSize_ER_256x256, 2,1);
	
	//make sure the floor is on the bottom (by default hardware layer 0 will be rendered last)
	bgSetPriority(bg1, 3);
	bgSetPriority(bg2, 2);
	bgSetPriority(bg3, 1);
	
	//they all share tiles and a palette
	dmaCopy(MultilayerTiles, bgGetGfxPtr(bg1), sizeof(MultilayerTiles));
	dmaCopy(MultilayerPal, BG_PALETTE, sizeof(MultilayerPal));

	//all we need to do is copy in the maps
	dmaCopy(Layer_1Map, bgGetMapPtr(bg1),  Layer_1MapLen);
	dmaCopy(Layer_2Map, bgGetMapPtr(bg2),  Layer_2MapLen);
	dmaCopy(Layer_3Map, bgGetMapPtr(bg3),  Layer_3MapLen);
	
	int keys = 0;
	bool bg1_hidden = false;
	bool bg2_hidden = false;
	bool bg3_hidden = false;

	while(!(keys & KEY_B))
	{
		scanKeys();
		
		keys = keysDown();
		
		if(keys & KEY_UP) bg1_hidden = !bg1_hidden;
		if(keys & KEY_DOWN) bg2_hidden = !bg2_hidden;
		if(keys & KEY_LEFT) bg3_hidden = !bg3_hidden;
		
		swiWaitForVBlank();
		
		bg1_hidden ? bgHide(bg1) : bgShow(bg1);
		bg2_hidden ? bgHide(bg2) : bgShow(bg2);
		bg3_hidden ? bgHide(bg3) : bgShow(bg3);
		
		consoleClear();

		iprintf("Press UP DOWN LEFT to toggle the layers\n\n");
		iprintf("Floor (UP): %s\n", bg1_hidden ? "hidden" : "displayed");
		iprintf("Walls (DOWN): %s\n", bg2_hidden ? "hidden" : "displayed");
		iprintf("Decorations (LEFT): %s\n", bg3_hidden ? "hidden" : "displayed");
	}
}
Exemple #29
0
void videoInit()
{
	videoSetModeSub(MODE_0_2D);
	oamInit(&oamSub, SpriteMapping_Bmp_1D_128, false);

	int bgId = bgInitSub(3, BgType_Text8bpp, BgSize_T_256x256, 0, 1);
	bgSetPriority(bgId, 3);
	dmaCopy(background.gfxData, bgGetGfxPtr(bgId), MemChunk_GetSize(background.gfxData));
	dmaCopy(background.mapData, bgGetMapPtr(bgId), MemChunk_GetSize(background.mapData));
	dmaCopy(background.palData, BG_PALETTE_SUB,    MemChunk_GetSize(background.palData));

	videoSetMode(MODE_3_2D);

	int bgBmp = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 2, 0);
	bmpBuf = bgGetGfxPtr(bgBmp);
	clearBitmap();

	int bgTop = bgInit(2, BgType_Text8bpp, BgSize_T_256x256, 0, 1);
	bgSetPriority(bgTop, 3);
	dmaCopy(topscr.gfxData, bgGetGfxPtr(bgTop), MemChunk_GetSize(topscr.gfxData));
	dmaCopy(topscr.mapData, bgGetMapPtr(bgTop), MemChunk_GetSize(topscr.mapData));
	dmaCopy(topscr.palData, BG_PALETTE,         MemChunk_GetSize(topscr.palData));

	u16* gfx = SPRITE_GFX_SUB;
	for (int i = 0; i < 6; i ++)
	{
		int xPos = 16 + (i % 3) * (64+16);
		int yPos = 48 + (i / 3) * (64+8);
		oamSet(&oamSub, i, xPos, yPos, 1, 15, SpriteSize_64x64, SpriteColorFormat_Bmp, gfx, -1, 0, false, false, false, false);
		gfx += 64*64;
	}
	{
		dmaCopy(selection.gfxData, gfx, MemChunk_GetSize(selection.gfxData));
		oamSet(&oamSub, 6, 0, 0, 0, 15, SpriteSize_16x16, SpriteColorFormat_Bmp, gfx, -1, 0, false, false, false, false);
		gfx += 16*16;
	}
	for (int i = 0; i < MAX_RUNNING_APP_COUNT; i ++)
	{
		oamSet(&oamSub, 7+i, 64+(i*(16+8)), 16, 1, 15, SpriteSize_16x16, SpriteColorFormat_Bmp, gfx, -1, 0, false, false, false, false);
		oamSub_mem[7+i].isHidden = true;
		gfx += 16*16;
	}

	g_appListChanged = true;

	bump.init(BG_PALETTE_SUB);
	bump.SelectBump(page);
	updCursor();
	loadPageIcons();
	updAppList();
	forceTopScrRefresh = true;
}
void advRotating(void)
{
	videoSetMode(MODE_5_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	
	int bg = bgInit(3, BgType_ExRotation, BgSize_ER_256x256, 0,1);
	
	dmaCopy(TextBackgroundsTiles, bgGetGfxPtr(bg), sizeof(TextBackgroundsTiles));
	dmaCopy(TextBackgroundsPal, BG_PALETTE, sizeof(TextBackgroundsPal));
	dmaCopy(Layer256x256Map, bgGetMapPtr(bg),  Layer256x256MapLen);
	
	bgMosaicEnable(bg);
	
	int keys = 0;
	int angle = 0;
	int center_x = 0;
	int center_y = 0;
	
	while(!(keys & KEY_B))
	{
		scanKeys();
		keys = keysHeld();
		
		if(keys & KEY_UP) center_y--;
		if(keys & KEY_DOWN) center_y++;
	
		if(keys & KEY_LEFT) center_x--;
		if(keys & KEY_RIGHT) center_x++;

		if(keys & KEY_L) angle-=40;
		if(keys & KEY_R) angle+=40;

		if(center_x > 256) center_x = 256;
		if(center_x < 0) center_x = 0;
		
		if(center_y > 192) center_y = 192;
		if(center_y < 0) center_y = 0;

		
		swiWaitForVBlank();
		
		bgSetRotate(bg, angle);
		bgSetScroll(bg, center_x, center_y);
		bgSetCenter(bg, center_x, center_y);
		bgUpdate();

		consoleClear();
		iprintf("Press B to exit.n");
		iprintf("Angle: %d \ncenter X: %d  center Y: %d", angleToDegrees(angle), center_x, center_y);
		
	}
}