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 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();
        }
    }
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;
}
Example #4
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;
}
Example #5
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);
}
Example #6
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;
}
Example #7
0
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);
}
Example #8
0
File: main.c Project: elzk/nds-ide
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;
}
Example #9
0
void loadTextures()
{
    vramSetBankA(VRAM_A_TEXTURE);
    vramSetBankF(VRAM_F_TEX_PALETTE_SLOT0);
    vramSetBankG(VRAM_G_TEX_PALETTE_SLOT5);
    glGenTextures(20, textureIDS);
    genTextures();
}
Example #10
0
void init_displays()
{
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_0_2D);

	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankB(VRAM_B_MAIN_BG);

	lcdMainOnBottom();
}
Example #11
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);
}
Example #12
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);
	}
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");
	}
}
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);
		
	}
}
Example #15
0
/*
	Screen_Init

	Mode 5 gives us 2 text backgrounds 0-1 (tiled mode) and
	2 extended rotation backgrounds 2-3. (linear fb)

	Also we need to map 2 banks of vram so we have enough space for
	our 512x512 surface.
*/
LOCALFUNC blnr Screen_Init(void)
{
	videoSetMode(MODE_5_2D);
	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankB(VRAM_B_MAIN_BG_0x06020000);

	Display_bg2_Main = bgInit(2, BgType_Bmp8, BgSize_B8_512x512, 0, 0);

	BG_PALETTE[0] = RGB15(31, 31, 31);
	BG_PALETTE[1] = RGB15(0, 0, 0);

	return trueblnr;
}
Example #16
0
void Hardware::init() {

#ifndef USING_SDL

	powerOn(POWER_ALL_2D);

	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);

	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
	vramSetBankC(VRAM_C_SUB_BG);

	// Initialise backgrounds
	bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);

	_topBuffer = new FrameBuffer((u16*)BG_BMP_RAM(0), SCREEN_WIDTH, SCREEN_HEIGHT);
	_bottomBuffer = new FrameBuffer((u16*)BG_BMP_RAM_SUB(0), SCREEN_WIDTH, SCREEN_HEIGHT);

#else

	Uint32 initflags = SDL_INIT_VIDEO;

	// Initialize the SDL library
	if (SDL_Init(initflags) < 0) {
		fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}

	// Set video mode
    _window = SDL_CreateWindow("EarthShaker", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT * 2, 0);
    _renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
    SDL_SetRenderDrawColor(_renderer, 0, 0, 0, 255);
    SDL_RenderClear(_renderer);
    SDL_RenderPresent(_renderer);

    _texture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_ABGR1555, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT * 2);

    _topBitmap = new u16[SCREEN_WIDTH * SCREEN_HEIGHT];
    _bottomBitmap = new u16[SCREEN_WIDTH * SCREEN_HEIGHT];

	_topBuffer = new FrameBuffer(_topBitmap, SCREEN_WIDTH, SCREEN_HEIGHT);
	_bottomBuffer = new FrameBuffer(_bottomBitmap, SCREEN_WIDTH, SCREEN_HEIGHT);

#endif

	_topGfx = _topBuffer->newGraphics();
	_bottomGfx = _bottomBuffer->newGraphics();
}
Example #17
0
void arm9_consoleInit()
{
    powerON(/*POWER_ALL*/POWER_LCD);
    
    // Use the main screen for output
    videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    vramSetBankA(VRAM_A_MAIN_BG);
    BG0_CR = BG_MAP_BASE(31);

    // Set the colour of the font to White.
    BG_PALETTE[255] = RGB15(31,31,31);

    consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16);
}
Example #18
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 #19
0
	void initMemory() {
		// Setup video mode for Main: 3D | Text | Text | Text
		videoSetMode(MODE_5_3D);
		// Setup video mode for Sub: Text | Text | Rotation | Rotation
		videoSetModeSub(MODE_5_2D);
		//Setup Memory Banks
		vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
		vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
		vramSetBankC(VRAM_C_SUB_BG_0x06200000);
		vramSetBankD(VRAM_D_TEXTURE);

		// Set Main screen on bottom
		REG_POWERCNT &= ~POWER_SWAP_LCDS;
	}
Example #20
0
int main(void)  {
	int i;
	int memUsageTemp = 0xFFFFFFFF;

	videoSetMode(MODE_0_2D);
	videoSetModeSub(MODE_0_2D);
	vramSetBankA(VRAM_A_MAIN_SPRITE);
	vramSetBankB(VRAM_B_MAIN_SPRITE);
	vramSetBankD(VRAM_D_SUB_SPRITE);

	consoleDemoInit();
//	consoleDebugInit(DebugDevice_NOCASH); //send stderr to no$gba debug window

	//api: initialize OAM to 1D mapping with XX byte offsets and no external palette
	oamInit(oam, SpriteMapping_1D_128, false);

	//create some sprites
	for(i = 0; i < SPRITE_MAX; i++)
		randomSprite(&sprites[i]);

	//load a randomly colored palette
	for(i = 0; i < 256; i++) {
      SPRITE_PALETTE[i] = rand();
      SPRITE_PALETTE_SUB[i] = rand();
	}

	while(1) { 
		moveSprites();

		updateSprites();

		swiWaitForVBlank();
		
		//api: updates real oam memory 
		oamUpdate(oam);

		if(oom) {	
			memUsageTemp = memUsageTemp > spriteMemoryUsage ? spriteMemoryUsage : memUsageTemp;
    	}	

		consoleClear();
		
		printf("Memory usage: %i %i%% \n",  spriteMemoryUsage, 100 * spriteMemoryUsage / (spriteMemSize));
		printf("Percentage fail: %i%% \n", oomCount * 100 / allocationCount);
		printf("Lowest Usage at fail %i %i%% \n", memUsageTemp, 100 * memUsageTemp / (spriteMemSize));				
	}

	return 0;
}
Example #21
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 #22
0
File: fb.c Project: epicsdeb/rtems
rtems_device_driver
frame_buffer_open (rtems_device_major_number major,
           rtems_device_minor_number minor, void *arg)
{
   printk ("[#] entering graphic mode on fb%d\n", minor);
   if (!minor) {
      videoSetMode (MODE_FB0);
      vramSetBankA (VRAM_A_LCD);
      memset ((void *)fb_fix_info.smem_start, 0, fb_fix_info.smem_len);
   } else {
      videoSetModeSub (MODE_FB0);
      vramSetBankB (VRAM_B_LCD);
      memset ((void *)fb_fix_info2.smem_start, 0, fb_fix_info2.smem_len);
    }
  return RTEMS_SUCCESSFUL;
}
void advMosaic(void)
{
	videoSetMode(MODE_0_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	
	int bg = bgInit(0, BgType_Text8bpp, BgSize_T_256x256, 0,1);
	
	dmaCopy(TextBackgroundsTiles, bgGetGfxPtr(bg), sizeof(TextBackgroundsTiles));
	dmaCopy(Layer256x256Map, bgGetMapPtr(bg),  Layer256x256MapLen);
	dmaCopy(TextBackgroundsPal, BG_PALETTE, sizeof(TextBackgroundsPal));
	
	bgMosaicEnable(bg);
	
	int keys = 0;
	int mosaic_x = 0;
	int mosaic_y = 0;
	
	while(!(keys & KEY_B))
	{
		scanKeys();
		keys = keysDown();
		
		if(keys & KEY_UP) mosaic_y--;
		if(keys & KEY_DOWN) mosaic_y++;
	
		if(keys & KEY_LEFT) mosaic_x--;
		if(keys & KEY_RIGHT) mosaic_x++;

		if(mosaic_x > 15) mosaic_x = 15;
		if(mosaic_x < 0) mosaic_x = 0;
		
		if(mosaic_y > 15) mosaic_y = 15;
		if(mosaic_y < 0) mosaic_y = 0;

		
		swiWaitForVBlank();
		
		bgSetMosaic(mosaic_x, mosaic_y);
		
		consoleClear();
		iprintf("Press B to exit\n");
		iprintf("DX: %d  DY: %d", mosaic_x, mosaic_y);
		
	}
}
Example #24
0
void BootSplashInit() {

	videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);
	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
	vramSetBankA (VRAM_A_MAIN_BG_0x06000000);
	vramSetBankC (VRAM_C_SUB_BG_0x06200000);
	REG_BG0CNT = BG_MAP_BASE(0) | BG_COLOR_256 | BG_TILE_BASE(2);
	REG_BG0CNT_SUB = BG_MAP_BASE(0) | BG_COLOR_256 | BG_TILE_BASE(2);
	BG_PALETTE[0]=0;
	BG_PALETTE[255]=0xffff;
	u16* bgMapTop = (u16*)SCREEN_BASE_BLOCK(0);
	u16* bgMapSub = (u16*)SCREEN_BASE_BLOCK_SUB(0);
	for (int i = 0; i < CONSOLE_SCREEN_WIDTH*CONSOLE_SCREEN_HEIGHT; i++) {
		bgMapTop[i] = (u16)i;
		bgMapSub[i] = (u16)i;
	}

}
Example #25
0
void splashScreen::initiate()
{
	lcdMainOnTop();

	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_5_2D); 

	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankC(VRAM_C_SUB_BG_0x06200000);	


	//sets up our backgrounds
	bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256,0,0);
	dmaCopy(splashBitmap, bgGetGfxPtr(bg3), splashBitmapLen);
	dmaCopy(splashPal, BG_PALETTE, splashPalLen);
	bg2 = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, 0,0);
	dmaCopy(splashBitmap, bgGetGfxPtr(bg2), splashBitmapLen);
	dmaCopy(splashPal, BG_PALETTE_SUB, splashPalLen);
	initiated = true;
}
void advScaling(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 scale_x = 1 << 8;
	int scale_y = 1 << 8;
	
	while(!(keys & KEY_B))
	{
		scanKeys();
		keys = keysHeld();
		
		if(keys & KEY_UP) scale_y++;
		if(keys & KEY_DOWN) scale_y--;
	
		if(keys & KEY_LEFT) scale_x++;
		if(keys & KEY_RIGHT) scale_x--;

    	swiWaitForVBlank();
		
		bgSetScale(bg, scale_x , scale_y );
		
		bgUpdate();

		consoleClear();
		iprintf("Press B to exit.n");
		iprintf("scale X: %d  scale Y: %d", scale_x, scale_y);
		
	}
}
Example #27
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 #28
0
File: main.c Project: hl1itj/Team3
int
main(void)
{
	// 상단 화면 설정
	InitDebug();
	videoSetMode(MODE_5_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	bgInit(3,BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	decompress(upBitmap, BG_GFX, LZ77Vram);

	// 하단 화면 설정
	videoSetModeSub(MODE_5_2D);
	vramSetBankC(VRAM_C_SUB_BG);
	bgInitSub(3,BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	decompress(downBitmap, BG_GFX_SUB, LZ77Vram);

	xTaskCreate(Key_Task,
			(const signed char * const)"Key_Task",
			2048,
			(void *)NULL,
			tskIDLE_PRIORITY + 10,
			NULL);

	xTaskCreate(Main_Task,
			(const signed char * const)"Main_Task",
			2048,
			(void *)NULL,
			tskIDLE_PRIORITY + 1,
			NULL);

	KeyQueue = xQueueCreate(MAX_KEY_LOG, sizeof(u8));

	vTaskStartScheduler();		// Never returns
	while(1)
		;
	return 0;
}
Example #29
0
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	touchPosition touch;

	PrintConsole topScreen;
	PrintConsole bottomScreen;
	
	videoSetMode(MODE_0_2D);
	videoSetModeSub(MODE_0_2D);

	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankC(VRAM_C_SUB_BG);

	consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
	consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);


	consoleSelect(&topScreen);
	iprintf("\n\n\tHello DS dev'rs\n");
	iprintf("\twww.drunkencoders.com\n");
	iprintf("\twww.devkitpro.org");

	consoleSelect(&bottomScreen);

	while(1) {

		touchRead(&touch);
		
		iprintf("\x1b[10;0HTouch x = %04i, %04i\n", touch.rawx, touch.px);
		iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py);

		swiWaitForVBlank();
	}

	return 0;
}
Example #30
0
int main(void)
{
    touchPosition touch;

    defaultExceptionHandler();

    lcdMainOnBottom();
    irqEnable(IRQ_VBLANK);

    videoSetMode(MODE_FB0);
    vramSetBankA(VRAM_A_LCD);

    consoleDemoInit();

    ClearScreen();

    touchPosition firstTouch = { 0, 0 };
    touchPosition lastTouch = { 0, 0 };

    int colours[3] = { 31, 31, 31 };
    int colourIndex = 0;

    printf("RGB15(%d,%d,%d)\n",colours[0],colours[1],colours[2]);

    std::stack<node*>* path = NULL;
    bool searched = false;

    node start(10,10,NULL);
    node target(244,180,NULL);

    Robot robot;
    robot.setPosition(start.x,start.y);

    int nextTouch = 0;

    //we like infinite loops in console dev!
    while(1)
    {
        swiWaitForVBlank();

        scanKeys();
        touchRead(&touch);

        int kd = keysDown();
        if (kd & KEY_A)
        {
            ClearScreen();
        }

        if (kd & KEY_UP)
        {
            ++colours[colourIndex];
            if (colours[colourIndex] > 31) colours[colourIndex] = 0;
            printf("RGB15(%d,%d,%d)\n",colours[0],colours[1],colours[2]);
        }

        if (kd & KEY_DOWN)
        {
            --colours[colourIndex];
            if (colours[colourIndex] < 0) colours[colourIndex] = 31;
            printf("RGB15(%d,%d,%d)\n",colours[0],colours[1],colours[2]);
        }

        if (kd & KEY_LEFT)
        {
            --colourIndex;
            if (colourIndex < 0) colourIndex = 2;
        }

        if (kd & KEY_RIGHT)
        {
            ++colourIndex;
            if (colourIndex > 2) colourIndex = 0;
        }

        if (kd & KEY_Y)
        {
            robot.setPosition(start.x,start.y);
            path = NULL;
            node::cleanup();
        }

        if(kd & KEY_B)
        {
            printf("Working...\n");
            searched = true;
            node current(robot.getPosition().px, robot.getPosition().py,NULL);
            path = astar::generate_path( astar::search(&current,&target) );
            printf("Path found!\n");
        }

        if (kd & KEY_R)
        {
            nextTouch = 2;
        }

        if (kd & KEY_L)
        {
            nextTouch = 1;
        }

        if(kd & KEY_TOUCH)
        {
            switch (nextTouch)
            {
            case 0:
                firstTouch = touch;
                draw::plot(touch.px,touch.py,RGB15(colours[0],colours[1],colours[2]));
                break;
            case 1: // Set start
                start.x = touch.px;
                start.y = touch.py;
                robot.setPosition(touch);
                break;
            case 2: // Set target
                target.x = touch.px;
                target.y = touch.py;
                break;
            default:
                break;
            }
        }

        if(keysHeld() & KEY_TOUCH)
        {
            if (nextTouch == 0)
            {
                lastTouch = touch;
                draw::line(firstTouch.px, firstTouch.py, lastTouch.px, lastTouch.py, RGB15(colours[0],colours[1],colours[2]));
                firstTouch = touch;
                //q.push(touch);
            }
        }

        if (keysUp() & KEY_TOUCH)
        {
            nextTouch = 0;
        }

        if (path)
        {
            if (searched && !path->empty())
            {
                assert(path != NULL);
                assert(path->top() != NULL);
                robot.move(path->top()->x, path->top()->y);

                if (robot.getPosition().px == path->top()->x && robot.getPosition().py == path->top()->y) path->pop();
            }
            else if (path->empty())
            {
                node::cleanup();
                delete path;
                path = NULL;
                searched = false;
            }
        }
        robot.draw();

        draw::plot(target.x, target.y, RGB15(31,0,0));
        draw::plot(target.x+1, target.y, RGB15(31,0,0));
        draw::plot(target.x+2, target.y, RGB15(31,0,0));
        draw::plot(target.x-1, target.y, RGB15(31,0,0));
        draw::plot(target.x-2, target.y, RGB15(31,0,0));
        draw::plot(target.x, target.y+1, RGB15(31,0,0));
        draw::plot(target.x, target.y+2, RGB15(31,0,0));
        draw::plot(target.x, target.y-1, RGB15(31,0,0));
        draw::plot(target.x, target.y-2, RGB15(31,0,0));
        draw::plot(target.x+1, target.y+1, RGB15(31,0,0));
        draw::plot(target.x+1, target.y-1, RGB15(31,0,0));
        draw::plot(target.x-1, target.y+1, RGB15(31,0,0));
        draw::plot(target.x-1, target.y-1, RGB15(31,0,0));

    }

    return 0;
}