示例#1
0
int main(void)  {

   consoleDemoInit();

   Keyboard *kbd = 	keyboardDemoInit();

   kbd->OnKeyPressed = OnKeyPressed;

   while(1) {
      char myName[256];

      iprintf("What is your name?\n");

      scanf("%s", myName);

      iprintf("\nHello %s", myName);

      scanKeys();
      while(!keysDown())scanKeys();

      swiWaitForVBlank();
      consoleClear();
   }

   return 0;
}
示例#2
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;	
}
示例#3
0
文件: main.c 项目: junjiemars/fun-os
int main(void)
{
  consoleDemoInit();

  iprintf("Phase#01 Sandbox\n");

  // run scheme
  // allocate 3.5MB memory for scheme
  // 1.5MB used for a stack
  // 2.0MB used for a heap
  int memory_size = 3670016;
  void* scheme_memory = malloc(memory_size);
  if (scheme_memory == NULL)
  {
    iprintf("ERROR: Couldn't allocate memory for scheme");

    while(1) {
      swiWaitForVBlank();
    }
  }

  int taggedResult = scheme_entry(scheme_memory, memory_size);
  int result = taggedResult >> 3;

  iprintf("scheme_entry returned: %i", result);

  while(1) {
    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;
}
示例#5
0
void list_directory() {

  consoleDemoInit();
  if (fatInitDefault()) {

    DIR *pdir;
    struct dirent *pent;

    pdir=opendir("/");

    if (pdir){
      while ((pent=readdir(pdir))!=NULL) {
	if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0)
	  continue;
	if(pent->d_type == DT_DIR)
	  iprintf("[%s]\n", pent->d_name);
	else
	  iprintf("%s\n", pent->d_name);
      }
      closedir(pdir);
    } else {
      iprintf ("opendir() failure; terminating\n");
    }

  } else {
    iprintf("fatInitDefault failure: terminating\n");
  }

  while(1) {
    swiWaitForVBlank();
  }

}
示例#6
0
文件: Field.cpp 项目: remar/castle
void
Field::addBlock(int blockX, int blockY, Color color, bool on)
{
  switch(color)
    {
    case YELLOW:
      yellowBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    case GREEN:
      greenBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    case BLUE:
      blueBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    default:
      consoleDemoInit();
      printf("ERROR: Default case reached in Field::addBlock()\n");
      while(1);
      break;
    }

  if(on)
    setBlock(blockX, blockY, BLOCK);
}
示例#7
0
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	touchPosition touchXY;

	irqSet(IRQ_VBLANK, Vblank);

	consoleDemoInit();

	iprintf("      Hello DS dev'rs\n");
	iprintf("     \x1b[32mwww.devkitpro.org\n");
	iprintf("   \x1b[32;1mwww.drunkencoders.com\x1b[39m");
 
	while(1) {
	
		swiWaitForVBlank();
		touchRead(&touchXY);

		// print at using ansi escape sequence \x1b[line;columnH 
		iprintf("\x1b[10;0HFrame = %d",frame);
		iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px);
		iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py);		
	
	}

	return 0;
}
示例#8
0
int main(void) {
//---------------------------------------------------------------------------------
	
        tblu = bluCreate();
	initRes();
	bsp = *((bluSprite*)tblu->System_ResourceFactory());
	tblu->Input_Init();
	tblu->GFX_Initiate();	
	tblu->GFX_LDSprite(&bsp);
	tblu->GFX_InitAnimationFrames(&tban, 2);
	tblu->GFX_AddAnimationFrame(&tban, 0, sgunTiles, sgunPal, sgunTilesLen, sgunPalLen);
	tblu->GFX_AddAnimationFrame(&tban, 1, sgunTiles+512, sgunPal, sgunTilesLen, sgunPalLen);
	tblu->System_SetFunc(FrameProc, BLUFRAMFUNC);
	consoleDemoInit();  //setup the sub screen for printing
	tblu->System_Start();

	tblu->GFX_Init3DDevice();
	while(1){
	DrawGLScene();
	glFlush(0);	

	}

/*	tblu->Release();
	while(1) {

		touchRead(&touch);
		iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py);

		swiWaitForVBlank();
	}

*/	return 0;
}
示例#9
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;
}
示例#10
0
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	consoleDemoInit();  //setup the sub screen for printing

	keyboardDemoInit();

	keyboardShow();

	while(1) {
		
		int key = keyboardUpdate();

		if(key > 0)
			iprintf("%c", key);

		swiWaitForVBlank();
		scanKeys();

		int pressed = keysDown();

		if(pressed & KEY_START) break;
	}

	return 0;
}
示例#11
0
文件: main.c 项目: wjross/ndsproject
int main(void) {
	
    consoleDemoInit();
    printf("\nTemplate ndsssss\n");

    while(1)
        swiWaitForVBlank();	
}
示例#12
0
文件: main.cpp 项目: remar/rage
void displayError()
{
  consoleDemoInit();

  printf("%s\n", rage.getErrorString());

  while(1){}
}
示例#13
0
void __sassert(const char *fileName, int lineNumber, const char* conditionString, const char* message)
{
    consoleDemoInit();
    iprintf("\x1b[j\x1b[42mAssertion!\n\x1b[39mFile: \n%s\n\nLine: %d\n\nCondition:\n%s\n\n\x1b[41m%s",fileName, lineNumber, conditionString, message);

    //todo: exit properly
	while(1);  
}
示例#14
0
void GrafikoakHasieratu()
{
	powerOn(POWER_ALL_2D);
    lcdMainOnBottom();
    hasieratuBideoa();
    //hasieratuFondoak();
	consoleDemoInit(); //Goiko pantaila testua erakusteko eta beheko irudiak erakusteko erabiliko da.
}
示例#15
0
int main( int argc, char **argv) {
	consoleDemoInit();
	if (fatInitDefault()) {
		runNdsFile("/BOOT.NDS", 0, NULL);
	} else {
		printf("FAT init failed!\n");
	}
	while(1) swiWaitForVBlank();
}
示例#16
0
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	consoleDemoInit();
	iprintf("Hello World!");
	while(1) {
		swiWaitForVBlank();
	}

}
示例#17
0
文件: main.cpp 项目: remar/rage
void displayError(int line)
{
  consoleDemoInit();

  printf("ERROR %d\n--------------------------------\n"
	 "Line %d: %s\n", rage.getErrorCode(), line, rage.getErrorString());

  while(1){}
}
示例#18
0
int main()
{
	consoleDemoInit();

	uint ticks = 0;
	TimerStates state = timerState_Stop;
	int down = keysDown();

	while(!(down & KEY_START))
	{
		swiWaitForVBlank();
		consoleClear();
		scanKeys();
		down = keysDown();

		if(state == timerState_Running)
		{
			ticks += timerElapsed(0);
		}

		if(down & KEY_A)
		{
			if(state == timerState_Stop)
			{
				timerStart(0, ClockDivider_1024, 0, NULL);
				state = timerState_Running;
			}
			else if(state == timerState_Pause)
			{
				timerUnpause(0);
				state = timerState_Running;
			}
			else if(state == timerState_Running)
			{
				ticks += timerPause(0);
				state = timerState_Pause;
			}
		}
		else if(down & KEY_B)
		{
			timerStop(0);
			ticks = 0;
			state = timerState_Stop;
		}

		iprintf("Press A to start and pause the \ntimer, B to clear the timer \nand start to quit the program.\n\n");
		iprintf("ticks:  %u\n", ticks);
		iprintf("second: %u:%u\n", ticks/TIMER_SPEED, ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED);
	}

	if(state != timerState_Stop)
	{
		timerStop(0);
	}

	return 0;
}
示例#19
0
void video_init()
{
    powerSET(POWER_LCD | POWER_2D_B);
    lcdMainOnBottom();
    videoSetMode(0);
    consoleDemoInit();

    iprintf("Wifi EEPROM Dumper\nMicah Dowty <*****@*****.**>\n\n");
}
示例#20
0
// Contructor clase CDebug
CDebug::CDebug() {
	consoleDemoInit();

	/*
	_text = new CText("fnt/default",256,256);
	_text->CreateLayer(true);

	_position = new Vector2();
	*/
} // CDebug
示例#21
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;
	}
}
示例#22
0
文件: main.c 项目: hogelog/dsgame
void init_state(GameState *state) {
  PA_Init();
  consoleDemoInit();

  iprintf("Nintendo DS Game Demo!\n");

  if (!fatInitDefault()) {
    iprintf("cannot init libfat\n");
    exit(1);
  }

  init_lua(state);
}
示例#23
0
文件: main.cpp 项目: Joesalad21/DoSu
int main(void)
{
	consoleDemoInit();
	while(1)
	{
		if(REG_KEYINPUT & KEY_A)
			printf("Key A is released");
		else
			printf("Key A is pressed");
		swiWaitForVBlank();
		consoleClear();
	}
	return 0;
}
示例#24
0
int main(void)
{
	irqInit();
	irqEnable(IRQ_VBLANK);

	consoleDemoInit();

	iprintf("\x1b[10;10HHello World!\n");

	while (1)
	{
		VBlankIntrWait();
	}
}
示例#25
0
/*
	DS_SysInit

	Initializes DS specific system hardware and interrupts.
*/
LOCALPROC DS_SysInit(void)
{
	defaultExceptionHandler();
	powerOn(POWER_ALL_2D);
	lcdMainOnTop();

	irqSet(IRQ_VBLANK, DS_VBlank_IRQ);
	irqSet(IRQ_HBLANK, DS_HBlank_IRQ);
	irqSet(IRQ_TIMER1, DS_Timer1_IRQ);

	irqEnable(IRQ_VBLANK);
	irqEnable(IRQ_HBLANK);
	irqEnable(IRQ_TIMER1);

	/*
		This sets up 2 timers as a milisecond counter.
		TIMER0_DATA Will overflow roughly every 1 msec into TIMER1_DATA.
		When TIMER1_DATA overflows an interrupt will be generated
		and DS_Timer1_IRQ will be called.
	*/
	TIMER0_DATA = 32768;

	TIMER0_CR = TIMER_DIV_1 | TIMER_ENABLE;



	TIMER1_DATA = 0;

	TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_IRQ_REQ;

	/*
		Testing.
	*/
	consoleDemoInit();
	consoleDebugInit(DebugDevice_NOCASH);

	/*
		Use the default keyboard until I design a (good) UI...
	*/
	DSKeyboard = keyboardDemoInit();
	keyboardShow();

	/*
		Drop back to a read only filesystem embedded in the
		Mini vMac binary if we cannot open a media device.
	*/
	if (! fatInitDefault()) {
		nitroFSInit();
	}
}
示例#26
0
int main(int argc, char* argv[])
{
	consoleDemoInit();
	InstallSoundSys();

	iprintf("\n\n\tSSEQ player PoC v1\n");
	iprintf("\tfincs.drunkencoders.com\n");
	iprintf("\tgithub.com/fincs");

	if (argc < 4)
	{
		if (!nitroFSInit())
		{
			error("Can't initialize NitroFS!");
			anykey();
			return 0;
		}
		if (defaultLoad(&g_sseqData, &g_sbnkData, g_swarData) != 0)
		{
			anykey();
			return 0;
		}
	}else
	{
		if (!fatInitDefault())
		{
			error("Can't initialize FAT!");
			anykey();
			return 0;
		}
		if (argvLoad(argc-1, argv+1, &g_sseqData, &g_sbnkData, g_swarData) != 0)
		{
			anykey();
			return 0;
		}
	}

	PlaySeq(g_sseqData, g_sbnkData, g_swarData);

	for(;;)
	{
		swiWaitForVBlank();

		scanKeys();
		if (keysDown() & KEY_START) break;
		if (keysDown() & KEY_B) StopSeq();
	}

	return 0;
}
示例#27
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;
}
示例#28
0
static void setup()
{
    consoleDemoInit();

    //put 3D on top
    lcdMainOnTop();

    //set mode 0, enable BG0 and set it to 3D
    videoSetMode(MODE_0_3D);

    // initialize gl
    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);

    glColor3b(255,255,0);

    glLight(0, RGB15(0,31,0) , 0,               floattov10(-1.0),      0);

    //need to set up some material properties since DS does not have them set by default
    glMaterialf(GL_AMBIENT, RGB15(5,5,5));
    glMaterialf(GL_DIFFUSE, RGB15(15,15,15));
    glMaterialf(GL_SPECULAR, RGB15(8,8,8));
    glMaterialf(GL_EMISSION, RGB15(5,5,5));

    //ds uses a table for shinyness..this generates a half-assed one
    glMaterialShinyness();

    //ds specific, several attributes can be set here   
    glPolyFmt( POLY_ALPHA(31) | POLY_CULL_NONE | POLY_FORMAT_LIGHT0 );

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, (float)W / H, Znear, Zfar);

    lookAtSelectedModel();
}
示例#29
0
文件: Field.cpp 项目: remar/castle
void
Field::addTarget(int blockX, int blockY, Color color)
{
  if(targets[color].set)
    {
      consoleDemoInit();
      printf("ERROR: Only one target per color allowed!\n");
      while(1);
    }

  targets[color].target = new Target(blockX, blockY, color);

  targets[color].x = blockX;
  targets[color].y = blockY;

  targets[color].set = true;
}
示例#30
0
void gamestate::videoInit() {
    powerOn(POWER_ALL_2D); //Turn on the 2D graphics core.

    lcdMainOnBottom(); // Place the main screen on the bottom physical screen

    /* Configure the VRAM and background control registers. */
    // This stuff is copied from pataters tutorial (because it works... 0o)
    /*
     * Map VRAM to display a background on the main and sub screens.
     *
     * The vramSetMainBanks function takes four arguments, one for each of the
     * major VRAM banks. We can use it as shorthand for assigning values to
     * each of the VRAM bank's control registers.
     *
     * We map  banks A and B to main screen background memory. This gives us
     * 256KB, which is a healty amount for 16-bit graphics.
     *
     * We map bank C to sub screen background memory.
     *
     * We map bank D to LCD. This setting is generally used for when we aren't
     * using a particular bank.
     *
     * We map bank E to main screen sprite memory (aka object memory).
     */
    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_LCD);

    vramSetBankE(VRAM_E_MAIN_SPRITE);

    /* Set the video mode on the main screen. */
    videoSetMode(MODE_5_2D | // Set the graphics mode to Mode 5
                 DISPLAY_BG2_ACTIVE |
                 DISPLAY_BG3_ACTIVE | // Enable BG3 for display
                 DISPLAY_SPR_ACTIVE | // Enable sprites for display
                 DISPLAY_SPR_1D );    // Enable 1D tiled sprites

    /* Set the video mode on the sub screen. */
    videoSetModeSub(MODE_5_2D | // Set the graphics mode to Mode 5
                    DISPLAY_BG3_ACTIVE); // Enable BG3 for display
    // Sets background registers
    consoleDemoInit(); // Need this for debug-output (iprintf)
}