Example #1
0
void Display::modeSelektor(){
	//Displaying bg3, and mode sprites
	bgSetPriority(this->subbg3, 1);
	DC_FlushAll();
	dmaCopy(greyedBgSubTiles,	bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen);
	dmaCopy(greyedBgSubMap,		bgGetMapPtr(this->subbg3), greyedBgSubMapLen);
	bgShow(subbg3);
	s8 i;
	
	
	for (i = 0; i < 4; ++i){
		modesSprite->display(64 + i, 32 +  128 * (i % 2), 16 + 96 * (i / 2), OBJPRIORITY_0, i);
	}
	oamUpdate(&oamSub);
	input->paused = true;
	while(!(Cfg::modeSelector && input->pad->select() == DOWN) && input->modeSelektor() != 1){
		swiWaitForVBlank();
	}
	Cfg::modeSelector = false;
	oamClear(&oamSub, 64, 4);
	if (Cfg::mode == SLIDERS){
		dmaCopy(slidersBg3SubTiles,		bgGetGfxPtr(this->subbg3), slidersBg3SubTilesLen);
		dmaCopy(this->slidersBg3Map,	bgGetMapPtr(this->subbg3), 1536);
	} else {
		bgSetPriority(this->subbg3, 2);
		bgHide(this->subbg3);
	}
}
Example #2
0
void mode__intro__credits___idle(void) {
  //
  // handle fadeout
  //
  if (mode != next_mode) {
    if (((mode_ms - exit_mode_ms) > INTRO__CREDITS__TOP_BG_FADE_OUT_DURATION_MS) &&
	((mode_ms - exit_mode_ms) > INTRO__CREDITS__BOT_BG_FADE_OUT_DURATION_MS) &&
	((mode_ms - exit_mode_ms) > INTRO__CREDITS__BOT_TXT_FADE_OUT_DURATION_MS)) {

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bg3),
		       256 * 256 * 2);
      //      memptr = (u16*)bgGetGfxPtr(bg3);
      //      for (i = 0 ; i < (256 * 256) ; i++) memptr[i] = (u16)0;
      
      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs3),
		       256 * 256);

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs2),
		       256 * 256);

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs0),
		       256 * 256 / 2);

      system_xmode_real();
    }
  }
}
Example #3
0
void initBackgrounds() {
	// bgInit(int layer, BgType type, BgSize size, int mapBase, int tileBase)	
	int bg2 = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0,0);
	int bg2sub = bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 2,0);
	decompress(MainBgBitmap, bgGetGfxPtr(bg2),  LZ77Vram);	
	decompress(MainBgBitmap, bgGetGfxPtr(bg2sub),  LZ77Vram);	
}
Example #4
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;
    }
Example #5
0
void evaluate(tlmmProgram *prog) {
  int x;
  dmaFillHalfWords(0, bgGetGfxPtr(3), 256*192*2);

  for(x = 0; x < 256; x++) {
#define SCALE 16
    float v = 192/2 - tlmmGetValue(prog, (float)(x-128)/SCALE)*SCALE;
    if(v >= 0 && v < 192)
      bgGetGfxPtr(3)[(int)v * 256 + x] = ARGB16(1, 31, 31, 31);
  }
}
Example #6
0
//---------------------------------------------------------------------------------
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;
	}
}
Example #7
0
void Outro_LoadResources(int grid_bg_main_id, int grid_bg_sub_id)
{
	/* Copy tile, map and palette data into VRAM */
	dmaCopy(gridTiles, bgGetGfxPtr(grid_bg_main_id), gridTilesLen);
	dmaCopy(gridMap, bgGetMapPtr(grid_bg_main_id), gridMapLen);
	dmaCopy(gridPal, BG_PALETTE + 0x2, gridPalLen);

	dmaCopy(gridTiles, bgGetGfxPtr(grid_bg_sub_id), gridTilesLen);
	dmaCopy(gridMap, bgGetMapPtr(grid_bg_sub_id), gridMapLen);
	dmaCopy(gridPal, BG_PALETTE_SUB + 0x2, gridPalLen);
}
Example #8
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!)");
}
Example #9
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;
}
Example #10
0
void Display::editKaossParams(){
	CCParam* ccParam = NULL;

	bgSetPriority(this->subbg3, 1);
	DC_FlushAll();
	dmaCopy(greyedBgSubTiles,	bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen);
	dmaCopy(greyedBgSubMap,		bgGetMapPtr(this->subbg3), greyedBgSubMapLen);
	bgShow(this->subbg3);
	while(!(Cfg::editParams && input->pad->start() == DOWN)){
		for (u8 i = 0; i<3; ++i){
			if (i == 0){
				echo(0, RED, 5, 7 + 8*(i%8), "X");
				ccParam = &Cfg::kaoss.x[Cfg::kaoss.bank];
			}
			if (i == 1){
				echo(0, RED, 5, 7 + 8*(i%8), "Y");
				ccParam = &Cfg::kaoss.y[Cfg::kaoss.bank];
			}
			if (i == 2){
				echo(0, RED, 5, 7 + 8*(i%8), "Z");
				ccParam = &Cfg::kaoss.z[Cfg::kaoss.bank];
			}
			

			echo(0, WHITE, 8, 7 + 8*(i%8), "CC");
			paramsEditSprite->display(16+i, 56 + 64*(i%8), 72, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 10, 6 + 8*(i%8), (*ccParam).cc);
			paramsEditSprite->display(32+i, 56 + 64*(i%8), 88, OBJPRIORITY_0, 1);
			
			echo(0, WHITE, 13, 7 + 8*(i%8), "CH");
			paramsEditSprite->display(48+i, 56 + 64*(i%8), 112, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 15, 6 + 8*(i%8), 1 + (*ccParam).channel);
			paramsEditSprite->display(64+i, 56 + 64*(i%8), 128, OBJPRIORITY_0, 1);
		}
		oamUpdate(&oamSub);
		input->editKaossParams();
		Cfg::editParams = true;
		swiWaitForVBlank();
	}
	Cfg::editParams = false;
	save->write();
	oamClear(&oamSub, 16, 80);	
	consoleClear();
	if (Cfg::mode == SLIDERS){
		dmaCopy(slidersBg3SubTiles,	bgGetGfxPtr(this->subbg3), slidersBg3SubTilesLen);
		dmaCopy(slidersBg3Map,		bgGetMapPtr(this->subbg3), 1536);
	} else {
		bgSetPriority(this->subbg3, 2);
		bgHide(this->subbg3);
	}
}
Example #11
0
void DSGM_InitText(DSGM_Layer *layer) {
	DSGM_Debug("Init text: screen %d, layerNumber %d, vramId %d\n", layer->screen, layer->layerNumber, DSGM_text[layer->screen][layer->layerNumber].bgId);
	
	ConsoleFont font;
	
	if(layer->background != DSGM_DEFAULT_FONT) {
		font.gfx = bgGetGfxPtr(layer->vramId);
		
		DSGM_UnlockBackgroundPalette(layer->screen);
		font.pal = (u16 *)&(layer->screen == DSGM_TOP ? VRAM_E_EXT_PALETTE : VRAM_H_EXT_PALETTE)[layer->layerNumber][0];
		font.numColors = 2;
		
		font.numChars = 127;
		font.bpp = 4;
		font.asciiOffset = 0;
		font.convertSingleColor = false;
	}
	
	consoleInit(&DSGM_text[layer->screen][layer->layerNumber], layer->layerNumber, BgType_Text4bpp, BgSize_T_256x256, layer->mapBase, layer->tileBase, layer->screen, layer->background == DSGM_DEFAULT_FONT);
	layer->vramId = DSGM_text[layer->screen][layer->layerNumber].bgId;
	
	if(layer->background != DSGM_DEFAULT_FONT) {
		consoleSetFont(&DSGM_text[layer->screen][layer->layerNumber], &font);
		DSGM_LockBackgroundPalette(layer->screen);
	}
	
	DSGM_textLayer[layer->screen] = layer->layerNumber;
	consoleSelect(&DSGM_text[layer->screen][layer->layerNumber]);
	consoleClear();
}
Example #12
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();
        }
    }
Example #13
0
void BndsModifier::clearCanvas()
{
      swiWaitForVBlank();
      u16* buffer = (u16*) bgGetGfxPtr ( g_video->backgroundMain() );
      /// Borra la pantalla.
      drawRectangle8bpp ( 41, 0, 255, 170, 6, buffer );

}
Example #14
0
void fillEmptyPage(AppState & state) {
  for (int y=0 ; y < MY_BG_H; y++) {
    int offset = y * MY_BG_W / 2;
    for (int x=0; x<MY_BG_W; x+=2) {
      int offset2 = offset + x/2;
      bgGetGfxPtr(3)[offset2] = 0;
    }
  }
  state.lastImageFromPcx = false;
}
Example #15
0
	void init() {

		initMemory();

		//Init backgrounds
		// Main 3D
		init3DSettings();
		// Main Map:
		mapEngine = new MapEngine(1, 4, 1);
		// Main Console:
		consoleInit(&main_console,3,BgType_ExRotation, BgSize_ER_256x256, 31, 0, true, false);
		bg3 = main_console.bgId;
		bgSetCenter(bg3, 254, 0);
		bgSetRotate(bg3, -8192);

		// Sub Console:
		consoleInit(&sub_console,3,BgType_ExRotation, BgSize_ER_256x256, 31, 1, false, false);
		bg3Sub = sub_console.bgId;
		bgSetCenter(bg3Sub, 254, 0);
		bgSetRotate(bg3Sub, -8192);

		// Sub Image:
		bg2Sub = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, 4,0);
		dmaCopy(leftmenuBitmap, bgGetGfxPtr(bg2Sub), 256*192);
		dmaCopy(leftmenuPal, BG_PALETTE_SUB, leftmenuPalLen);

		// Init Sprites
		oamInit(&oamMain, SpriteMapping_1D_128, false);

		// Set the priorities
		bgSetPriority(0,1);
		bgSetPriority(1,2);
		bgSetPriority(2,3);
		bgSetPriority(3,0);
		bgSetPriority(bg3Sub, 2);
		bgSetPriority(bg2Sub, 3);

		//Init font
		font.gfx = (u16*)fontTiles;
		font.pal = (u16*)fontPal;
		font.numChars = 95;
		font.numColors =  fontPalLen / 2;
		font.bpp = 8;
		font.asciiOffset = 32;
		font.convertSingleColor = false;
		consoleSetFont(&main_console, &font);
		consoleSetFont(&sub_console, &font);

		consoleSelect(&main_console);
		iprintf("\x1b[2J");
		iprintf("Arkham Tower v0.01");
		consoleSelect(&sub_console);
		iprintf("\x1b[2J");
	}
Example #16
0
void setMenuUP() {
	switch (cscreen) {
		case 0:
	dmaCopy(menu1Bitmap, bgGetGfxPtr(bg3), 256*256);
	dmaCopy(menu1Pal, BG_PALETTE, 256*2);
	break;
		case 1:
	dmaCopy(menu2Bitmap, bgGetGfxPtr(bg3), 256*256);
	dmaCopy(menu2Pal, BG_PALETTE, 256*2);
	break;
		case 2:
	dmaCopy(menu3Bitmap, bgGetGfxPtr(bg3), 256*256);
	dmaCopy(menu3Pal, BG_PALETTE, 256*2);
	break;
		case 4:
	dmaCopy(menu5Bitmap, bgGetGfxPtr(bg3), 256*256);
	dmaCopy(menu5Pal, BG_PALETTE, 256*2);
	break;
	}
}
Example #17
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;
}
Example #18
0
    void boxUI::drawAllBoxStatus( bool p_bottom ) {
        dmaFillWords( 0, bgGetGfxPtr( !p_bottom ? IO::bg2sub : IO::bg2 ), 256 * 192 );
        dmaFillWords( 0, bgGetGfxPtr( !p_bottom ? IO::bg3sub : IO::bg3 ), 256 * 192 );

        auto pal = BG_PAL( !p_bottom );
        pal[ 0 ] = WHITE;
        char buffer[ 50 ];

        IO::initOAMTable( !p_bottom );
        IO::regularFont->printString( GET_STRING( 61 ), 4, 3, !p_bottom );
        u8  w = 32, h = 24; // width and heigth
        u16 pkmncnt = 0;
        for( u8 i = 0; i < 7; ++i )
            for( u8 j = 0; j < 6; ++j ) {
                pal[ 128 + j * 7 + i ] = getBoxColor( j * 7 + i );
                u8   x                 = 2 + 36 * i;
                u8   y                 = 22 + 28 * j;
                bool prsd              = j * 7 + i == SAVE::SAV->getActiveFile( ).m_curBox;
                IO::printChoiceBox( x, y, x + w, y + h, 6 - 2 * prsd, 128 + j * 7 + i, false,
                                    !p_bottom );
                u8 cnt = SAVE::SAV->m_storedPokemon[ j * 7 + i ].count( );
                pkmncnt += cnt;
                if( cnt == MAX_PKMN_PER_BOX )
                    IO::regularFont->setColor( RED_IDX, 1 );
                else
                    IO::regularFont->setColor( BLACK_IDX, 1 );
                snprintf( buffer, 49, "%2d", cnt );
                IO::regularFont->printString( buffer, x + 7, y + 5, !p_bottom );
            }
        snprintf( buffer, 49, "%4d Pokémon", pkmncnt );
        if( pkmncnt == 756 )
            IO::regularFont->setColor( RED_IDX, 1 );
        else
            IO::regularFont->setColor( BLACK_IDX, 1 );
        IO::regularFont->printString( buffer, 252, 3, !p_bottom, IO::font::RIGHT );

        for( u8 i = 0; i < 5; ++i ) {
            IO::OamTop->oamBuffer[ PAGE_ICON_START + i ].isHidden = true;
        }
        IO::updateOAM( false );
    }
Example #19
0
void initConsole(void)
{
	int sz = 0;
	u16* consoleGfx = bufferFile("font.img.bin", &sz);
	if(consoleGfx) {
		consoleId = bgInitSub(0, BgType_Text4bpp, BgSize_T_256x256, 2,0);
		dmaCopy(consoleGfx, bgGetGfxPtr(consoleId), sz);
		col = row = 0;
		consoleMap = bgGetMapPtr(consoleId);
		free(consoleGfx);
	}
}
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 #22
0
// MIXER Functions
//-------------------------------------------------------------------------
void Display::mixer(){
	clearGfx();

	DC_FlushAll();
	dmaCopy(mixerBgSubTiles,	bgGetGfxPtr(subbg2), mixerBgSubTilesLen);
	dmaCopy(mixerBgSubMap,		bgGetMapPtr(subbg2), mixerBgSubMapLen);
	
	for (u8 i = 0; i < 8; ++i)
		muteSprite->display(i, i*32 , 163, 1, 1);
	
	bgHide(mainbg3);
	save->writeCcs();
}
Example #23
0
// SLIDERS Functions
//-------------------------------------------------------------------------
void Display::sliders(){
	clearGfx();

	for(u8 i = 0; i<16; ++i){
		this->updateSliderMap(i);
		this->updateSliderUpMap(i);
	}

	DC_FlushAll();	
	dmaCopy(slidersBg2SubTiles,		bgGetGfxPtr(subbg2), slidersBg2SubTilesLen);
	dmaCopy(slidersBg3SubTiles,		bgGetGfxPtr(subbg3), slidersBg3SubTilesLen);

	DC_FlushAll();
	dmaCopy(slidersBg2Map,		bgGetMapPtr(subbg2), 1536);
	dmaCopy(slidersBg3Map,		bgGetMapPtr(subbg3), 1536);
	
	echo(1, LIGHT_GREY, 1, 2, "BANK:");
	echo(1, WHITE, 6, 3, "BANK-");
	echo(1, WHITE, 6, 19, "BANK;");

	bgHide(mainbg3);
	save->writeCcs();
}
Example #24
0
int main(void)
{
	// Video setup
	lcdMainOnBottom();
	irqEnable(IRQ_VBLANK);
	
	vramSetBankC(VRAM_C_SUB_BG);
	
    // Text console
	videoSetModeSub(MODE_5_2D);
	PrintConsole *pc = consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true);
	BG_PALETTE_SUB[255] = RGB15(31,15,0);
	bgSetPriority(pc->bgId, 0);
	
    // DSMI Logo
	int bg2 = bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 2, 0);
	bgSetPriority(bg2, 1);
	u16 *bg2vram = bgGetGfxPtr(bg2);
	dmaCopy(dsmi_logo_dsBitmap, bg2vram, 256*192);
	
	iprintf("\x1b[12;12HPulse DS\n");
	
	// Connect
	int res = dsmi_connect();
	while(res == 0) {
		iprintf("\x1b[15;0H\x1b[KCould not connect. We apologize for the inconvecience.\n");
		while(1);
	}
	
	iprintf("\x1b[15;0H\x1b[KRunning.\n");
	
	u8 message, data1, data2;
	while(1)
	{
		// We query every 60th of a second (notice the swiWaitForVBlank).
		// For lower latency you should query more frequently.
		
		// Query and play until there are no more new messages
		while(dsmi_read(&message, &data1, &data2)) {
			printf("0x%x 0x%x 0x%x\n", message, data1, data2);
			midiToArm7(message, data1, data2);
		}
		
		swiWaitForVBlank();
	}
	
	return 0;
}
Example #25
0
// KAOSS Functions
//-------------------------------------------------------------------------
void Display::kaoss(){
	u16 i;

	clearGfx();

	dmaCopy(kaossBgSubTiles,	bgGetGfxPtr(subbg2), kaossBgSubTilesLen);
	dmaCopy(kaossBgSubMap,		bgGetMapPtr(subbg2), kaossBgSubMapLen);

	for (i = 0; i < 64; ++i)
		setKaossSpriteFrame(i, 0);
	
	bgHide(mainbg3);

	echo(1, LIGHT_GREY, 1, 2, "BANK:");
	save->writeCcs();
}
Example #26
0
void Display::editMixerParams(){
	CCParam ccParam;

	bgSetPriority(this->subbg3, 1);
	DC_FlushAll();
	dmaCopy(greyedBgSubTiles,	bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen);
	dmaCopy(greyedBgSubMap,		bgGetMapPtr(this->subbg3), greyedBgSubMapLen);
	bgShow(this->subbg3);

	echo(0, RED, 0, 13, "MIXER");
	echo(0, RED, 12, 13, "MUTES");
	while(!(Cfg::editParams && input->pad->start() == DOWN)){
		for (u8 i = 0; i<8; ++i){
			ccParam = Cfg::mixer.ccs[i];
			
			echo(0, WHITE, 2, 1 + 4*(i%8), "CC");
			paramsEditSprite->display(16+i, 8 + 32*(i%8), 24, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 4, 4*(i%8), ccParam.cc);
			paramsEditSprite->display(32+i, 8 + 32*(i%8), 40, OBJPRIORITY_0, 1);
			
			echo(0, WHITE, 6, 1 + 4*(i%8), "CH");
			paramsEditSprite->display(48+i, 8 + 32*(i%8), 56, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 8, 4*(i%8), 1 + ccParam.channel);
			paramsEditSprite->display(64+i, 8 + 32*(i%8), 72, OBJPRIORITY_0, 1);
			
			ccParam = Cfg::mixer.mutes[i];

			echo(0, WHITE, 14, 1 + 4*(i%8), "CC");
			paramsEditSprite->display(24+i, 8 + 32*(i%8), 120, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 16, 4*(i%8), ccParam.cc);
			paramsEditSprite->display(40+i, 8 + 32*(i%8), 136, OBJPRIORITY_0, 1);
			
			echo(0, WHITE, 18, 1 + 4*(i%8), "CH");
			paramsEditSprite->display(56+i, 8 + 32*(i%8), 152, OBJPRIORITY_0, 0);
			iprintf("\x1b[%d;%dH%3d", 20, 4*(i%8), 1 + ccParam.channel);
			paramsEditSprite->display(72+i, 8 + 32*(i%8), 168, OBJPRIORITY_0, 1);
		}
		oamUpdate(&oamSub);
		input->editMixerParams();
		Cfg::editParams = true;
		swiWaitForVBlank();
	}
	save->write();
	Cfg::editParams = false;
	oamClear(&oamSub, 16, 80);	
	consoleClear();
}
Example #27
0
//---------------------------------------------------------------------------------
PrintConsole* consoleInit(PrintConsole* console, int layer,
				BgType type, BgSize size,
				int mapBase, int tileBase,
				bool mainDisplay, bool loadGraphics){
//---------------------------------------------------------------------------------

	static bool firstConsoleInit = true;

	if(firstConsoleInit) {
		devoptab_list[STD_OUT] = &dotab_stdout;
		devoptab_list[STD_ERR] = &dotab_stdout;

		setvbuf(stdout, NULL , _IONBF, 0);
		setvbuf(stderr, NULL , _IONBF, 0);
				
		firstConsoleInit = false;
	}
	
	if(console) {
		currentConsole = console;
	} else {
		console = currentConsole;	
	}

	*currentConsole = defaultConsole;

	if(mainDisplay) {
		console->bgId = bgInit(layer, type, size, mapBase, tileBase);
	} else {
		console->bgId = bgInitSub(layer, type, size, mapBase, tileBase);
	}	
	
	console->fontBgGfx = (u16*)bgGetGfxPtr(console->bgId);
	console->fontBgMap = (u16*)bgGetMapPtr(console->bgId);

	console->consoleInitialised = 1;
	
	consoleCls('2');

	if(loadGraphics) 
		consoleLoadFont(console);

	return currentConsole;

}
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 #29
0
BG_INF* initBg(s16* tiles, int tileSz, s16* pal, int width, int height, int layer, u16* map)
{
	BG_INF* tmp;
	if((tmp = malloc(sizeof(BG_INF)))) {
		tmp->bgId = bgInit(layer, BgType_Text8bpp, BgSize_T_512x256, 0,1);
		dmaCopy(tiles, bgGetGfxPtr(tmp->bgId), tileSz);
		dmaCopy(pal, BG_PALETTE, 256*2);
		tmp->vram_map 	= bgGetMapPtr(tmp->bgId);
		tmp->map 		= map;
		tmp->mapwidth	= width;
		tmp->mapHeight  = height;
		tmp->x			= 0;
		tmp->y			= 0;
		fillScreen(tmp, 0, 0);
		return tmp;
	}
	return NULL;
}
Example #30
0
static inline void postProcess2(void)
{
	u16* p1=mainScreen;
	u16* p2=portal1.viewPoint;
	u16* p3=portal2.viewPoint;

	u16** stp;
	blueSeen=orangeSeen=false;
	int oval=0;
	for(stp=ppStack;stp<stackEnd;stp++)
	{
		int val=(int)((*stp)-p1);
		if(val>256*192*2){blueSeen=true;val-=256*192*2;if(p1[oval-1]==65504)oval--;if(p1[val]==65504)val++;if(val-oval>0)dmaCopy(&(p3[oval]), &(bgGetGfxPtr(mainBG)[oval]), (val-oval)*2);}
		else if(val>256*192){orangeSeen=true;val-=256*192;if(p1[oval-1]==33791)oval--;if(p1[val]==33791)val++;if(val-oval>0)dmaCopy(&(p2[oval]), &(bgGetGfxPtr(mainBG)[oval]), (val-oval)*2);}
		else {if(val-oval>0)dmaCopy(&(p1[oval]), &(bgGetGfxPtr(mainBG)[oval]), (val-oval)*2);}
		oval=val;
	}
}