Пример #1
0
/*
	DS_ScrollBackground:

	Positions the screen as to center it over the emulated cursor.
*/
LOCALPROC DS_ScrollBackground(void)
{
	int ScrollX = 0;
	int ScrollY = 0;
	int Scale = 0;

	/*
		TODO:
		Lots of magic numbers here.
	*/
#if EnableMagnify
	if (WantMagnify) {
		ScrollX = ((int) CurMouseH) - (DS_ScreenWidth / 4);
		ScrollY = ((int) CurMouseV) - (DS_ScreenHeight / 4);
		Scale = 128;

		ScrollX = ScrollX > vMacScreenWidth - (DS_ScreenWidth / 2)
			? vMacScreenWidth - (DS_ScreenWidth / 2)
			: ScrollX;
		ScrollY = ScrollY > vMacScreenHeight - (DS_ScreenHeight / 2)
			? vMacScreenHeight - (DS_ScreenHeight / 2)
			: ScrollY;
	} else
#endif
	{
		ScrollX = ((int) CurMouseH) - (DS_ScreenWidth / 2);
		ScrollY = ((int) CurMouseV) - (DS_ScreenHeight / 2);
		Scale = 256;

		ScrollX = ScrollX > vMacScreenWidth - DS_ScreenWidth
			? vMacScreenWidth - DS_ScreenWidth
			: ScrollX;
		ScrollY = ScrollY > vMacScreenHeight - DS_ScreenHeight
			? vMacScreenHeight - DS_ScreenHeight
			: ScrollY;
	}

	ScrollX = ScrollX < 0 ? 0 : ScrollX;
	ScrollY = ScrollY < 0 ? 0 : ScrollY;

	if (Display_bg2_Main) {
		bgSetScale(Display_bg2_Main, Scale, Scale);
		bgSetScroll(Display_bg2_Main, ScrollX, ScrollY);
	}
}
Пример #2
0
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);
		
	}
}