Ejemplo n.º 1
0
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 ();
}
Ejemplo n.º 2
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
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);
}
Ejemplo n.º 3
0
void setKeyHighlight(int key, bool highlight) {
	u16 *base = ((u16 *) SCREEN_BASE_BLOCK_SUB(DS::s_mapBase));

	if (highlight) {
		base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x] |= 0x1000;
		base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x + 1] |= 0x1000;
		base[(keyboardY + keys[key].y + 1) * 32 + keyboardX + keys[key].x] |= 0x1000;
		base[(keyboardY + keys[key].y + 1) * 32 + keyboardX + keys[key].x + 1] |= 0x1000;
	} else {
		base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x] &= ~0x1000;
		base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x + 1] &= ~0x1000;
		base[(keyboardY + keys[key].y + 1) * 32 + keyboardX + keys[key].x] &= ~0x1000;
		base[(keyboardY + keys[key].y + 1) * 32 + keyboardX + keys[key].x + 1] &= ~0x1000;
	}
}
Ejemplo n.º 4
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;
	}

}
Ejemplo n.º 5
0
Archivo: main.cpp Proyecto: kusma/nds
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

    struct stat st;

    // Enable VBlank for Vblank Interrupt Wait
    irqInit();
    irqEnable(IRQ_VBLANK);

    videoSetMode(0);	//not using the main screen

    // Subscreen as a console
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    vramSetBankH(VRAM_H_SUB_BG);
    SUB_BG0_CR = BG_MAP_BASE(15);
    BG_PALETTE_SUB[0]=0;
    BG_PALETTE_SUB[255]=0xffff;
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

    iprintf ("Init'ing FAT...");
    if (fatInitDefault()) {
        iprintf ("okay\n");
    } else {
        iprintf ("fail!\n");
        stop();
    }

    if (stat (DEFAULT_FILE, &st) >= 0) {
        iprintf ("Running %s\n", DEFAULT_FILE);
        runNdsFile (DEFAULT_FILE);
    } else {
        std::string filename = browseForFile (".nds");
        iprintf ("Running %s\n", filename.c_str());
        runNdsFile (filename.c_str());
    }

    iprintf ("Start failed\n");

    stop();

    return 0;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
int NDS_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
    //printf("WARNING: You are using the SDL NDS video driver!\n");

    /* Determine the screen depth (use default 8-bit depth) */
    /* we change this during the SDL_SetVideoMode implementation... */
    vformat->BitsPerPixel = 16;     // mode 3
    vformat->BytesPerPixel = 2;
    vformat->Rmask = 0x0000f800;
    vformat->Gmask = 0x000007e0;
    vformat->Bmask = 0x0000001f;
    powerON(POWER_ALL);
    irqInit();
    irqSet(IRQ_VBLANK, on_irq_vblank);
    irqEnable(IRQ_VBLANK);

    //set the mode for 2 text layers and two extended background layers
    //videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
    videoSetMode(MODE_6_2D | DISPLAY_BG2_ACTIVE);

    //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 | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text

    //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)
    //vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000,VRAM_C_SUB_BG , VRAM_D_LCD);
    vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);
    //vramSetBankA(VRAM_A_MAIN_BG);
    //vramSetBankB(VRAM_B_MAIN_BG);
    //vramSetBankC(VRAM_C_MAIN_BG);
    //vramSetBankD(VRAM_D_MAIN_BG);
    //vramSetBankE(VRAM_E_MAIN_BG);
    //vramSetBankF(VRAM_F_MAIN_BG);
    //vramSetBankG(VRAM_G_MAIN_BG);
    vramSetBankH(VRAM_H_SUB_BG);
    vramSetBankI(VRAM_I_LCD);

    ////////////////set up text background for text/////////////////////
    SUB_BG0_CR = BG_MAP_BASE(8);

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

    //BG3_CR = BG_BMP16_512x512;

    //these are rotation backgrounds so you must set the rotation attributes:
    //these are fixed point numbers with the low 8 bits the fractional part
    //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap
    /*  BG3_XDX = 1<<8;
        BG3_XDY = 0;
        BG3_YDX = 0;
        BG3_YDY = 1<<8;
        //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2
        BG3_CX = 0;
        BG3_CY = 0;
    */
    //consoleInit() is a lot more flexible but this gets you up and running quick
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);


    frontBuffer =(u16*)(0x06000000);
    //backBuffer =(u16*)(0x06000000 + 1024 * 512*2);

    //lcdSwap();
    /* We're done! */
    return 0;
}
Ejemplo n.º 8
0
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 
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
void drawKeyboard(int tileBase, int mapBase, u16 *saveSpace) {
 	/* int keyboardDataSize = 4736 * 2; */

	for (int r = 0; r < 32 * 32; r++) {
//		*saveSpace++ = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r];
		((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = 0;
	}

	for (int r = 0; r < KEYBOARD_DATA_SIZE / 2; r++) {
//		*saveSpace++ = ((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r];
		((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r] = ((u16 *) (::keyboard_raw))[r];
	}

	for (int r = 0; r < 16; r++) {
		BG_PALETTE_SUB[r] = ((u16 *) (keyboard_pal_raw))[r];
	}

	// this is the font
	for (int tile = 0; tile < 94; tile++) {

		u16 *tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + ((KEYBOARD_DATA_SIZE) + (tile * 32)));
		const u8 *src = ((const u8 *) (::_8x8font_tga_raw)) + 18 + tile * 8;

		for (int y = 0 ; y < 8; y++) {
			for (int x = 0; x < 2; x++) {
				 *(tileAddr + (y * 2) + x) =(*(src + (y * 752) + (x * 4) + 0) & 0x0F)
									 	 | ((*(src + (y * 752) + (x * 4) + 1) & 0x0F) << 4)
										 | ((*(src + (y * 752) + (x * 4) + 2) & 0x0F) << 8)
										 | ((*(src + (y * 752) + (x * 4) + 3) & 0x0F) << 12);

			}
		}
	}




	for (int r = 0; r < 16; r++) {
		int col = ((u16 *) (keyboard_pal_raw))[r];

		int red = col & 0x001F;
		int green = (col & 0x03E0) >> 5;
		int blue = (col & 0x7C00) >> 10;

		red = (red * 8) / 16;
		green = (green * 24) / 16;
		blue = (blue * 8) / 16;

		if (green > 31) green = 31;

		BG_PALETTE_SUB[16 + r] = red | (green << 5) | (blue << 10);
	}

	keyboardX = -2;
	keyboardY = 2;

	DS::s_mapBase = mapBase;
	DS::s_tileBase = tileBase;

	shiftState = false;
	capsLockState = false;

	int x = keyboardX;
	int y = keyboardY;

	u16 *base = ((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase));
	baseAddress = base;

	for (int r = 0; r < DS_NUM_KEYS; r++) {
		base[(y + keys[r].y) * 32 + x + keys[r].x] = 10 + keys[r].keyNum * 2;
		base[(y + keys[r].y) * 32 + x + keys[r].x + 1] = 10 + keys[r].keyNum * 2 + 1;

		base[(y + keys[r].y + 1) * 32 + x + keys[r].x] = 10 + 148 + keys[r].keyNum * 2;
		base[(y + keys[r].y + 1) * 32 + x + keys[r].x + 1] = 10 + 148 + keys[r].keyNum * 2 + 1;

		keys[r].pressed = false;
	}


	closed = false;
	clearAutoComplete();

}