static int NDS_RenderClear(SDL_Renderer *renderer)
{
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;

	/* wait for capture unit to be ready */
	while(REG_DISPCAPCNT & DCAP_ENABLE);

	/* 3D engine can only work on one screen at a time. */
	data->is_sub = !data->is_sub;
	if (data->is_sub) {
		lcdMainOnBottom();
		vramSetBankC(VRAM_C_LCD);
		vramSetBankD(VRAM_D_SUB_SPRITE);
		REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3);
	} else {
		lcdMainOnTop();
		vramSetBankD(VRAM_D_LCD);
		vramSetBankC(VRAM_C_SUB_BG);
		REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3);
	}

	glBegin2D();

    glClearColor(renderer->r >> 3,
                 renderer->g >> 3,
                 renderer->b >> 3,
                 renderer->a >> 3);

	return 0;
}
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;
}
示例#3
0
文件: bspstart.c 项目: rtemss/rtems
void bsp_start (void)
{
  /* initialize irq management */
  BSP_rtems_irq_mngt_init ();

  /* setup console mode for lower screen */
  irqEnable (IRQ_VBLANK);
  videoSetMode (0);
  videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE);
  vramSetBankC (VRAM_C_SUB_BG);

  SUB_BG0_CR = BG_MAP_BASE (31);
  BG_PALETTE_SUB[255] = RGB15 (31, 31, 31);
  consoleInitDefault ((u16 *) SCREEN_BASE_BLOCK_SUB (31),
                      (u16 *) CHAR_BASE_BLOCK_SUB (0), 16);

  /* print status message */
  printk ("[+] kernel console started\n");

  /* set the cpu mode to system user */
  arm_cpu_mode = 0x1f;

  /* configure clock period */
  Configuration.microseconds_per_tick = 10000;  /* us */

  defaultExceptionHandler ();
}
示例#4
0
//---------------------------------------------------------------------------------
// Places the console in a default mode using bg0 of the sub display, and vram c for 
// font and map..this is provided for rapid prototyping and nothing more
PrintConsole* consoleDemoInit(void) {
//---------------------------------------------------------------------------------
	videoSetModeSub(MODE_0_2D);
	vramSetBankC(VRAM_C_SUB_BG); 

	return consoleInit(NULL, defaultConsole.bgLayer, BgType_Text4bpp, BgSize_T_256x256, defaultConsole.mapBase, defaultConsole.gfxBase, false, true);
}
示例#5
0
文件: main.cpp 项目: nevilc/YomiDS
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;
}
示例#6
0
文件: main.c 项目: 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;
}
示例#7
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();
        }
    }
示例#8
0
文件: dual3D.c 项目: Almamu/portalDS
void updateD3D()
{
	if (d3dScreen) {
		videoSetModeSub(MODE_5_2D | DISPLAY_BG2_ACTIVE);
		vramSetBankC(VRAM_C_SUB_BG);
		vramSetBankD(VRAM_D_LCD);
		setRegCapture(true, 0, 15, 3, 0, 3, 0, 0);
		d3dScreen=false;
	}else{
		videoSetModeSub(MODE_5_2D | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_2D_BMP_256);
		vramSetBankC(VRAM_C_LCD);
		vramSetBankD(VRAM_D_SUB_SPRITE);
		setRegCapture(true, 0, 15, 2, 0, 3, 0, 0);
		d3dScreen=true;
	}
    lcdSwap();
}
示例#9
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);
	}
示例#10
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);
}
//---------------------------------------------------------------------------------
// Places the console in a default mode using bg0 of the sub display, and vram c for
// font and map..this is provided for rapid prototyping and nothing more
void consoleDemoInit(void) {
//---------------------------------------------------------------------------------
	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
	vramSetBankC(VRAM_C_SUB_BG);

	SUB_BG0_CR = BG_MAP_BASE(31);

	BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255

	//consoleInit() is a lot more flexible but this gets you up and running quick
	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
}
示例#12
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();
}
示例#13
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);
}
示例#14
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;
	}
示例#15
0
文件: arm9_main.c 项目: 0xtob/dsmi
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;
}
示例#16
0
文件: main.c 项目: bttf/petsounds
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);
}
示例#17
0
bool videoStart(const char* file)
{
	vramSetBankB(VRAM_B_LCD);
	vramSetBankC(VRAM_C_LCD);
//	videoSetMode(MODE_FB1);

	if(videoPlaying) return false;
	
	videoFile = fopen(file, "rb");
	if (videoFile == NULL) return false;

	timerStart(3, ClockDivider_256, TIMER_FREQ_256(20), videoTick);
	videoFrames = 0;
	videoPlaying = true;
	vramBank = false;
	return true;
}
示例#18
0
文件: fb.c 项目: epicsdeb/rtems
rtems_device_driver
frame_buffer_close (rtems_device_major_number major,
            rtems_device_minor_number minor, void *arg)
{
  printk ("[#] leaving graphic mode on fb%d\n", minor);
  if (!minor) {
      memset ((void *)fb_fix_info.smem_start, 0, fb_fix_info.smem_len);
  }
  else {
      memset ((void *)fb_fix_info2.smem_start, 0, fb_fix_info2.smem_len);
      /* back to console */
      videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE);
      vramSetBankC (VRAM_C_SUB_BG);
  }

  return RTEMS_SUCCESSFUL;
}
示例#19
0
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();
  }
}
示例#20
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;
	}

}
示例#21
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;
}
示例#22
0
int main()
{
    irqInit();
    irqEnable(IRQ_VBLANK);
    videoSetMode(0);
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    vramSetBankC(VRAM_C_SUB_BG);
    SUB_BG0_CR = BG_MAP_BASE(31);
    BG_PALETTE_SUB[255] = RGB15(31, 31, 31);
    consoleInitDefault((u16 *) SCREEN_BASE_BLOCK_SUB(31), (u16 *)
            CHAR_BASE_BLOCK_SUB(0), 16);

    printf("Starting FAT\n");
    fatInitDefault();
    printf("Starting WiFi\n");
    wifiInit();
    while(1) Menu::Main();

    return 0;
}
示例#23
0
// Adapted in part from the devkitPro examples.
INT32 I_StartupSystem(void)
{
	lcdMainOnTop();

	videoSetModeSub(MODE_0_2D);
	vramSetBankC(VRAM_C_MAIN_BG);	// Get this mapped *out* of the sub BG
	vramSetBankI(VRAM_I_SUB_BG_0x06208000);

	// The background VRAM that's mapped starts at 0x06208000.
	// The map base is specified in an offset of multiples of 2 KB
	// from 0x06200000, and the tile base in multiples of 16 KB.
	// We put the tiles at the start and the map 2 KB from the end
	// (i.e. 14 KB from the start).
	// The map base is then at 0x0620B800 = 0x06200000 + 16 * 0x800 + 7 * 0x800,
	// and the tile base is at 0x06208000 = 0x06200000 + 2 * 0x4000.
	consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 16+7, 2, false, true);

	// start FAT filesystem code, required for reading SD card
	if(!fatInitDefault())
		I_Error("Couldn't init FAT.");

	return 0;
}
示例#24
0
文件: main.c 项目: 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;
}
示例#25
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;
}
示例#26
0
int main(void)  {

	struct in_addr ip, gateway, mask, dns1, dns2;
	
	// set the mode for 2 text layers and two extended background layers
	videoSetMode(MODE_5_2D);
    vramSetBankA(VRAM_A_MAIN_BG_0x06000000);

	consoleDemoInit();
   
	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(&bottomScreen);
   
   Keyboard *kbd = keyboardDemoInit();
   
   kbd->OnKeyPressed = OnKeyPressed;
   
   consoleSelect(&topScreen);
   
   iprintf("Connecting to WiFi...");
	
	if(!Wifi_InitDefault(WFC_CONNECT)){
		iprintf("Failed to connect!");
		exit(1);
	}
		
		iprintf("Connected\n\n");
		
		uint16 keysPressed = ~(REG_KEYINPUT);
			if(keysPressed & KEY_A){
				debug = true;
			}
		
		ip = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2);

		while(Connected == false && debug == false) {
			char wiiIP[256];

			iprintf("Your ip: %s\n",inet_ntoa(ip));
			iprintf("Type in your Wii's IP(or /cmd for the console):\n");
			scanf("%s", wiiIP);

			if(!strcmp(wiiIP, "/cmd")){
				CMD();
				continue;
			}	

			iprintf("\nConnecting To %s\nfrom %s...", wiiIP,inet_ntoa(ip));
			
			int server = 0; server = TCP_ClientConnect(wiiIP, 8593);//TCP_ClientConnect(ip address, port)

			if(server == true){
				Connected = true;
				iprintf("Connected\n");
			}

			while(Connected == true){
				
			}
			
			iprintf("Press start to exit or click any other button to try again:\n");

			scanKeys();
			while(!keysDown()){
				scanKeys();
				if(keysPressed & KEY_START)
					exit(0);
			}

			swiWaitForVBlank();
			consoleClear();
	}
	
	int host = 0;
	int client = 0;
	if(debug == true){
		
		consoleClear();
		iprintf("Welcome To Server Screen\n");
		iprintf("Your ip: %s\n",inet_ntoa(ip));
		host = TCP_Server(PORT, PLAYERS);//TCP_Server(port, number of players)
	}
	
	while(debug == true){
		
		client = PLAYERS; client = TCP_GetClient(host);//TCP_GetClient(host socket)
		if(!clientForServer == 4){
			clientForServer++;
			iprintf("Client connected(%d of %d)\n", clientForServer,PLAYERS);
			iprintf("Client id: %d\n", client);
		}
		
	}

   return 0;
}
示例#27
0
文件: main.cpp 项目: jkroll20/libflux
int main(void)
{
    touchPosition touch;

    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
    vramSetBankC(VRAM_C_SUB_BG);

    SUB_BG0_CR = BG_MAP_BASE(31);

    BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255

    //consoleInit() is a lot more fluxible but this gets you up and running quick
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
    
/////////////
    powerON(POWER_ALL);

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

    // irqs are nice
    irqInit();
    irqEnable(IRQ_VBLANK);
    
    // initialize gl
    glInit();
    
    // setup the rear plane
    glClearColor(2, 4, 3, 16);
    glClearDepth(GL_MAX_DEPTH);
    
    // this should work the same as the normal gl call
    glViewPort(0,0, 255,191);
    
    glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
    
    glMatrixMode(GL_PROJECTION);
    
    glLoadIdentity();
    //~ glOrtho(0, 1, 192.0/256.0, 0, -10, 10);
    glOrthof32(0, 1<<12, (192<<12)/256, 0, -10<<12, 10<<12);
    
    REG_POWERCNT^= POWER_SWAP_LCDS;
/////////////


    flux_init();
    create_frame_groups();
    create_button_groups();
    create_titleframe();
    
    dmaCopy(fluxcolors, syscol_table, sizeof(fluxcolors));
    
    dword rc1= create_rect(NOPARENT, 20,20, 128,96, 0x808080);
    dword rc= create_rect(NOPARENT, 10,10, 128,96, 0x404040|TRANSL_3);
    dword frm= clone_frame("titleframe", rc);
    clone_frame("titleframe", rc1);
    //~ clone_group("button", rc, 10,30, 30,14, ALIGN_LEFT|ALIGN_TOP);

    create_rect(rc, 10,10, 10,10, 0xFFFFFF|TRANSL_1);
    create_rect(rc, 20,10, 10,10, 0xFFFFFF|TRANSL_2);
    create_rect(rc, 30,10, 10,10, 0xFFFFFF|TRANSL_3);
    create_rect(rc, 10,15, 30,10, 0xFFFFFF|TRANSL_1);
    
    create_text(rc, 10,30, 40,40, "Text! Space!\nNewline!", 0xFFFFFF, FONT_DEFAULT);
    
    bool redraw_all= true;
    bool touch_wasdown= false;
    int lasttouch_x, lasttouch_y;
    while(1)
    {
	scanKeys();
    	u32 keysheld= keysHeld();
	u32 keysdown= keysDown();
	touch= touchReadXY();
	
	if(keysdown&KEY_A)
	{
	    redraw_all^= 1;
	    iprintf("redraw each frame: %s\n", redraw_all? "on": "off");
	}
	
	if(keysdown&KEY_B)
	{
	    do_texalpha^= 1;
	    iprintf("texture alpha: %s\n", do_texalpha? "on": "off");
	}
	
	if(touch.x || touch.y)
	{
	    flux_mouse_event(touch.px, touch.py, 1);
	    lasttouch_x= touch.px, lasttouch_y= touch.py;
	    touch_wasdown= true;
	}
	else
	{
	    if(touch_wasdown) flux_mouse_event(lasttouch_x, lasttouch_y, 0);
	    touch_wasdown= false;
	}
	    

	flux_tick();
	if(redraw_all)
	{
	    redraw_rect(&viewport);
	    update_rect(&viewport);
	}
	
	swiWaitForVBlank();
    }

    return 0;
}
示例#28
0
文件: main.cpp 项目: bkuker/DiceDS
int main()
{	
	struct timeval tv;
	
	powerON(POWER_ALL);

	//set mode 0, enable BG0 and set it to 3D
	videoSetMode(MODE_0_3D);
	
	//Use console
	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
	vramSetBankC(VRAM_C_SUB_BG); 
	SUB_BG0_CR = BG_MAP_BASE(31);
	BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255
	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
	
	//iprintf("Starting up...\n");
	
	// install the default exception handler
	defaultExceptionHandler();


	//irqs are nice
	irqInit();
	irqEnable(IRQ_VBLANK);
	
	// set the generic sound parameters
	setGenericSound(	11025,	/* sample rate */
						127,	/* volume */
						64,		/* panning */
						1 );	/* sound format*/
						

	glInit();
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
		
	//this should work the same as the normal gl call
	glViewPort(0,0,255,191);
	
	glClearColor(0,0,0,0);
	glClearDepth(0x7FFF);
	
	vramSetBankA(VRAM_A_TEXTURE);
	vramSetBankB(VRAM_B_TEXTURE);
	
	logo();

	glGenTextures(1, &textureID);
	glBindTexture(0, textureID);
	glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD , (u8*)die_bmp_bin);
	
	
	glGenTextures(1, &textureID2);
	glBindTexture(0, textureID2);
	glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)mario_bmp_bin);
	
	gettimeofday(&tv, NULL);
	//iprintf("Seeding with %d\n", tv.tv_usec);
    srand(tv.tv_usec);

	while(1){
		gameLoop();
	}

	return 0;
}//end main 
示例#29
0
bool Console::AllocateConsole()
{
    CoreAssert(this != NULL);
#ifdef TARGET_OS_WINDOWS
    m_consoleAllocated = (AllocConsole() == TRUE);
#elif defined (TARGET_OS_MACOSX) && 0
    /* BSD-style pty code. */
    char buf[64];
    const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const char *ptyminors = "0123456789abcdef";
    int num_minors = strlen(ptyminors);
    int num_ptys = strlen(ptymajors) * num_minors;

    for (int i = 0; i < num_ptys; i++) {
        sprintf(buf, "/dev/pty%c%c", ptymajors[i / num_minors], ptyminors[i % num_minors]);
        m_ptyfd = open(buf, O_RDWR | O_NOCTTY);
        if (m_ptyfd < 0)
            continue;

        sprintf(m_slaveName, "/dev/tty%c%c", ptymajors[i / num_minors], ptyminors[i % num_minors]);

        /* Open the slave side. */
        m_ttyfd = open(m_slaveName, O_RDWR | O_NOCTTY);
        if (m_ttyfd < 0) {
            close(m_ptyfd);
            break;
        }

        m_consoleAllocated = true;
        break;
    }

    if (m_consoleAllocated) {
        m_childPID = fork();
        if (m_childPID == -1) {
            m_consoleAllocated = false;
            close(m_ttyfd);
            close(m_ptyfd);
            return m_consoleAllocated;
        }

        if (m_childPID == 0) {
            /* child */
            close(m_ttyfd);
            char call[128];
            char *pt = &m_slaveName[strlen(m_slaveName) - 1];
            const char *xterm = "/usr/X11/bin/xterm";
            sprintf(call, "-S%s/%d", pt, m_ptyfd);
            execl(xterm, xterm, "-bg", "black", "-fg", "white", "-geometry", "132x50", call, NULL);
            exit(0);
        } else {
            /* master */
            close(m_ptyfd);
        }
    }

#elif defined (TARGET_OS_NDSFIRMWARE)
    irqInit();
    irqEnable(IRQ_VBLANK);
    videoSetMode(MODE_0_2D);
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    vramSetBankC(VRAM_C_SUB_BG);
    SUB_BG0_CR = BG_MAP_BASE(31);
    BG_PALETTE_SUB[255] = RGB15(31, 31, 31);
    consoleInitDefault((u16 *)SCREEN_BASE_BLOCK_SUB(31), (u16 *)CHAR_BASE_BLOCK_SUB(0), 16);
    m_consoleAllocated = true;
#endif
    return m_consoleAllocated;
}
示例#30
0
//---------------------------------------------------------------------------------
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();
	}

}