Beispiel #1
0
void InitVideo (void)
	{
	// Initialise the video system
	VIDEO_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	int x, y, w, h;
	x = 20;
	y = 32;
	w = rmode->fbWidth - (32);
	h = rmode->xfbHeight - (48);
	
	CON_InitEx(rmode, x, y, w, h);
	
	VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);

	CON_InitEx(rmode, x, y, w, h);
	
	// Set console text color
	printf("\x1b[%u;%um", 37, false);
	printf("\x1b[%u;%um", 40, false);
	}
Beispiel #2
0
void rvlInitFat()
{
	// temporary init video, pad, console
	VIDEO_Init();
	WPAD_Init();
	rmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
	// loop until either Home has been pressed, or an SD card has been found
	while(!fatInitDefault()) {
		WPAD_ScanPads();
		printf("\x1b[2;0HFAT initialization error!");
		printf("\x1b[3;0HPlease insert a SD card to continue or press Home to exit!");
		u32 pressed = WPAD_ButtonsDown(0);
		if(pressed & WPAD_BUTTON_HOME) {
			printf("\x1b[5;0HExiting...");
			exit(0);
		}
		VIDEO_WaitVSync();
	}
	printf("\x1b[2;0H");
	// set the app path
	strcpy(program.apppath, "sd:/apps/wii_azunyan8");
}
void Initialise()
{
	// Initialise the video system
	VIDEO_Init();

	// This function initialises the attached controllers
	PAD_Init();

	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

	// Initialise the console, required for printf
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

	// Set up the video registers with the chosen mode
	VIDEO_Configure(rmode);

	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);

	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}
Beispiel #4
0
int main(int argc, char *argv[])
{
	//does more than it should
	VIDEO_Init();

	int have_sd = initFAT();
	if (have_sd){
		FILE *fp = fopen("fat:/autoexec.dol", "rb");
		if (fp) {
			fseek(fp, 0, SEEK_END);
			int size = ftell(fp);
			fseek(fp, 0, SEEK_SET);
			if ((size > 0) && (size < (AR_GetSize() - (64*1024)))) {
				u8 *dol = (u8*) memalign(32, size);
				if (dol) {
					fread(dol, 1, size, fp);
						DOLtoARAM(dol, 0, NULL);
				}
				//We shouldn't reach this point
				if (dol != NULL) free(dol);
			}
			fclose(fp);
		}
			
	}
	return 0;
}
Beispiel #5
0
void grlib_Init (void)
	{
	memset (&grlibSettings, 0, sizeof (s_grlibSettings));
	grlibSettings.wiiswitch_poweroff = false;
	grlibSettings.wiiswitch_reset = false;
	
    // Initialise the Wiimotes & Gamecube
	PAD_Init(); 
    WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);

	VIDEO_Init();
	VIDEO_SetBlack(true);  // Disable video output during initialisation
	VIDEO_WaitVSync();
	VIDEO_WaitVSync();

    GRRLIB_Init(1,0);

	WPAD_SetVRes(0, 640, 480);
	WPAD_SetPowerButtonCallback( wmpower_cb );
	
	SYS_SetPowerCallback (power_cb);
    SYS_SetResetCallback (reset_cb);
	
	redrawTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight);
	popPushTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight);
	
	grlibSettings.RedrawCallback = NULL;
	
	grlibSettings.pointer[0] = NULL;
	grlibSettings.pointer[1] = NULL;
	grlibSettings.pointer[2] = NULL;
	grlibSettings.pointer[3] = NULL;
	}
Beispiel #6
0
void
InitVideo ()
{
	VIDEO_Init();
	vmode = VIDEO_GetPreferredMode(NULL); // get default video mode

	//Widescreen loading image fix...
	vmode->viWidth = 678;
	vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2;
	
	VIDEO_Configure (vmode);

	// Allocate the video buffers
	xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
	xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));

	// A console is always useful while debugging
	console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);

	// Clear framebuffers etc.
	VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
	VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
	VIDEO_SetNextFramebuffer (xfb[0]);

	VIDEO_SetBlack (FALSE);
	VIDEO_Flush ();
	VIDEO_WaitVSync ();
	if (vmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync ();

	StartGX();
	ResetVideo_Menu();
	// Finally, the video is up and ready for use :)
}
Beispiel #7
0
int main(){
	SYS_SetResetCallback(WiiResetPressed);
	SYS_SetPowerCallback(WiiPowerPressed);
	WPAD_SetPowerButtonCallback(WiimotePowerPressed);
	
	VIDEO_Init();

	if(CONF_GetAspectRatio())
	{
		SCREEN_WIDTH = 720;
	} else {
		SCREEN_WIDTH = 640;
	}
	
	
	initializeinput();
	initializeworld();
	
	GRRLIB_InitVideo();
	GRRLIB_Start();
	
	startscreen();
		
    while(1){
		if(!fadeout)
		{
			updateinput();
			updateworld();
			updatetiles();
			updateoverlay();
		}
		
		drawworld();
		drawcursor();
		drawoverlay();

		//When hitting home do a slow fade to black,
		//if it is totally black do the actual exit
		if (wpadheld & WPAD_BUTTON_HOME || HWButton) fadeout = true;
		if(fadeout)
		{
			fadeout_opacity += 5;
			if(fadeout_opacity >= 270) {
				if(HWButton)
					SYS_ResetSystem(HWButton, 0, 0);
					
				return 0;
			}
				
			GRRLIB_Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, fadeout_opacity > 255 ? 255 << 24 : fadeout_opacity << 24, true);
			
		}
		
		GRRLIB_Render();
    }
    return 0;
}
Beispiel #8
0
void Sys_Init(void)
{
	/* Initialize video subsytem */
	VIDEO_Init();

	/* Set RESET/POWER button callback */
	SYS_SetResetCallback(__Sys_ResetCallback);
	SYS_SetPowerCallback(__Sys_PowerCallback);
}
Beispiel #9
0
int main(int argc, char **argv)
{
    //DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
    s8 ios_patched = 0;
    s32 ret = 0;

    CheckForGecko();
    VIDEO_Init();

    vmode = VIDEO_GetPreferredMode(NULL);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

    VIDEO_Configure(vmode);
    VIDEO_SetNextFramebuffer(xfb);
    VIDEO_SetBlack(false);
    VIDEO_Flush();

    VIDEO_WaitVSync();
    if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

    int x = 20, y = 20, w, h;
    w = vmode->fbWidth - (x * 2);
    h = vmode->xfbHeight - (y + 20);

    // Initialize the console
    //Con_InitEX works better but for some odd reason doesn't show right when clearing screen...
    //CON_InitEx(vmode, x, y, w, h);
    CON_Init(xfb,x,y,w,h, vmode->fbWidth*VI_DISPLAY_PIX_SZ );
    printf("\n\n\n");
    VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);

    gprintf("resolution is %dx%d\n",vmode->viWidth,vmode->viHeight);
    //printf("\x1b[2J");
    /*sleep(3);
    gprintf("crashing...\n");
    free((void*)0x1);*/
    /*free((void*)0x1);
    free((void*)0x1);
    free((void*)0x1);
    memcpy((void*)0x0,(void*)0x1,5);*/
    //return 0;
    //reload ios so that IF the user started this with AHBPROT we lose everything from HBC. also, IOS36 is the most patched ios :')
    IOS_ReloadIOS(36);

    WPAD_Init();
    PAD_Init();

    printf("\nIOS %d rev %d\n\n",IOS_GetVersion(),IOS_GetRevision());
    if( (VERSION&0xFF) % 10 == 0 )
    {
#if BETAVERSION > 0
        printf("Priiloader v%d.%db%d(r0x%08x) Installation/Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,BETAVERSION,GIT_REV);
#else
        printf("\t\tPriiloader v%d.%d(r0x%08x) Installation / Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,GIT_REV);
#endif
    }
Beispiel #10
0
void InitVideo()
{
	VIDEO_Init();
	
	// If WiiU - Force 16:9 aspect ratio based on WiiU settings
	if(isWiiU() && Settings.widescreen)
	{
		write32(0xd8006a0, 0x30000004), mask32(0xd8006a8, 0, 2);		
	}
	
	vmode = VIDEO_GetPreferredMode(NULL); // get default video mode

	vmode->viWidth = Settings.widescreen ? 708 : 694;

	if (Settings.PAL50)
	{
		vmode->viXOrigin = (VI_MAX_WIDTH_PAL - vmode->viWidth) / 2;
	}
	else
	{
		vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth) / 2;
	}

	VIDEO_Configure(vmode);

	screenheight = 480;
	screenwidth = vmode->fbWidth;

	// Allocate the video buffers
	xfb[0] = (u32 *) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) );
	xfb[1] = (u32 *) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) );

	// Clear framebuffers etc.
	VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
	VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);
	VIDEO_SetNextFramebuffer(xfb[0]);

	VIDEO_Flush();
	VIDEO_WaitVSync();
	if (vmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();

	// Initialize GX
	GXColor background = { 0, 0, 0, 0xff };
	gp_fifo = (u8 *) memalign(32, GP_FIFO_SIZE);
	memset (gp_fifo, 0, GP_FIFO_SIZE);
	GX_Init (gp_fifo, GP_FIFO_SIZE);
	GX_SetCopyClear (background, 0x00ffffff);
	GX_SetDispCopyGamma (GX_GM_1_0);
	GX_SetCullMode (GX_CULL_NONE);

	ResetVideo_Menu();

	VIDEO_SetBlack(FALSE);
	// Finally, the video is up and ready for use :)
}
Beispiel #11
0
static void frontend_gx_init(void *data)
{
   (void)data;
#ifdef HW_RVL
   IOS_ReloadIOS(IOS_GetVersion());
   L2Enhance();
#ifndef IS_SALAMANDER
   gx_init_mem2();
#endif
#endif

#if defined(DEBUG) && defined(IS_SALAMANDER)
   VIDEO_Init();
   GXRModeObj *rmode = VIDEO_GetPreferredMode(NULL);
   void *xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
   console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
   VIDEO_Configure(rmode);
   VIDEO_SetNextFramebuffer(xfb);
   VIDEO_SetBlack(FALSE);
   VIDEO_Flush();
   VIDEO_WaitVSync();
   VIDEO_WaitVSync();
#endif

#ifndef DEBUG
   __exception_setreload(8);
#endif

   fatInitDefault();

#ifdef HAVE_LOGGER
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER) && !defined(IS_SALAMANDER)
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_file;
#endif

#if defined(HW_RVL) && !defined(IS_SALAMANDER)
   OSThread gx_device_thread;
   gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
   gx_devices[GX_DEVICE_SD].name = "sd";
   gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
   gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
   gx_devices[GX_DEVICE_USB].name = "usb";
   gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);

   OSInitMutex(&gx_device_cond_mutex);
   OSInitCond(&gx_device_cond);
   OSInitMutex(&gx_device_mutex);
   OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0);
#endif
}
Beispiel #12
0
void initConsole(const void *imgBgData,enum CONSOLE_COLORS CONSOLE_COLOR,const char *strSplashScreenMessage,double dbLeft,double dbTop,double dbWidth,double dbHeight) {
PNGUPROP imgProperties;
IMGCTX imgContext;
void *pFramebuffer=NULL;
GXRModeObj *pRmode=NULL;
double dbConsoleFrameX[2]={dbLeft,dbLeft},dbConsoleFrameY[2]={dbTop,dbTop},dbBgImgXScaleFactor=1,dbBgImgYScaleFactor=1,dbReferenceWidth,dbReferenceHeight;
int intConsoleColumnsCount,intConsoleRowsCount;
struct stConsoleCursorLocation stTexteLocation;
    VIDEO_Init();
    pRmode=VIDEO_GetPreferredMode(NULL);
    pFramebuffer=MEM_K0_TO_K1(SYS_AllocateFramebuffer(pRmode));
    VIDEO_ClearFrameBuffer(pRmode,pFramebuffer,CONSOLE_COLOR);
    VIDEO_Configure(pRmode);
    VIDEO_SetNextFramebuffer(pFramebuffer);
    VIDEO_SetBlack(FALSE);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if(pRmode->viTVMode&VI_NON_INTERLACE) {
        VIDEO_WaitVSync();
    }
    dbWidth=fabs(dbWidth);
    dbHeight=fabs(dbHeight);
    if ((imgContext=getPngImageRessources(imgBgData,&imgProperties))) {
        dbReferenceWidth=imgProperties.imgWidth;
        dbReferenceHeight=imgProperties.imgHeight;
        dbBgImgXScaleFactor=pRmode->fbWidth/imgProperties.imgWidth;
        dbBgImgYScaleFactor=pRmode->xfbHeight/imgProperties.imgHeight;
    }
    else {
        dbReferenceWidth=pRmode->fbWidth;
        dbReferenceHeight=pRmode->xfbHeight;
    }
    if (dbWidth<=1) {
        dbWidth=dbReferenceWidth*dbWidth;
        dbConsoleFrameX[0]=0;
        dbConsoleFrameX[1]=dbWidth;
    }
    if (dbHeight<=1) {
        dbHeight=dbReferenceHeight*dbHeight;
        dbConsoleFrameY[0]=0;
        dbConsoleFrameY[1]=dbHeight;
    }
    CON_InitEx(pRmode,(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameX[0],2,0,dbReferenceWidth,dbLeft)*dbBgImgXScaleFactor),(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameY[0],2,0,dbReferenceHeight,dbTop)*dbBgImgYScaleFactor),(s32) getRoundNumber(dbWidth*dbBgImgXScaleFactor),(s32) getRoundNumber(dbHeight*dbBgImgYScaleFactor));
    if (imgContext) {
        PNGU_DECODE_TO_COORDS_YCbYCr(imgContext,0,0,imgProperties.imgWidth,imgProperties.imgHeight,pRmode->fbWidth,pRmode->xfbHeight,pFramebuffer);
        PNGU_ReleaseImageContext(imgContext);
    }
    resetDefaultFontSyle();
    if (*strSplashScreenMessage) {
        CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount);
        printAlignedText(ALIGN_CENTER,ALIGN_MIDDLE,0,0,intConsoleRowsCount-1,intConsoleColumnsCount-1,true,true,&stTexteLocation,"%s",strSplashScreenMessage);
    }

}
Beispiel #13
0
void Sys_Init(void)
{
	/* Initialize video subsytem */
	VIDEO_Init();

	/* Set RESET/POWER button callback */
	SYS_SetResetCallback(__Sys_ResetCallback);
	SYS_SetPowerCallback(__Sys_PowerCallback);

	/* Prepare random seed */
	srand(time(0));
}
Beispiel #14
0
void init_video_and_wpad()
{
	// Video and WPAD initialized?
	if(video_and_wpad_initialized)
	{
		return;
	}
	
	// Initialise the video system
	VIDEO_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	
	// Set up the video registers with the chosen mode
	VIDEO_Configure(rmode);
	
	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);
	
	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	// Set console parameters
    int x = 24, y = 32, w, h;
    w = rmode->fbWidth - (32);
    h = rmode->xfbHeight - (48);

    // Initialize the console - CON_InitEx works after VIDEO_ calls
	CON_InitEx(rmode, x, y, w, h);

	// Clear the garbage around the edges of the console
    VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
	
	// This function initialises the attached controllers
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
	video_and_wpad_initialized = TRUE;
}
int main(int argc, char **argv) {
	void *xfb[2];
	u32 type;
	int fbi = 0;

	VIDEO_Init();
	PAD_Init();
	WPAD_Init();

	rmode = VIDEO_GetPreferredMode(NULL);

	// double buffering, prevents flickering (is it needed for LCD TV? i don't have one to test)
	xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	SYS_SetResetCallback(reload);
	SYS_SetPowerCallback(shutdown);

	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(0, rmode->fbWidth, rmode->xfbHeight);

	while(!doreload && !dooff) {
		CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
		//VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK);
		std::cout<<"\n\n\n";
		WPAD_ReadPending(WPAD_CHAN_ALL, countevs);
		int wiimote_connection_status = WPAD_Probe(0, &type);
		print_wiimote_connection_status(wiimote_connection_status);

		std::cout<<"  Event count: "<<evctr<<"\n";
		if(wiimote_connection_status == WPAD_ERR_NONE) {
			print_and_draw_wiimote_data(xfb[fbi]);
		}
		VIDEO_SetNextFramebuffer(xfb[fbi]);
		VIDEO_Flush();
		VIDEO_WaitVSync();
		fbi ^= 1;
	}
	if(doreload) return 0;
	if(dooff) SYS_ResetSystem(SYS_SHUTDOWN,0,0);

	return 0;
}
Beispiel #16
0
		static void init()
		{
			fb = 0;

			// Initialise the video system.
			VIDEO_Init();

			rmode = VIDEO_GetPreferredMode(NULL);

			// Allocate the frame buffer.
			framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
			framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

			// Set up the video system with the chosen mode.
			VIDEO_Configure(rmode);

			// Set the frame buffer.
			VIDEO_SetNextFramebuffer(framebuffer[fb]);

			VIDEO_SetBlack(FALSE);
			VIDEO_Flush();
			VIDEO_WaitVSync();
			if (rmode->viTVMode & VI_NON_INTERLACE)
			{
				VIDEO_WaitVSync();
			}

			// Initialise the debug console.
			// ELUTODO: only one framebuffer with it?
			console_init(framebuffer[0], 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2);

			// Initialise the controller library.
			PAD_Init();

			// Initialise the keyboard library
			KEYBOARD_Init(NULL);

			if(!fatInitDefault())
				Sys_Error("Error initializing filesystem");

#ifndef DISABLE_WIIMOTE
			if (WPAD_Init() != WPAD_ERR_NONE)
				Sys_Error("WPAD_Init() failed.\n");
#endif

			wiimote_ir_res_x = rmode->fbWidth;
			wiimote_ir_res_y = rmode->xfbHeight;
		}
Beispiel #17
0
void wii_video_init(void)
{
   VIDEO_Init();
   GXRModeObj *mode = VIDEO_GetPreferredMode(NULL);
   setup_video_mode(mode);

   GX_Init(gx_fifo, sizeof(gx_fifo));
   GX_SetDispCopyGamma(GX_GM_1_0);
   GX_SetCullMode(GX_CULL_NONE);
   GX_SetClipMode(GX_CLIP_DISABLE);

   init_vtx(mode);
   build_disp_list();

   g_filter = true;
   g_vsync = true;
}
Beispiel #18
0
STDTerminal::STDTerminal() {
#ifdef FORWII
	//	TODO:osetrit ak je video uz initnute
	VIDEO_Init();
	rmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth
			* VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if (rmode->viTVMode & VI_NON_INTERLACE)
	VIDEO_WaitVSync();
#endif
}
Beispiel #19
0
int main()
{
#if GEKKO
    VIDEO_Init();
#if HW_RVL
    WPAD_Init();
#endif
    PAD_Init();

    rmode = VIDEO_GetPreferredMode(nullptr);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

    CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
    CON_EnableGecko(CARD_SLOTB, true);

    VIDEO_Configure(rmode);
    VIDEO_SetBlack(false);

    VIDEO_Flush();

    VIDEO_WaitVSync();
    if (rmode->viTVMode & VI_NON_INTERLACE)
        VIDEO_WaitVSync();

    athena::io::MemoryCopyReader test("sd:/test.dat");
    while(true)
    {
#if HW_RVL
        WPAD_ScanPads();
#endif
        PAD_ScanPads();
        if (PAD_ButtonsDown(0) & PAD_BUTTON_START)
            break;

#if HW_RVL
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
            break;
#endif
        VIDEO_WaitVSync();
    }
#endif
    return 0;
}
Beispiel #20
0
void init_wii()
{
	VIDEO_Init();
	WPAD_Init();
	rmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();


	// The console understands VT terminal escape codes
	// This positions the cursor on row 2, column 0
	// we can use variables for this with format codes too
	// e.g. printf ("\x1b[%d;%dH", row, column );
	printf("\x1b[2;0H");

	printf("yellhttptest\n");
	printf("Initializing FAT...\n");
	if(!fatInitDefault())
	{
		printf("FAT init failed.\n");
		console_pause();
	}
	printf("Configuring network ...\n");
	memset(localip, 0, 16);
	memset(netmask, 0, 16);
	memset(gateway, 0, 16);
	s32 ret = if_config (localip, netmask, gateway, true);
	if(ret<0)
	{
		printf("Network config failed: %d\n", ret);
		console_pause();
	}
	else
	{
		printf("Network config done ip: %s, gw: %s, mask %s\n", localip, gateway, netmask);
	}
}
Beispiel #21
0
void initialise(void) 
{
	VIDEO_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	vmode = VIDEO_GetPreferredMode(NULL);
	xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
	xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
	console_init(xfb[0],20,20,vmode->fbWidth,vmode->xfbHeight,vmode->fbWidth*VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(vmode);
	VIDEO_SetNextFramebuffer(xfb[0]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
	printf("\x1b[2;0H"); // start at 2nd row, 0th column

	printf("switch2sneek: simple application to boot to sneek v2\n\n");
}
Beispiel #22
0
void
InitVideo ()
{
	VIDEO_Init();
	vmode = VIDEO_GetPreferredMode(NULL); // get default video mode

	// widescreen fix
	if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
	{
		vmode->viWidth = VI_MAX_WIDTH_PAL-12;
		vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
	}

	VIDEO_Configure (vmode);

	screenheight = vmode->xfbHeight;
	screenwidth = vmode->fbWidth;

	// Allocate the video buffers
	xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
	xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));

	// Clear framebuffers etc.
	VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
	VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
	VIDEO_SetNextFramebuffer (xfb[0]);

	// video callback
	VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB);

	VIDEO_SetBlack (FALSE);
	VIDEO_Flush ();
	VIDEO_WaitVSync ();
	if (vmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync ();

	StartGX();
	ResetVideo_Menu();
	// Finally, the video is up and ready for use :)
}
Beispiel #23
0
int wiidisplay_init(void)
{
  int error;
        
  error = init_colours(); if( error ) return error;

  VIDEO_Init();

  u32 videoMode = VIDEO_GetCurrentTvMode();
  switch(videoMode) {
  case VI_NTSC:
    rmode = &TVNtsc480IntDf;
    break;
  case VI_PAL:
    rmode = &TVPal528IntDf;
    break;
  case VI_MPAL:
    rmode = &TVMpal480IntDf;
    break;
  default:
    rmode = &TVNtsc480IntDf;
    break;
  }

  xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
  console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight,
	       rmode->fbWidth*VI_DISPLAY_PIX_SZ);

  VIDEO_Configure(rmode);
  VIDEO_SetNextFramebuffer(xfb);
  VIDEO_SetBlack(FALSE);
  VIDEO_Flush();

  VIDEO_WaitVSync();
  if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

  return 0;
}
Beispiel #24
0
void InitTextVideo ()
{
    gprintf("\nInitTextVideo ()");
    if (textVideoInit)
    {
        gprintf("...0");
        return;
    }
    dbvideo=1;
    VIDEO_Init();
                                                  // get default video mode
    GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL);

    // widescreen fix
    VIDEO_Configure (vmode);

    // Allocate the video buffers
    xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));

    // A console is always useful while debugging
    console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);

    // Clear framebuffers etc.
    VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK);
    VIDEO_SetNextFramebuffer (xfb);

    VIDEO_SetBlack (FALSE);
    VIDEO_Flush ();
    VIDEO_WaitVSync ();
    if (vmode->viTVMode & VI_NON_INTERLACE)
        VIDEO_WaitVSync ();

    //send console output to the gecko
    if (geckoinit)CON_EnableGecko(1, true);
    textVideoInit = true;
    gprintf("...1");

}
Beispiel #25
0
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	// Initialise the video system
	VIDEO_Init();
	Video_SetMode();

	WPAD_Init();
	PAD_Init();

   	if(AHBPROT_DISABLED)
		IosPatch_RUNTIME(true, false, false, true);
	else
		IOS_ReloadIOS(236);

	menu();

	signed_blob *p_tmd = NULL;
	u32 len;
	s32 ret;

	ret = GetTMD(0x0001000154484246LL, &p_tmd, &len);

	if(ret < 0)
	{
		*(vu32*)0x8132FFFB = 0x50756E65;
		DCFlushRange((void*)0x8132FFFB, 4);
		SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
	}
	else
	{
		WII_LaunchTitle(0x0001000154484246);

	}

	return 0;
}
Beispiel #26
0
int main(void)
{
	int vmode = -1;
	exception_init();
	dsp_reset();

	irq_initialize();
	irq_bw_enable(BW_PI_IRQ_RESET);
	irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
	/* external ohci */
	irq_hw_enable(IRQ_OHCI0);
	/* internal ohci */
	//irq_hw_enable(IRQ_OHCI1);

	ipc_initialize();
	ipc_slowping();

	gecko_init();
    input_init();
	init_fb(vmode);

	VIDEO_Init(vmode);
	VIDEO_SetFrameBuffer(get_xfb());
	VISetupEncoder();

	u32 version = ipc_getvers();
	u16 mini_version_major = version >> 16 & 0xFFFF;
	u16 mini_version_minor = version & 0xFFFF;
	printf("Mini version: %d.%0d\n", mini_version_major, mini_version_minor);

	if (version < MINIMUM_MINI_VERSION) {
		printf("Sorry, this version of MINI (armboot.bin)\n"
			"is too old, please update to at least %d.%0d.\n", 
			(MINIMUM_MINI_VERSION >> 16), (MINIMUM_MINI_VERSION & 0xFFFF));
		for (;;) 
			; // better ideas welcome!
	}
Beispiel #27
0
int main(int argc,char **argv) {

    f32 yscale,zt = 0;
    u32 xfbHeight;
    u32 fb = 0;
    f32 rquad = 0.0f;
    u32 first_frame = 1;
    GXTexObj texture;
    Mtx view; // view and perspective matrices
    Mtx model, modelview;
    Mtx44 perspective;
    void *gpfifo = NULL;
    GXColor background = {0, 0, 0, 0xff};
    guVector cam = {0.0F, 0.0F, 0.0F},
             up = {0.0F, 1.0F, 0.0F},
             look = {0.0F, 0.0F, -1.0F};
    TPLFile crateTPL;

    VIDEO_Init();
    WPAD_Init();

    rmode = VIDEO_GetPreferredMode(NULL);

    // allocate the fifo buffer
    gpfifo = memalign(32,DEFAULT_FIFO_SIZE);
    memset(gpfifo,0,DEFAULT_FIFO_SIZE);

    // allocate 2 framebuffers for double buffering
    frameBuffer[0] = SYS_AllocateFramebuffer(rmode);
    frameBuffer[1] = SYS_AllocateFramebuffer(rmode);

    // configure video
    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(frameBuffer[fb]);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

    fb ^= 1;

    // init the flipper
    GX_Init(gpfifo,DEFAULT_FIFO_SIZE);

    // clears the bg to color and clears the z buffer
    GX_SetCopyClear(background, 0x00ffffff);

    // other gx setup
    GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
    yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight);
    xfbHeight = GX_SetDispCopyYScale(yscale);
    GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopyDst(rmode->fbWidth,xfbHeight);
    GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
    GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE));

    if (rmode->aa)
        GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
    else
        GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);

    GX_SetCullMode(GX_CULL_NONE);
    GX_CopyDisp(frameBuffer[fb],GX_TRUE);
    GX_SetDispCopyGamma(GX_GM_1_0);

    // setup the vertex attribute table
    // describes the data
    // args: vat location 0-7, type of data, data format, size, scale
    // so for ex. in the first call we are sending position data with
    // 3 values X,Y,Z of size F32. scale sets the number of fractional
    // bits for non float data.
    GX_ClearVtxDesc();
    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0);

    GX_InvVtxCache();
    GX_InvalidateTexAll();
    TPL_OpenTPLFromMemory(&crateTPL, (void *)crate_tpl,crate_tpl_size);
    TPL_GetTexture(&crateTPL,crate,&texture);

    // setup our camera at the origin
    // looking down the -z axis with y up
    guLookAt(view, &cam, &up, &look);

    // setup our projection matrix
    // this creates a perspective matrix with a view angle of 90,
    // and aspect ratio based on the display resolution
    f32 w = rmode->viWidth;
    f32 h = rmode->viHeight;
    guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F);
    GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE);

    guVector cubeAxis = {1,1,1};

    while(1) {

        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
        else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_UP) zt -= 0.25f;
        else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_DOWN) zt += 0.25f;

        // set number of rasterized color channels
        GX_SetNumChans(1);

        //set number of textures to generate
        GX_SetNumTexGens(1);

        // setup texture coordinate generation
        // args: texcoord slot 0-7, matrix type, source to generate texture coordinates from, matrix to use
        GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);

        GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE);
        GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

        GX_LoadTexObj(&texture, GX_TEXMAP0);

        guMtxIdentity(model);
        guMtxRotAxisDeg(model, &cubeAxis, rquad);
        guMtxTransApply(model, model, 0.0f,0.0f,zt-7.0f);
        guMtxConcat(view,model,modelview);
        // load the modelview matrix into matrix memory
        GX_LoadPosMtxImm(modelview, GX_PNMTX3);
        GX_SetCurrentMtx(GX_PNMTX3);

        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);			// Draw a Cube

        GX_Position3f32(-1.0f, 1.0f, -1.0f);	// Top Left of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-1.0f, 1.0f, 1.0f);	// Top Right of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(-1.0f, -1.0f, 1.0f);	// Bottom Right of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(- 1.0f, -1.0f, -1.0f);		// Bottom Left of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( 1.0f,1.0f, -1.0f);	// Top Left of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f, -1.0f);	// Top Right of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f,1.0f);	// Bottom Right of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f,1.0f,1.0f);	// Bottom Left of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( -1.0f, -1.0f, 1.0f);		// Top Right Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f, -1.0f, 1.0f);	// Top Left Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f, -1.0f);	// Bottom Left Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( -1.0f,-1.0f, -1.0f);	// Bottom Right Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( -1.0f,1.0f,1.0f);	// Bottom Left Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-1.0f,1.0f,-1.0f);	// Bottom Right Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f, 1.0f,-1.0f);	// Top Right Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f, 1.0f,1.0f);	// Top Left Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32(1.0f, -1.0f, -1.0f);	// Top Right Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f, 1.0f,-1.0f);	// Top Left Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(-1.0f,1.0f,-1.0f);	// Bottom Left Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-1.0f,-1.0f, -1.0f);	// Bottom Right Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( 1.0f, -1.0f,1.0f);	// Top Right Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32( -1.0f, -1.0f, 1.0f);		// Top Left Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32( -1.0f,1.0f, 1.0f);	// Bottom Left Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f,1.0f,1.0f);	// Bottom Right Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(0.0f,1.0f);

        GX_End();									// Done Drawing The Quad

        GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
        GX_SetColorUpdate(GX_TRUE);
        GX_CopyDisp(frameBuffer[fb],GX_TRUE);

        GX_DrawDone();

        VIDEO_SetNextFramebuffer(frameBuffer[fb]);
        if(first_frame) {
            first_frame = 0;
            VIDEO_SetBlack(FALSE);
        }
        VIDEO_Flush();
        VIDEO_WaitVSync();
        fb ^= 1;

        rquad -= 0.15f;				// Decrease The Rotation Variable For The Quad     ( NEW )
    }
}
Beispiel #28
0
//---------------------------------------------------------------------------------
int main() {
//---------------------------------------------------------------------------------
	VIDEO_Init();
	
	rmode = VIDEO_GetPreferredMode(NULL);

	PAD_Init();
	
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
		
	VIDEO_Configure(rmode);
		
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	console_init(xfb,20,64,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2);
	VIDEO_SetNextFramebuffer(xfb);

	printf("Memory Card Demo\n\n");

	while (1) {
		printf("Insert A card in slot B and press A\n");

		do {
			PAD_ScanPads();
			if (PAD_ButtonsDown(0) & PAD_BUTTON_START) PSOreload();
			VIDEO_WaitVSync();
		} while ( !(PAD_ButtonsDown(0) & PAD_BUTTON_A));


		printf("Mounting card ...\n");

		CARD_Init("DEMO","00");
		int SlotB_error = CARD_Mount(CARD_SLOTB, SysArea, card_removed);
	
		printf("slot B code %d\n",SlotB_error);

		int CardError;
		
		if (SlotB_error >= 0) {

			unsigned int SectorSize = 0;
			CARD_GetSectorSize(CARD_SLOTB,&SectorSize);

			printf("Sector size is %d bytes.\n\n",SectorSize);

			char *CardBuffer = (char *)memalign(32,SectorSize);
			
			printf("Starting directory\n");

			card_dir CardDir;
			card_file CardFile;
			
			CardError = CARD_FindFirst(CARD_SLOTB, &CardDir, true);

			bool found = false;
			
			while ( CARD_ERROR_NOFILE != CardError ) {
				printf("%s  %s  %s\n",CardDir.filename,CardDir.gamecode,CardDir.company);
				CardError = CARD_FindNext(&CardDir);
				if ( 0 == strcmp (DemoFileName, (char *)CardDir.filename)) found = true; 
			};

			printf("Finished directory\n\n");
			
			if (found) {
				printf("Test file contains :- \n");
				CardError = CARD_Open(CARD_SLOTB ,DemoFileName,&CardFile);
				CARD_Read(&CardFile,CardBuffer,SectorSize,0);
				printf("%s\n",CardBuffer);
				
				CARD_Close(&CardFile);
			
				CARD_Delete(CARD_SLOTB,DemoFileName);
			} else {
			
				printf("writing test file ...\n");
				CardError = CARD_Create(CARD_SLOTB ,DemoFileName,SectorSize,&CardFile);

				if (0 == CardError) {
					time_t gc_time;
					gc_time = time(NULL);

					sprintf(CardBuffer,"This text was written by MemCardDemo\nat %s\n",ctime(&gc_time));

					CardError = CARD_Write(&CardFile,CardBuffer,SectorSize,0);
					CardError = CARD_Close(&CardFile);
				}
			}

			CARD_Unmount(CARD_SLOTB);
			free(CardBuffer);
			
		}
	}

}
Beispiel #29
0
// TODO this is just my console test app, clean up this mess!
int main(int argc, char *argv[]) {
	(void) argc;
	(void) argv;

	VIDEO_Init();
	PAD_Init();

	SYS_SetResetCallback(stmcb);
	SYS_SetPowerCallback(stmcb);

	gfx_video_init(NULL);
	gfx_init();
	gfx_con_init(NULL);

	printf("startup\n");

	gfx_tex_t tex;
	memset(&tex, 0, sizeof(gfx_tex_t));
	if (!gfx_tex_init(&tex, GFX_TF_RGB565, 0, 16, 16)) {
		printf("failed to init tex!\n");
		return 1;
	}
	memset(tex.pixels, 0xe070, 16 * 16 * 2);
	gfx_tex_flush_texture(&tex);

	gfx_screen_coords_t coords_bg;
	gfx_coords(&coords_bg, &tex, GFX_COORD_FULLSCREEN);

	srand(gettime());

	u64 frame = 0;
	u16 b;
	bool pf = false;
	u32 retries;
	u8 fg = 7, bg = 0;
	u32 i;
	char buf[32];

	while (!quit) {
		b = 0;
		if (PAD_ScanPads() & 1) {
			b = PAD_ButtonsDown(0);
		
			gfx_con_set_alpha(0xff - PAD_TriggerR(0), 0xff - PAD_TriggerL(0));
		}

		if (b & PAD_BUTTON_A)
			quit = true;

		if (b & PAD_BUTTON_B)
			pf = !pf;

		if (b & PAD_BUTTON_X)
			printf(S_RED("Hello") " " S_BLUE("world") "!\n");

		if (pf) {
			for (i = 0; i < gfx_con_get_columns() * gfx_con_get_rows(); ++i) {
				printf(CON_ESC "%u;1m" CON_ESC "%um%c", 30 + IRAND(8),
						40 + IRAND(8), 0x20 + IRAND(16 * 9));
			}
		}

		if (b & PAD_TRIGGER_Z) {
			gfx_con_reset();
			fg = 7;
			bg = 0;
		}

		if (b & 15) {
			if (b & PAD_BUTTON_LEFT) {
				fg = (fg + 8 - 1) % 8;
				gfx_con_set_foreground_color(fg, true);
			}
			if (b & PAD_BUTTON_RIGHT) {
				fg = (fg + 1) % 8;
				gfx_con_set_foreground_color(fg, true);
			}
			if (b & PAD_BUTTON_UP) {
				bg = (bg + 8 - 1) % 8;
				gfx_con_set_background_color(bg, false);
			}
			if (b & PAD_BUTTON_DOWN) {
				bg = (bg + 1) % 8;
				gfx_con_set_background_color(bg, false);
			}

			printf("new color selected: %u %u\n", fg, bg);
		}

		sprintf(buf, "frame: %llu", frame);
		gfx_con_save_attr();
		gfx_con_set_pos(1, gfx_con_get_columns() - strlen(buf) + 1);
		printf(CON_COLRESET "%s", buf);
		gfx_con_restore_attr();

		retries = 0;
		while (!gfx_frame_start()) {
			retries++;
			if (retries > 1000) {
				printf("gx hates you\n");
				gfx_frame_abort();
				return -1;
			}

			usleep(50);
		}

		gfx_draw_tex(&tex, &coords_bg);
		gfx_con_draw();

		gfx_frame_end();

		frame++;
	}

	printf("shutdown\n");

	gfx_tex_deinit(&tex);
	gfx_con_deinit();
	gfx_deinit();
	gfx_video_deinit();

	return 0;
}
Beispiel #30
0
/* Initialise Video, PAD, DVD, Font */
void* Initialise (void)
{
	VIDEO_Init ();
	PAD_Init ();  
	DVD_Init(); 
	*(volatile unsigned long*)0xcc00643c = 0x00000000; //allow 32mhz exi bus
	
	// Disable IPL modchips to allow access to IPL ROM fonts
	ipl_set_config(6); 
	usleep(1000); //wait for modchip to disable (overkill)
	
	
	__SYS_ReadROM(IPLInfo,256,0);	// Read IPL tag

	// Wii has no IPL tags for "PAL" so let libOGC figure out the video mode
	if(!is_gamecube()) {
		vmode = VIDEO_GetPreferredMode(NULL); //Last mode used
	}
	else {	// Gamecube, determine based on IPL
		int retPAD = 0, retCnt = 10000;
		while(retPAD <= 0 && retCnt >= 0) { retPAD = PAD_ScanPads(); usleep(100); retCnt--; }
		// L Trigger held down ignores the fact that there's a component cable plugged in.
		if(VIDEO_HaveComponentCable() && !(PAD_ButtonsDown(0) & PAD_TRIGGER_L)) {
			if(strstr(IPLInfo,"MPAL")!=NULL) {
				swissSettings.sramVideo = 2;
				vmode = &TVMpal480Prog; //Progressive 480p
			}
			else if((strstr(IPLInfo,"PAL")!=NULL)) {
				swissSettings.sramVideo = 1;
				vmode = &TVPal576ProgScale; //Progressive 576p
			}
			else {
				swissSettings.sramVideo = 0;
				vmode = &TVNtsc480Prog; //Progressive 480p
			}
		}
		else {
			//try to use the IPL region
			if(strstr(IPLInfo,"MPAL")!=NULL) {
				swissSettings.sramVideo = 2;
				vmode = &TVMpal480IntDf;        //PAL-M
			}
			else if(strstr(IPLInfo,"PAL")!=NULL) {
				swissSettings.sramVideo = 1;
				vmode = &TVPal576IntDfScale;         //PAL
			}
			else {
				swissSettings.sramVideo = 0;
				vmode = &TVNtsc480IntDf;        //NTSC
			}
		}
	}
	initialise_video(vmode);
	populateVideoStr(vmode);

	init_font();
	init_textures();
	whichfb = 0;
	
	drive_version(&driveVersion[0]);
	swissSettings.hasDVDDrive = *(u32*)&driveVersion[0] ? 1 : 0;
	
	if(!driveVersion[0]) {
		// Reset DVD if there was a modchip
		DrawFrameStart();
		WriteFontStyled(640/2, 250, "Initialise DVD .. (HOLD B if NO DVD Drive)", 0.8f, true, defaultColor);
		DrawFrameFinish();
		dvd_reset();	// low-level, basic
		dvd_read_id();
		if(!(PAD_ButtonsHeld(0) & PAD_BUTTON_B)) {
			dvd_set_streaming(*(char*)0x80000008);
		}
		drive_version(&driveVersion[0]);
		swissSettings.hasDVDDrive = *(u32*)&driveVersion[0] ? 1 : 0;
		if(!swissSettings.hasDVDDrive) {
			DrawFrameStart();
			DrawMessageBox(D_INFO, "No DVD Drive Detected !!");
			DrawFrameFinish();
			sleep(2);
		}
	}
	
	return xfb[0];
}