コード例 #1
0
ファイル: textFunctions.c プロジェクト: GEMISIS/RPSLS-DS
/*
 * Sets the font on the desired screen with the chosen properties.
 * @param screen The screen to set the font for.
 * @param offSet The offset of the first character.
 * @param numberOfCharacters The total number of characters available for display.
 * @param fontTiles The tiles for the font.
 * @param fontPal The palette for the font.
 */
void setFont(int screen, int offSet, int numberOfCharacters,
		const unsigned int* fontTiles, const unsigned short* fontPal)
{
	/*
	 * Creates a temporary font.
	 */
	ConsoleFont font;

	/*
	 * Sets the font's graphics.
	 */
	font.gfx = (u16*) fontTiles;
	/*
	 * Sets the font's palette.
	 */
	font.pal = (u16*) fontPal;
	/*
	 * Sets the number of characters in the font.
	 */
	font.numChars = numberOfCharacters;
	/*
	 * Sets the number of colors in the font.
	 */
	font.numColors = 32 / 2;
	/*
	 * Sets the bits per pixel for the font's graphics.
	 */
	font.bpp = 4;
	/*
	 * Sets the offset of the first ASCII character.
	 */
	font.asciiOffset = offSet;
	/*
	 * Tells it to use multiple colors.
	 */
	font.convertSingleColor = false;

	/*
	 * Checks if the screen is <= 0.
	 */
	if (screen <= 0)
	{
		/*
		 * If it is, then set the font for the bottom screen.
		 */
		consoleSetFont(&bottomScreen, &font);
	}
	else
	{
		/*
		 * Otherwise, the font for the top screen is set.
		 */
		consoleSetFont(&topScreen, &font);
	}
}
コード例 #2
0
ファイル: display.cpp プロジェクト: Jell/tower_game
	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");
	}
コード例 #3
0
ファイル: DSGM_text.c プロジェクト: CTurt/dsgmLib
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();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: richelbilderbeek/CppTests
int main()
{
  powerOn(POWER_ALL_2D);

  const int tile_base = 0;
  const int map_base = 20;


  videoSetModeSub(MODE_0_2D);
  videoSetMode(MODE_0_2D);
  vramSetBankC(VRAM_C_SUB_BG);

  PrintConsole * bottom_screen
    = consoleInit(
      nullptr,
      0,
      BgType_Text4bpp,
      BgSize_T_256x256,
      map_base,
      tile_base,
      false,
      false
  );

  ConsoleFont font;

  font.gfx = const_cast<u16*>(reinterpret_cast<const u16*>(fontTiles));
  font.pal = const_cast<u16*>(fontPal);
  font.numChars = 95;
  font.numColors =  fontPalLen / 2;
  font.bpp = 4;
  font.asciiOffset = 32;
  font.convertSingleColor = false;

  consoleSetFont(bottom_screen, &font);

  std::cout
    << "Use of a custom font\n"
    << "Adapted from libnds\n"
    << "custom_font demo"
  ;

  while(1) {
    swiWaitForVBlank();
  }
}
コード例 #5
0
ファイル: render.cpp プロジェクト: jsykes/starkas
void Render::InitFont()
{
	const int tile_base = 0;
	const int map_base = 7;

    consoleInit(&bottomScreen,1, BgType_Text4bpp, BgSize_R_128x128 , tile_base, map_base, false, false);

	ConsoleFont font;

	font.gfx = (u16*)fontTiles;
	font.pal = (u16*)fontPal;
	font.numChars = 95;
	font.numColors =  fontPalLen / 2;
	font.bpp = 4;
	font.asciiOffset = 32;
	font.convertSingleColor = false;
	
	consoleSetFont(&bottomScreen, &font);
}
コード例 #6
0
ファイル: display.cpp プロジェクト: SBRK/MIDI-Control-DS
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");
}
コード例 #7
0
ファイル: main.c プロジェクト: 0265727207/evandrix.github.com
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

	const int tile_base = 0;
	const int map_base = 20;


	videoSetMode(0);	

	videoSetModeSub(MODE_5_2D);	
	vramSetBankC(VRAM_C_SUB_BG); 

	PrintConsole *console = consoleInit(0, 3, BgType_ExRotation, BgSize_ER_256x256, map_base, tile_base, false, false);

	ConsoleFont 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(console, &font);

	int bg3 = console->bgId;

	iprintf("Custom Font Demo\n");
	iprintf("   by Poffy\n");
	iprintf("modified by WinterMute and dovoto\n");
	iprintf("for libnds examples\n");

	
	unsigned int angle = 0;
    int scrollX = 0;
	int scrollY = 0;
	int scaleX = intToFixed(1,8);
	int scaleY = intToFixed(1,8);

	while(1) {
		scanKeys();
		u32 keys = keysHeld();

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

		if ( keys & KEY_LEFT ) scrollX++;
		if ( keys & KEY_RIGHT ) scrollX--;
		if ( keys & KEY_UP ) scrollY++;
		if ( keys & KEY_DOWN ) scrollY--;

		if ( keys & KEY_A ) scaleX++;
		if ( keys & KEY_B ) scaleX--;

		if( keys & KEY_X ) scaleY++;
		if( keys & KEY_Y ) scaleY--;

		swiWaitForVBlank();


		bgSetRotateScale(bg3, angle, scaleX, scaleY);
		bgSetScroll(bg3, scrollX, scrollY);
		bgUpdate();
	}

}