示例#1
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 :)
}
示例#2
0
void Init_Console()
{
	// 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);
}
示例#3
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;
}
示例#4
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");

}
示例#5
0
void video_setmode(void)
{
	/* Select preferred video mode */
	vmode = VIDEO_GetPreferredMode(NULL);

	/* Allocate memory for the framebuffer */
	framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

	/* Configure the video subsystem */
	VIDEO_Configure(vmode);

	/* Setup video */
	VIDEO_SetNextFramebuffer(framebuffer);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();

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

	/* Clear the screen */
	VIDEO_ClearFrameBuffer(vmode, framebuffer, COLOR_BLACK);
}
示例#6
0
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
	s32 retval;

	// Initialise the video system
	VIDEO_Init();
	
	// This function initialises the attached controllers
	WPAD_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();
	if(usb_isgeckoalive(1))CON_EnableGecko(1, 1);

	log_buffer = (char*)malloc(0x4000);
	memset(log_buffer, 0, 0x4000);

	printf("Initializing WC24...\n");
	retval = WC24_Init();
	if(retval<0)
	{
		printf("WC24_Init returned %d\n", retval);
		return retval;
	}
	curtitleid = WC24_GetTitleID();

	printf("\n\n");
	printf("Getting NANDBOOTINFO argv...\n");
	argv = WII_GetNANDBootInfoArgv(&argc, &launchcode);
	#ifdef WIILOADAPPDEBUG
		#ifdef WIILOADTEST_BOOTDISC	
		argc = 1;
		launchcode = 2;
		#endif

		#ifdef WIILOADTEST_BOOTHB	
		launchcode = 1;
		argc = 2;
		argv[1] = WIILOADTEST_BOOTHB;
		#endif
	#endif

	ResetWakeup_Timestamp();
	#ifndef WIILOADAPPDEBUG
	retval = ProcessWC24(launchcode & BIT(25));//Don't do any WC24 stuff with HBC wiiload, only with the actual installed wc24boottitle.
	#endif
	launchcode &= ~(BIT(25));
	ProcessArgs(argc, argv, 0);
	printf("Shutting down WC24...\n");
	WC24_Shutdown();
	FlushLog();

	return 0;
}
示例#7
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* Initialise Video
*
* Before doing anything in libogc, it's recommended to configure a video
* output.
****************************************************************************/
static void
Initialise (void)
{
	VIDEO_Init ();		/*** ALWAYS CALL FIRST IN ANY LIBOGC PROJECT!
				     Not only does it initialise the video
				     subsystem, but also sets up the ogc os
				***/

	PAD_Init ();			/*** Initialise pads for input ***/
#ifdef HW_RVL
	WPAD_Init ();
#endif

	// get default video mode
	vmode = VIDEO_GetPreferredMode(NULL);

	switch (vmode->viTVMode >> 2)
	{
	case VI_PAL:
		// 576 lines (PAL 50Hz)
		// display should be centered vertically (borders)
		//Make all video modes the same size so menus doesn't screw up
		vmode = &TVPal576IntDfScale;
		vmode->xfbHeight = 480;
		vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
		vmode->viHeight = 480;

		vmode_60hz = 0;
		break;

	case VI_NTSC:
		// 480 lines (NTSC 60hz)
		vmode_60hz = 1;
		break;

	default:
		// 480 lines (PAL 60Hz)
		vmode_60hz = 1;
		break;
	}

#ifdef HW_DOL
	/* we have component cables, but the preferred mode is interlaced
	 * why don't we switch into progressive?
	 * (user may not have progressive compatible display but component input)
	 * on the Wii, the user can do this themselves on their Wii Settings */
	if(VIDEO_HaveComponentCable())
		vmode = &TVNtsc480Prog;
#endif

	/*	// check for progressive scan // bool progressive = FALSE;
		if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
			progressive = true;
	*/

#ifdef HW_RVL
	// widescreen fix
	if(CONF_GetAspectRatio())
	{
		vmode->viWidth = 678;
		vmode->viXOrigin = (VI_MAX_WIDTH_PAL - 678) / 2;
	}
#endif

	// configure VI
	VIDEO_Configure (vmode);

	// always 480 lines /*** Update screen height for font engine ***/
	screenheight = vmode->xfbHeight;

	/*** Now configure the framebuffer.
	     Really a framebuffer is just a chunk of memory
	     to hold the display line by line.
	***/
	// Allocate the video buffers
	xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
	/*** I prefer also to have a second buffer for double-buffering.
	     This is not needed for the console demo.
	***/
	xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));

	/*** Define a console ***/
	console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);

	/*** Clear framebuffer to black ***/
	VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
	VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);

	/*** Set the framebuffer to be displayed at next VBlank ***/
	VIDEO_SetNextFramebuffer (xfb[0]);

	/*** Get the PAD status updated by libogc ***/
	VIDEO_SetPostRetraceCallback (updatePAD);
	VIDEO_SetBlack (0);

	/*** Update the video for next vblank ***/
	VIDEO_Flush ();

	VIDEO_WaitVSync ();		/*** Wait for VBL ***/
	if (vmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync ();

}
示例#8
0
void GC_SetVideoMode(u8 videomode, DML_CFG *BooterCFG, u8 DM_Patch)
{
	syssram *sram;
	sram = __SYS_LockSram();
	static GXRModeObj *rmode;
	int memflag = 0;

	if((VIDEO_HaveComponentCable() && (CONF_GetProgressiveScan() > 0)) || videomode > 3)
		sram->flags |= 0x80; //set progressive flag
	else
		sram->flags &= 0x7F; //clear progressive flag

	if(videomode == 1 || videomode == 3 || videomode == 5)
	{
		memflag = 1;
		sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL
		sram->ntd |= 0x40; //set pal60 flag
	}
	else
	{
		sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC
		sram->ntd &= 0xBF; //clear pal60 flag
	}

	if(videomode == 1)
	{
		if(DM_Patch == VIDEO_PATCH_FORCE)
			BooterCFG->VideoMode |= DML_VID_FORCE_PAL50;
		rmode = &TVPal528IntDf;
	}
	else if(videomode == 2)
	{
		if(DM_Patch == VIDEO_PATCH_FORCE)
			BooterCFG->VideoMode |= DML_VID_FORCE_NTSC;
		rmode = &TVNtsc480IntDf;
	}
	else if(videomode == 3)
	{
		if(DM_Patch == VIDEO_PATCH_FORCE)
			BooterCFG->VideoMode |= DML_VID_FORCE_PAL60;
		rmode = &TVEurgb60Hz480IntDf;
		memflag = 5;
	}
	else if(videomode == 4 ||videomode == 6)
	{
		if(DM_Patch == VIDEO_PATCH_FORCE)
			BooterCFG->VideoMode |= DML_VID_FORCE_PROG;
		rmode = &TVNtsc480Prog;
	}
	else if(videomode == 5 || videomode == 7)
	{
		if(DM_Patch == VIDEO_PATCH_FORCE)
			BooterCFG->VideoMode |= DML_VID_FORCE_PROG;
		rmode = &TVEurgb60Hz480Prog;
		memflag = 5;
	}

	__SYS_UnlockSram(1); // 1 -> write changes
	while(!__SYS_SyncSram());

	/* Set video mode register */
	*(vu32 *)0x800000CC = memflag;
	DCFlushRange((void *)(0x800000CC), 4);

	/* Set video mode */
	if (rmode != 0)
		VIDEO_Configure(rmode);

	/* Setup video  */
	VIDEO_SetBlack(TRUE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();
}
示例#9
0
文件: template.c 项目: pomali/wii
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	// Initialise the video system
	VIDEO_Init();
	
	// This function initialises the attached controllers
	WPAD_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();


	// 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");

	while(1) {
		
		// Call WPAD_ScanPads each loop, this reads the latest controller states
		WPAD_ScanPads();
		
		// WPAD_ButtonsDown tells us which buttons were pressed in this loop
		// this is a "one shot" state which will not fire again until the button has been released
		u32 pressed = WPAD_ButtonsDown(0);

		// We return to the launcher application via exit
		if ( pressed & WPAD_BUTTON_HOME ) exit(0);

		// Wait for the next frame
		VIDEO_WaitVSync();
	}

	return 0;
}
//---------------------------------------------------------------------------------
int main( int argc, char **argv ){
//---------------------------------------------------------------------------------
	f32 yscale;

	u32 xfbHeight;

	Mtx	view;
	Mtx44 perspective;

	u32	fb = 0; 	// initial framebuffer index
	GXColor background = {0, 0, 0, 0xff};


	// init the vi.
	VIDEO_Init();
	WPAD_Init();
 
	rmode = VIDEO_GetPreferredMode(NULL);
	
	// allocate 2 framebuffers for double buffering
	frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(frameBuffer[fb]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	// setup the fifo and then init the flipper
	void *gp_fifo = NULL;
	gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);
	memset(gp_fifo,0,DEFAULT_FIFO_SIZE);
 
	GX_Init(gp_fifo,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));
 
	GX_SetCullMode(GX_CULL_NONE);
	GX_CopyDisp(frameBuffer[fb],GX_TRUE);
	GX_SetDispCopyGamma(GX_GM_1_0);
 
	// setup our camera at the origin
	// looking down the -z axis with y up
	guVector cam = {0.0F, 0.0F, 0.0F},
			up = {0.0F, 1.0F, 0.0F},
		  look = {0.0F, 0.0F, -1.0F};
	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);
 
	while(1) {

		WPAD_ScanPads();

		if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);

		// do this before drawing
		GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);


		// do this stuff after drawing
		GX_DrawDone();
		
		fb ^= 1;		// flip framebuffer
		GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
		GX_SetColorUpdate(GX_TRUE);
		GX_CopyDisp(frameBuffer[fb],GX_TRUE);

		VIDEO_SetNextFramebuffer(frameBuffer[fb]);
 
		VIDEO_Flush();
 
		VIDEO_WaitVSync();


	}
	return 0;
}
示例#11
0
文件: main.c 项目: suloku/dolaunch
//---------------------------------------------------------------------------------
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);
	
	int slot = CARD_SLOTA;
	u32 i;
	int tomenu = 0;
	u16 buttonsDown;
	u8 pressed = 0;
	int filesize;
	int bytesdone = 0;
	
	while(1){
		VIDEO_ClearFrameBuffer (rmode, xfb, COLOR_BLACK);
		listpos=0;
		tomenu=0;
		pressed = 0;
		printf("\x1b[2;0H");
		printf("Memory Card Loader 0.2 by Suloku\n");
		printf("********************************\n\n");
		printf("Press A or B button to select a slot.\n");
		while (1){
			PAD_ScanPads();
			buttonsDown=PAD_ButtonsDown(0);
			if (buttonsDown & PAD_BUTTON_A){ slot = CARD_SLOTA; pressed = 1;}
			if (buttonsDown & PAD_BUTTON_B){ slot = CARD_SLOTB; pressed = 1;}
			if (buttonsDown & PAD_BUTTON_START){ PSOreload();}
			VIDEO_WaitVSync();
			if (pressed) break;
		}
		printf("Mounting card in slot %s...", (slot==0?"A":"B"));
		
		int Slot_error = MountCard(slot);
		printf("code %d. ",Slot_error);

		int CardError;
		
		if (Slot_error >= 0) {
			printf("Sector size is %d bytes.\n",sectsize);
			printf("Reading memory card files...");

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

			cardcount = 0;
			while ( CARD_ERROR_NOFILE != CardError ) {
				if (strncmp ("DOLX", (char *)CardDir.gamecode, 4)  ==  0){
					memcpy (&CardList[cardcount], &CardDir, sizeof (card_dir));
					cardcount++;
				}
				CardError = CARD_FindNext(&CardDir);
			}
			printf("finished.\n\n");
			
			if (cardcount == 0){
				printf("No dol files in memory card in slot %s\n\n", (slot==0?"A":"B"));
				waitA();
			}else{
				while (1){
					pressed = 0;
					VIDEO_ClearFrameBuffer (rmode, xfb, COLOR_BLACK);
					printf("\x1b[2;0H");
					printf("Memory Card Loader 0.1 by Suloku\n");
					printf("********************************\n\n");
					printf("Dol files in memory card %s: %d\n\n", (slot==0?"A":"B"), cardcount);
					
					if (listpos!=0) printf ("/\\/\\\n");
					else printf("    \n");
					
					for (i=listpos; i<listpos+10; i++){
						printf ("    ");
						if (i==listpos) printf ("-->");
						printf("%s                    \n",CardList[i].filename);
						if (i>= cardcount )break;
					}
					printf("\x1b[18;0H");
					if (cardcount >=10 && listpos != cardcount-1) printf ("\\/\\/\n");
					else{
						printf("    \n");
					}
					printf("\n\t\tPress B button to go back to slot select.\n\n");

					while (1){
						PAD_ScanPads();
						buttonsDown=PAD_ButtonsDown(0);
						if (buttonsDown & PAD_BUTTON_UP){
							listpos--;
							if (listpos <0) listpos = 0;
							pressed = 1;
						}
						if (buttonsDown & PAD_BUTTON_DOWN){
							listpos++;
							if (listpos >= cardcount-1) listpos = cardcount-1;
							pressed = 1;
						}
						if (buttonsDown & PAD_BUTTON_LEFT){
							listpos-=10;
							if (listpos <0) listpos = 0;
							pressed = 1;
						}
						if (buttonsDown & PAD_BUTTON_RIGHT){
							listpos+=10;
							if (listpos >= cardcount-1) listpos = cardcount-1;
							pressed = 1;
						}
						if (buttonsDown & PAD_BUTTON_A){
							printf("Loading %s...\n", CardList[listpos].filename);
							/*** Initialise for this company & gamecode ***/
							//add null char
							company[2] = gamecode[4] = 0;
							memcpy (company, &CardList[listpos].company, 2);
							memcpy (gamecode, &CardList[listpos].gamecode, 4);							
							CARD_SetCompany(company);
							CARD_SetGamecode(gamecode);
							CardError = CARD_Open(slot ,(char*)&CardList[listpos].filename,&CardFile);
							if (CardError < 0)
							{
									CARD_Unmount (slot);
									printf("Error %d while opening file.\n", CardError);
									waitA();
									
							}else{
								/*** Copy the file contents to the buffer ***/
								filesize = CardFile.len;
								u8 *dolbuffer = (u8*) memalign(32, filesize);
								while (bytesdone < filesize)
								{
										CardError= CARD_Read(&CardFile, dolbuffer+bytesdone, sectsize, bytesdone);
										bytesdone += sectsize;
								}
								CARD_Close(&CardFile);
								CARD_Unmount(slot);
							//boot dol
								//This will load cli_buffer and cli_size
								getclifrombuffer(dolbuffer, filesize);
								if (cli_buffer!=NULL){
									// Build a command line to pass to the DOL
									int argc2 = 0;
									char *argv2[1024];
									//add a terminating null character for last argument if needed
									if (cli_buffer[cli_size-1] != '\0'){
										cli_buffer[cli_size] = '\0';
										cli_size += 1;
									}

									// CLI parse
									char bootpath[CARD_FILENAMELEN+10];
									sprintf(bootpath, "mc%d:/%s", slot, (char*)&CardList[listpos].filename);
									argv2[argc2] = bootpath;
									argc2++;
									// First argument is at the beginning of the file
									if(cli_buffer[0] != '\r' && cli_buffer[0] != '\n') {
										argv2[argc2] = cli_buffer;
										argc2++;
									}
									// Search for the others after each newline
									int i;
									for(i = 0; i < cli_size; i++) {
										if(cli_buffer[i] == '\r' || cli_buffer[i] == '\n') {
											cli_buffer[i] = '\0';
										}
										else if(cli_buffer[i - 1] == '\0') {
											argv2[argc2] = cli_buffer + i;
											argc2++;

											if(argc2 >= 1024)
												break;
										}
									}
									DOLtoARAM(dolbuffer, argc2, argc2 == 0 ? NULL : argv2);
								}else{
									DOLtoARAM(dolbuffer, 0, NULL);
								}

								//If we get here dol was invalid
								if(dolbuffer != NULL) free(dolbuffer);
								printf("Not a valid dol file.\n");
								waitA();
								tomenu = 1;
							}
							pressed = 1;
						}
						if (buttonsDown & PAD_BUTTON_B){ pressed = 1;tomenu=1;}
						if (buttonsDown & PAD_BUTTON_START){ PSOreload();}
						VIDEO_WaitVSync();
						if (pressed) break;
					}
					if (tomenu) break;
				}
			}
			CARD_Unmount(slot);
		}else{
			printf("\n\nCan't mount card in slot %s!\n", (slot==0?"A":"B"));
			waitA();
		}
	}
	return 0;
}
示例#12
0
文件: menu.c 项目: bogger33/gnuboy-gx
void MainMenu ()
{
  s8 ret;
  u8 quit = 0;
  menu = 0;
#ifdef HW_RVL
  u8 count = 6;
  char items[6][20] =
#else
  u8 count = 5;
  char items[5][20] =
#endif
  {
    {"Play Game"},
    {"Hard Reset"},
    {"Load New Game"},
    {"Emulator Options"},
#ifdef HW_RVL
    {"Return to Loader"},
#endif
    {"System Reboot"}
  };

  /* 50 hz TV mode */
  if (gc_pal)
  {
    VIDEO_Configure (vmode);
    VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    VIDEO_WaitVSync();
  }

  /* autosave (SRAM only) */
  int temp = config.freeze_auto;
  config.freeze_auto = -1;
  memfile_autosave();
  config.freeze_auto = temp;

  
  while (quit == 0)
  {
    strcpy (menutitle, "Version 1.04.2");  
    ret = DoMenu (&items[0], count);

    switch (ret)
    {
      case -1: /*** Button B ***/
      case 0:  /*** Play Game ***/
        quit = 1;
        break;

      case 1:
        emu_reset();
        quit = 1;
        break;
 
      case 2:  /*** Load ROM Menu ***/
        quit = loadmenu();
        break;

      case 3:  /*** Emulator Options */
        Emu_options();
        break;

      case 4:  /*** SD/PSO/TP Reload ***/
        memfile_autosave();
        VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
        VIDEO_Flush();
        VIDEO_WaitVSync();
#ifdef HW_RVL
        DI_Close();
        exit(0);
        break;

      case 5:  /*** Return to Wii System Menu ***/
        memfile_autosave();
        VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
        VIDEO_Flush();
        VIDEO_WaitVSync();
        DI_Close();
        SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
#else
        SYS_ResetSystem(SYS_HOTRESET,0,0);
#endif
        break;
    }
  }
  
  /*** Remove any still held buttons ***/
  while (PAD_ButtonsHeld(0)) PAD_ScanPads();
#ifdef HW_RVL
  while (WPAD_ButtonsHeld(0)) WPAD_ScanPads();
#endif

  /*** Restore fullscreen 50hz ***/
  if (gc_pal)
  {
    extern GXRModeObj TV50hz_576i;
    GXRModeObj *rmode = &TV50hz_576i;
    Mtx p;

    rmode->xfbHeight = 574;
    rmode->viYOrigin = 0;
    rmode->viHeight = 574;
    VIDEO_Configure (rmode);
    VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    VIDEO_WaitVSync();

    /* reset rendering mode */
    GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F);
    GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight);
    f32 yScale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight);
    u16 xfbHeight = GX_SetDispCopyYScale (yScale);
    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));
    GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
    guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000);
    GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);

  }

#ifndef HW_RVL
  /*** Stop the DVD from causing clicks while playing ***/
  uselessinquiry ();
#endif
}
示例#13
0
static int drawgx_window_create(sdl_window_info *window, int width, int height)
{
    sdl_info *sdl = window->dxdata;
    u32 xfbHeight;
    f32 yscale;
    Mtx44 perspective;
    Mtx GXmodelView2D;
    GXColor background = {0, 0, 0, 0xff};
    currfb = 0;
    // allocate memory for our structures
    sdl = malloc(sizeof(*sdl));
    memset(sdl, 0, sizeof(*sdl));

    window->dxdata = sdl;

    sdl->scale_mode = &scale_modes[window->scale_mode];

    sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);

    sdl->extra_flags |= sdl->scale_mode->extra_flags;

    /*sdl->sdlsurf = SDL_SetVideoMode(width, height,
    			   0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);*/
    //sdl->sdlsurf = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);

    //if (!sdl->sdlsurf)
    //	return 1;

    window->width = gx_screenWidth();//sdl->sdlsurf->w;
    window->height = 480;//sdl->sdlsurf->h;

    sdl->safe_hofs = (window->width - window->width * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2;
    sdl->safe_vofs = (window->height - window->height * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2;

    /*if (sdl->scale_mode->is_yuv)
    	yuv_overlay_init(window);*/

    sdl->yuv_lookup = NULL;
    sdl->blittimer = 0;

    //if (is_inited) return 0;
    //is_inited = 1;
    //drawgx_yuv_init(sdl);
    //SDL_QuitSubSystem(SDL_INIT_VIDEO);
    if (is_inited) return 0;

    is_inited = 1;

    VIDEO_Init();
    VIDEO_SetBlack(true);
    vmode = VIDEO_GetPreferredMode(NULL);

    switch (vmode->viTVMode >> 2)
    {
    case VI_PAL:
        vmode = &TVPal574IntDfScale;
        vmode->xfbHeight = 480;
        vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
        vmode->viHeight = 480;
        break;

    case VI_NTSC:
        break;

    default:
        break;
    }

    VIDEO_Configure(vmode);

    xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
    xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

    VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
    VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);

    VIDEO_SetNextFramebuffer(xfb[currfb]);

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

    gp_fifo = memalign(32, DEFAULT_FIFO_SIZE);
    memset(gp_fifo, 0, DEFAULT_FIFO_SIZE);
    GX_Init(gp_fifo, DEFAULT_FIFO_SIZE);
    atexit(drawgx_shutdown);

    GX_SetCopyClear(background, 0x00ffffff);

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

    if (vmode->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(xfb[currfb],GX_TRUE);
    GX_SetDispCopyGamma(GX_GM_1_0);

    GX_SetNumChans(1);
    GX_SetNumTexGens(1);
    GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
    GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);

    GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
    GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
    GX_SetAlphaUpdate(GX_TRUE);
    GX_SetColorUpdate(GX_TRUE);

    guOrtho(perspective,0,479,0,gx_screenWidth()-1,0,300);
    GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC);

    guMtxIdentity(GXmodelView2D);
    guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -5.0F);
    GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);

    GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
    GX_InvVtxCache();
    GX_ClearVtxDesc();
    GX_InvalidateTexAll();

    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, 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_RGBA8, 0);

    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

    VIDEO_SetBlack(false);

    GX_InitTexObj(&blankTex, blanktex, 1, 1, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);

    return 0;
}
示例#14
0
void REV_init()
{
	//Local variables
	f32 yscale;
	u32 xfbHeight;
	//Load the right IOS, so keyboard works fin
	u32 iosVersion = IOS_GetVersion();
	if(iosVersion != 36)
	{
		IOS_ReloadIOS(36);
	}
	////
	VIDEO_Init();//Video Library Init
	PAD_Init();//Gamecube Pad Library Init
	WPAD_Init();//Wiimote Library Init
	rMode = VIDEO_GetPreferredMode(NULL);//Set render mode
	// allocate 2 framebuffers for double buffering
	frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode));
	frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode));
	//Configure Video System
	VIDEO_Configure(rMode);
	VIDEO_SetNextFramebuffer(frameBuffer[fb]);//Initial Framebuffer
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rMode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	fb ^= 1;//Set next index
	//Set up the FIFO
	void *gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);//Allocate
	memset(gp_fifo,0,DEFAULT_FIFO_SIZE);//and Clear
	//Init GX hardware
	GX_Init(gp_fifo,DEFAULT_FIFO_SIZE);
	// clears the bg to color and clears the z buffer
	GX_SetCopyClear(DEF_BG_COLOR , 0x00ffffff);
	//More initialization
	w = rMode->viWidth;
    h = rMode->viHeight;
	
	yscale = GX_GetYScaleFactor(rMode->efbHeight,rMode->xfbHeight);
	xfbHeight = GX_SetDispCopyYScale(yscale);
	GX_SetDispCopySrc(0,0,rMode->fbWidth,rMode->efbHeight);
	GX_SetDispCopyDst(rMode->fbWidth,xfbHeight);
	GX_SetFieldMode(rMode->field_rendering,((h==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_CopyDisp(frameBuffer[fb],GX_TRUE);
	GX_SetDispCopyGamma(GX_GM_1_0);
	
	for(u8 i = 0; i < 4; i++)
	WPAD_SetVRes(i,w,h);
	
	//Hardware Initialized, now engine initialization
	//Init filesystem
	fatInitDefault();
	//First create a Root
	mainRoot = new ROOT;
	mainRoot->init((f32)w,(f32)h);
	GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
	GX_SetColorUpdate(GX_ENABLE);
	GX_SetAlphaUpdate(GX_ENABLE);
	GX_SetZCompLoc(GX_TRUE);
	GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
	init3dConfig();
	init2dConfig();
	init2D(w, h);
	transQueue = NULL;
	solidQueue = NULL;
	zQueue = NULL;
	REV_fontsInit();
	KEYBOARD_Init(NULL);
	keyboardInit();
}
示例#15
0
void REV_process(tMapQ3 * map)
{
	//Variables
	f32 preWait = 0, postWait = 0;
	static u8 firstFrame = 1;
	TRACKER * auxT;
	setUp3D();
	//Wait just before drawing (instead of after), this should enhance performance
	VIDEO_Flush();
	preWait = (f32)(ticks_to_millisecs(gettime()));
 	VIDEO_WaitVSync();
	postWait = (f32)(ticks_to_millisecs(gettime()));
	GPUWaitTime = 0.001f * (postWait - preWait);
	//Update physics
	updatePhysics();
	setBGColor(SC_BLUE);
	//Clasify objects into solid or transparent queues
	//This is done before everything else because this clasification is the same for every viewport
	clasify3D(mainRoot->rootNode);
	//Now we use the clasified queues to render shadows
	//if(mainRoot->shadowCaster)
		//mainRoot->shadowScene();
	//Render each Viewport into it's texture
	GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
	//GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
	std::multimap<CAMERA*, TRender2Texture*>::iterator iter = mainRoot->m_Render2Textures.begin();
	for(;iter != mainRoot->m_Render2Textures.end(); ++iter)
	{
		(*iter).second->setForRender(perspective);
		(*iter).second->getCamera()->setForRender(view);
		//Before rendering the scene, render the skyBox
		GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);
		mainRoot->skyBox.render((*iter).second->getCamera());
		GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
		//Now render the map
		//GX_LoadPosMtxImm(view, GX_PNMTX0);
		//if(map)
			//renderQ3Map(tTex->cam->getPos(), map);
		//Now render objects
		GX_SetCullMode(GX_CULL_NONE);
		auxT = solidQueue;
		while(auxT)
		{
			render(auxT->target, (*iter).second->getCamera()->getPos());
			auxT = auxT->next;
		}
		orderQueue((*iter).second->getCamera());
		auxT = transQueue;
		while(auxT)
		{
			render(auxT->target, (*iter).second->getCamera()->getPos());
			auxT = auxT->next;
		}
		//Copy the embeded frame buffer to the texture
		(*iter).second->copyTexture();
	}
	while(solidQueue)
	{
		auxT = solidQueue;
		solidQueue = solidQueue->next;
		free(auxT);
	}
	while(transQueue)
	{
		auxT = transQueue;
		transQueue = transQueue->next;
		free(auxT);
	}
	setBGColor(SC_WHITE);
	//2D System
	//GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);
	GX_SetCopyFilter(rMode->aa,rMode->sample_pattern,GX_TRUE,rMode->vfilter);
	GX_SetViewport(0,0, w, h,0,1);
	GX_SetScissor(0,0, w, h);
	guOrtho(perspective,0,h,0,w, 1.0,100.0);
	GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC);
	GX_SetCullMode(GX_CULL_NONE);
	setUp2D();
	parse2D(mainRoot->rootN2D);
	order2D();
	render2D();
	GX_DrawDone();
	
	GX_CopyDisp(frameBuffer[fb],GX_TRUE);
	VIDEO_SetNextFramebuffer(frameBuffer[fb]);
	
	//Set out black screen after first frame
	if(firstFrame)
	{
		firstFrame = 0;
		VIDEO_SetBlack(FALSE);
	}
	
	fb ^= 1;
}
示例#16
0
int main (int argc, char **argv) {

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

	sys_rmode = VIDEO_GetPreferredMode(NULL);

	sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));
	sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));

	sys_frame_count = 0;

	CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(sys_rmode);
	VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(sys_rmode->viTVMode & VI_NON_INTERLACE)
	{
		VIDEO_WaitVSync();
	};

	sys_frame_count++;

	GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]);

	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight);

	if(!fatInitDefault())
	{
		Sys_Error("Filesystem not enabled");
	};

	sys_previous_time = Sys_Milliseconds();
	do 
	{
		sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true);
	} while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000));
	if(sys_netinit_error < 0)
	{
		printf("Network not enabled\n");
	};

	if (KEYBOARD_Init(Sys_KeyPress) != 0)
	{
		printf("Keyboard not found\n");
	};

	OSK_LoadKeys(Keys_dat, Keys_dat_size);

	int   len, i;
	char  *cmdline;

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++)
	{
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}

	Com_Init(cmdline);

	WPAD_SetPowerButtonCallback(Sys_PowerOff);

	while (1) {

		sys_previous_time = Sys_Milliseconds();
		if(MOUSE_IsConnected())
		{
			sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event);
			if(sys_mouse_valid)	MOUSE_FlushEvents();
		}
		else
		{
			sys_mouse_valid = 0;
			sys_mouse_event.button = 0;
		};

		Com_Frame( );

		if(in_osk->value)
		{
			OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]);
		};
		sys_frame_count++;
		GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]);

		KEYBOARD_FlushEvents();
		VIDEO_Flush();
		VIDEO_WaitVSync();

	}
	return 0;
}
示例#17
0
int main(int argc, char **argv) {
	jobs = new RSS_Job[0];
	ijobs = 0;
	// Initialise the video system
	VIDEO_Init();
		
	//Get Language
	lang = CONF_GetLanguage();

	// This function initialises the attached controllers
	WPAD_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();

	printf("\x1b[2;0H");
	if (LANG_GER) printf("Willkommen bei rssmii!\n\n");
	else printf("Welcome to rssmii!\n\n");

	int retval = load_feeds();
	if (retval != 0)
	{
		fail(retval);
	}

	if(LANG_GER) printf("Die folgenden RSS-Feeds wurden von der SD-Karte gelesen und werden abonniert und alle vorherigen Abonnements werden geloescht:\n");
	else printf("The following RSS-Feeds were read from the SD-Card and you will subscribe to them while all previous subscriptions will be deleted:\n");
	for (int i = 0; i < ijobs; i++)
	{
		printf("   %s\n", jobs[i].name);
	}

	if (LANG_GER) printf("\n\nSind sie sicher? (A: Fortsetzen; HOME: Abbrechen)");
	else printf("\n\nAre you sure? (A: Continue; HOME: Abort");

	while (1)
	{
		WPAD_ScanPads();
		if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) end();
		if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) break;
	}

	AddJobs();

	//printf("\n\nDone.");
	if (LANG_GER) printf("\nMit HOME zurueck zum Loader.");
	else printf("\nGet back to the Loader with the HOME-Button.");

	while (1)
	{
		WPAD_ScanPads();
		if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
	}
	end();
	//return 0;
}
示例#18
0
文件: config.c 项目: kidaa/Provenance
void config_default(void)
{
  /* version TAG */
  strncpy(config.version,CONFIG_VERSION,16);

  /* sound options */
  config.psg_preamp     = 150;
  config.fm_preamp      = 100;
  config.hq_fm          = 1;
  config.psgBoostNoise  = 1;
  config.filter         = 1;
  config.lp_range       = 0x9999; /* 0.6 in 16.16 fixed point */
  config.low_freq       = 880;
  config.high_freq      = 5000;
  config.lg             = 1.0;
  config.mg             = 1.0;
  config.hg             = 1.0;
  config.dac_bits       = 14;
  config.ym2413         = 2; /* AUTO */
  config.mono           = 0;

  /* system options */
  config.system         = 0; /* AUTO */
  config.region_detect  = 0; /* AUTO */
  config.vdp_mode       = 0; /* AUTO */
  config.master_clock   = 0; /* AUTO */
  config.force_dtack    = 0;
  config.addr_error     = 1;
  config.bios           = 0;
  config.lock_on        = 0;
  config.hot_swap       = 0;

  /* video options */
  config.xshift   = 0;
  config.yshift   = 0;
  config.xscale   = 0;
  config.yscale   = 0;
  config.aspect   = 1;
  config.overscan = 3; /* FULL */
  config.gg_extra = 0;
  config.ntsc     = 0;
  config.vsync    = 1; /* AUTO */
  config.bilinear = 1;
  config.vfilter  = 1;

  if (VIDEO_HaveComponentCable())
  {
    config.render = 2;
  }
  else
  {
    config.render = 0;
  }

  switch (vmode->viTVMode >> 2)
  {
    case VI_PAL:
      config.tv_mode = 1; /* 50hz only */
      break;

    case VI_EURGB60:
      config.tv_mode = 2; /* 50/60hz */
      break;
    
    default:
      config.tv_mode = 0; /* 60hz only */
      break;
  }

#ifdef HW_RVL
  config.trap = 0;
  config.gamma = VI_GM_1_0 / 10.0;
#endif

  /* controllers options */
  config.gun_cursor[0]  = 1;
  config.gun_cursor[1]  = 1;
  config.invert_mouse   = 0;

  /* on-screen options */
  config.cd_leds = 0;

  /* menu options */
  config.autoload     = 0;
  config.autocheat    = 0;
#ifdef HW_RVL
  config.s_auto       = 1;
#else
  config.s_auto       = 0;
  config.v_prog       = 1;
#endif
  config.s_default    = 1;
  config.s_device     = 0;
  config.l_device     = 0;
  config.bg_overlay   = 0;
  config.screen_w     = 658;
  config.bgm_volume   = 100.0;
  config.sfx_volume   = 100.0;

  /* default ROM directories */
#ifdef HW_RVL
  sprintf (config.lastdir[0][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
#else
  sprintf (config.lastdir[0][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
#endif

  /* try to restore user config */
  int loaded = config_load();

#ifndef HW_RVL
  /* detect progressive mode enable/disable requests */
  PAD_ScanPads();
  if (PAD_ButtonsHeld(0) & PAD_BUTTON_B)
  {
    /* swap progressive mode enable flag and play some sound to inform user */
    config.v_prog ^= 1;
    ASND_Pause(0);
    int voice = ASND_GetFirstUnusedVoice();
    ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL);
    sleep (2);
    ASND_Pause(1);
  }

  /* switch into 480p if component cable has been detected and progressive mode is enabled */
  if (VIDEO_HaveComponentCable() && config.v_prog)
  {
    vmode = &TVNtsc480Prog;
    VIDEO_Configure (vmode);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    VIDEO_WaitVSync();
  }
#endif

  /* inform user if default config is used */
  if (!loaded)
  {
    GUI_WaitPrompt("Warning","Default Settings restored");
    gx_input_SetDefault();
  }

  /* default emulated inputs */
  input.system[0] = SYSTEM_MD_GAMEPAD;
  input.system[1] = (config.input[1].device != -1) ? SYSTEM_MD_GAMEPAD : NO_SYSTEM;
  input_init();
}
示例#19
0
int main()
{
	void *xfb;
	GXRModeObj *rmode;
	lwp_t handle;
	int r;
	char *stack;

	IOS_ReloadIOS(30);

	VIDEO_Init();

	switch(VIDEO_GetCurrentTvMode())
	{
		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 1
	printf("Calling main()\n");
	main_real();
	printf("main() returned\n");
#else
	printf("Creating main thread\n");

	stack = malloc(1024*1024);
	if (stack == 0)
	{
		printf("Unable to allocate stack\n");
		while(1);
	}

	handle = 0;
	r = LWP_CreateThread(&handle, main_real, 0, stack, 1024*1024, 50);
	if (r != 0)
	{
		printf("Failed to create thread\n");
		while(1);
	}
	printf("Main thread created\n");
	LWP_SetThreadPriority(0, 0);

	printf("Looping\n");
	while(1);
#endif
}
示例#20
0
文件: video.c 项目: MANICX100/wiimc
void
InitVideo ()
{
	VIDEO_Init();
	vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
	
	bool pal = false;

	if (vmode == &TVPal528IntDf)
		pal = true;

	if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
	{
		vmode->fbWidth = 640;
		vmode->efbHeight = 456;
		vmode->viWidth = 686;

		if (pal)
		{
			vmode->xfbHeight = 542;
			vmode->viHeight = 542;
		}
		else
		{
			vmode->xfbHeight = 456;
			vmode->viHeight = 456;
		}
	}
	else
	{
		if (pal)
			vmode = &TVPal574IntDfScale;

		vmode->viWidth = 672;
	}

	if (pal)
	{
		vmode->viXOrigin = (VI_MAX_WIDTH_PAL - vmode->viWidth) / 2;
		vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - vmode->viHeight) / 2;
	}
	else
	{
		vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth) / 2;
		vmode->viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode->viHeight) / 2;
	}

	VIDEO_Configure (vmode);

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

	// 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 :)
}
示例#21
0
void config_default(void)
{
  /* version TAG */
  strncpy(config.version,CONFIG_VERSION,16);

  /* sound options */
  config.psg_preamp     = 150;
  config.fm_preamp      = 100;
  config.hq_fm          = 1;
  config.psgBoostNoise  = 1;
  config.filter         = 1;
  config.lp_range       = 0x9999; /* 0.6 in 16.16 fixed point */
  config.low_freq       = 880;
  config.high_freq      = 5000;
  config.lg             = 1.0;
  config.mg             = 1.0;
  config.hg             = 1.0;
  config.dac_bits       = 14;
  config.ym2413         = 2; /* AUTO */
  config.mono           = 0;

  /* system options */
  config.system         = 0; /* AUTO */
  config.region_detect  = 0; /* AUTO */
  config.vdp_mode       = 0; /* AUTO */
  config.master_clock   = 0; /* AUTO */
  config.force_dtack    = 0;
  config.addr_error     = 1;
  config.bios           = 0;
  config.lock_on        = 0;
  config.hot_swap       = 0;

  /* video options */
  config.xshift   = 0;
  config.yshift   = 0;
  config.xscale   = 0;
  config.yscale   = 0;
  config.aspect   = 1;
  config.overscan = 3; /* FULL */
  config.gg_extra = 0;
  config.lcd      = 0;
  config.ntsc     = 0;
  config.vsync    = 1; /* AUTO */
  config.bilinear = 0;
  config.vfilter  = 1;

  if (VIDEO_HaveComponentCable())
  {
    config.render = 2;
  }
  else
  {
    config.render = 0;
  }

  switch (vmode->viTVMode >> 2)
  {
    case VI_PAL:
      config.tv_mode = 1; /* 50hz only */
      break;

    case VI_EURGB60:
      config.tv_mode = 2; /* 50/60hz */
      break;
    
    default:
      config.tv_mode = 0; /* 60hz only */
      break;
  }

#ifdef HW_RVL
  config.trap = 0;
  config.gamma = VI_GM_1_0 / 10.0;
#else
  config.v_prog = 1;
#endif

  /* NTSC filter options */
  config.ntsc_sharpness   = 0.0;
  config.ntsc_resolution  = 0.0;
  config.ntsc_artifacts   = 0.0;
  config.ntsc_fringing    = 0.0;
  config.ntsc_bleed       = 0.0;

  /* controllers options */
  config.gun_cursor[0]  = 1;
  config.gun_cursor[1]  = 1;
  config.invert_mouse   = 0;

  /* on-screen options */
  config.cd_leds = 0;
  config.fps     = 0;

  /* menu options */
  config.autoload     = 0;
  config.autocheat    = 0;
  config.s_auto       = 1;
  config.s_default    = 1;
  config.s_device     = 0;
  config.bg_overlay   = 0;
  config.screen_w     = 658;
  config.bgm_volume   = 100.0;
  config.sfx_volume   = 100.0;
#ifdef HW_RVL
  config.autosleep    = 1;
  config.calx         = 0;
  config.caly         = 0;
#endif

  /* default ROM directories */
#ifdef HW_RVL
  DIR *dir = opendir("sd:/");
  if (dir)
  {
    config.l_device = TYPE_SD;
    closedir(dir);
  }
  else
  {
    config.l_device = TYPE_USB;
  }
  sprintf (config.lastdir[0][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_SD],  "sd:%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
#else
  config.l_device = TYPE_SD;
  sprintf (config.lastdir[0][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_SD],  "%s/roms/",  DEFAULT_PATH);
  sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
  sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH);
#endif

  /* system ROM paths */
  sprintf (config.sys_rom[0],   "%s/bios/bios_CD_U.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[1],   "%s/bios/bios_CD_E.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[2],   "%s/bios/bios_CD_J.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[3],   "%s/bios/bios_MD.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[4],   "%s/bios/bios_U.sms", DEFAULT_PATH);
  sprintf (config.sys_rom[5],   "%s/bios/bios_E.sms", DEFAULT_PATH);
  sprintf (config.sys_rom[6],   "%s/bios/bios_J.sms", DEFAULT_PATH);
  sprintf (config.sys_rom[7],   "%s/bios/bios.gg",  DEFAULT_PATH);
  sprintf (config.sys_rom[8],   "%s/lock-on/ggenie.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[9],   "%s/lock-on/areplay.bin", DEFAULT_PATH);
  sprintf (config.sys_rom[10],  "%s/lock-on/sk.bin",  DEFAULT_PATH);
  sprintf (config.sys_rom[11],  "%s/lock-on/sk2chip.bin", DEFAULT_PATH);

  /* try to restore user config */
  int loaded = config_load();
  
#ifdef HW_RVL
  /* initialize WPAD timeout */
  WPAD_SetIdleTimeout(config.autosleep ? 300 : 1800);
#else
  /* check if component cable was detected */
  if (VIDEO_HaveComponentCable())
  {
    /* when component cable is detected, libogc automatically enables progressive mode  */
    /* as preferred video mode but it could still be used on TV not supporting 480p/576p */
    PAD_ScanPads();

    /* detect progressive mode switch requests */
    if (PAD_ButtonsHeld(0) & PAD_BUTTON_B)
    {
      /* swap progressive mode enable flag */
      config.v_prog ^= 1;

      /* play some sound to inform user */
      ASND_Pause(0);
      int voice = ASND_GetFirstUnusedVoice();
      ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL);
      sleep (2);
      ASND_Pause(1);
    }

    /* check if progressive mode should be disabled */
    if (!config.v_prog)
    {
      /* switch menu video mode to interlaced */
      vmode->viTVMode = (vmode->viTVMode & ~3) | VI_INTERLACE;
      VIDEO_Configure(vmode);
      VIDEO_Flush();
      VIDEO_WaitVSync();
      VIDEO_WaitVSync();
    }
  }
#endif

  /* inform user if default config is used */
  if (!loaded)
  {
    GUI_WaitPrompt("Warning","Default Settings restored");
    gx_input_SetDefault();
  }

  /* default emulated inputs */
  input.system[0] = SYSTEM_GAMEPAD;
  input.system[1] = (config.input[1].device != -1) ? SYSTEM_GAMEPAD : NO_SYSTEM;
  input_init();
}
示例#22
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);
			
		}
	}

}
示例#23
0
int main(int argc,char **argv)
{
	f32 yscale;
	u32 xfbHeight;
	u32 fb = 0;
	u32 first_frame = 1;
	GXTexObj texture;
	Mtx view; // view and perspective matrices
	Mtx44 perspective;
	void *gpfifo = NULL;
	GXColor background = {0x00, 0x00, 0x00, 0xFF};
	guVector cam = {0.0F, 0.0F, 0.0F},
			up = {0.0F, 1.0F, 0.0F},
		  look = {0.0F, 0.0F, -1.0F};

	TPLFile cubeTPL;

	VIDEO_Init();
	PAD_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_NRM, 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_NRM, GX_NRM_XYZ, GX_F32, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGB, GX_RGB8, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);

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

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

    GX_InvVtxCache();
	GX_InvalidateTexAll();

	TPL_OpenTPLFromMemory(&cubeTPL, (void *)Cube_tpl,Cube_tpl_size);
	TPL_GetTexture(&cubeTPL,cube,&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);

	if (BuildLists(texture)) { // Build the display lists
		exit(1);        // Exit if failed.
	}

	while(1) {

		PAD_ScanPads();

		if ( PAD_ButtonsDown(0) & PAD_BUTTON_START) {
			exit(0);
		}

		u16 directions = PAD_ButtonsHeld(0);
		if ( directions & PAD_BUTTON_LEFT ) yrot += 0.5f;
		if ( directions & PAD_BUTTON_RIGHT ) yrot -= 0.5f;
		if ( yrot > 360.f ) yrot -= 360.f;
		if ( yrot < 0 ) yrot += 360.f;

		if ( directions & PAD_BUTTON_UP ) xrot -= 0.5f;
		if ( directions & PAD_BUTTON_DOWN ) xrot += 0.5f;
		if ( xrot > 360.f ) xrot -= 360.f;
		if ( xrot < 0 ) xrot += 360.f;

		if(first_frame) {
			first_frame = 0;
			VIDEO_SetBlack(FALSE);
		}

		// draw things	
		DrawScene(view);

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

		GX_DrawDone();

		VIDEO_SetNextFramebuffer(frameBuffer[fb]);
		VIDEO_Flush();
 		VIDEO_WaitVSync();
		fb ^= 1;
	}
}
示例#24
0
void Gui::draw()
{
//	printf("Gui draw\n");
	Input::getInstance().refreshInput();
	Cursor::getInstance().updateCursor();
	Focus::getInstance().updateFocus();
	if(padAutoAssign) auto_assign_controllers();
	//Update time??
	//Get graphics framework and pass to Frame draw fns?
	gfx->drawInit();
	drawBackground();
	FrameList::const_iterator iteration;
	for (iteration = frameList.begin(); iteration != frameList.end(); iteration++)
	{
		(*iteration)->updateTime(0.0f); //TODO: Pass deltaTime
		(*iteration)->drawChildren(*gfx);
	}
//	menuLogo->drawComponent(*gfx);
	menuLogo->draw(*gfx);
	if (MessageBox::getInstance().getActive()) MessageBox::getInstance().drawMessageBox(*gfx);
	if (LoadingBar::getInstance().getActive()) LoadingBar::getInstance().drawLoadingBar(*gfx);
	Cursor::getInstance().drawCursor(*gfx);

	if(shutdown)
	{
		Cursor::getInstance().setFreezeAction(true);
		Focus::getInstance().setFreezeAction(true);
		gfx->enableBlending(true);
		gfx->setTEV(GX_PASSCLR);
		gfx->setDepth(-10.0f);
		gfx->newModelView();
		gfx->loadModelView();
		gfx->loadOrthographic();

		gfx->setColor((GXColor){0, 0, 0, fade});
		if(screenMode)	gfx->fillRect(-104, 0, 848, 480);
		else			gfx->fillRect(0, 0, 640, 480);
		
		if(fade == 255)
		{
			VIDEO_SetBlack(true);
			VIDEO_Flush();
		 	VIDEO_WaitVSync();
			if(shutdown==1)	//Power off System
				SYS_ResetSystem(SYS_POWEROFF, 0, 0);
			else			//Return to Loader
			{
#ifdef WII
        if(dvd_hard_init) {
				  DI_Close();
			  }
#endif
				void (*rld)() = (void (*)()) 0x80001800;
				rld();
			}
		}

		char increment = 3;
		fade = fade +increment > 255 ? 255 : fade + increment;
	}

	gfx->swapBuffers();
}
示例#25
0
//---------------------------------------------------------------------------------
int main( int argc, char **argv ){
//---------------------------------------------------------------------------------
	u32	fb; 	// initial framebuffer index
	u32 first_frame;
	f32 yscale;
	u32 xfbHeight;
	Mtx44 perspective;
	Mtx GXmodelView2D;
	void *gp_fifo = NULL;

	GXColor background = {0, 0, 0, 0xff};

	int i;

	VIDEO_Init();
 
	rmode = VIDEO_GetPreferredMode(NULL);
	
	fb = 0;
	first_frame = 1;
	// allocate 2 framebuffers for double buffering
	frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(frameBuffer[fb]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	fb ^= 1;

	// setup the fifo and then init the flipper
	gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);
	memset(gp_fifo,0,DEFAULT_FIFO_SIZE);
 
	GX_Init(gp_fifo,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 descriptor
	// tells the flipper to expect direct data
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
	

	GX_SetNumChans(1);
	GX_SetNumTexGens(1);
	GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
	GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
	GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);


	GX_InvalidateTexAll();

	TPLFile spriteTPL;
	TPL_OpenTPLFromMemory(&spriteTPL, (void *)textures_tpl,textures_tpl_size);
	TPL_GetTexture(&spriteTPL,ballsprites,&texObj);

	GX_LoadTexObj(&texObj, GX_TEXMAP0);

	guOrtho(perspective,0,479,0,639,0,300);
	GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC);

	PAD_Init();

	srand(time(NULL));

	for(i = 0; i < NUM_SPRITES; i++) {
		//random place and speed
		sprites[i].x = (rand() % (640 - 32 )) << 8;
		sprites[i].y = (rand() % (480 - 32 )) << 8 ;
		sprites[i].dx = (rand() & 0xFF) + 0x100;
		sprites[i].dy = (rand() & 0xFF) + 0x100;
		sprites[i].image = rand() & 3;

		if(rand() & 1)
			sprites[i].dx = -sprites[i].dx;
		if(rand() & 1)
			sprites[i].dy = -sprites[i].dy;
	}

	GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
	guMtxIdentity(GXmodelView2D);
	guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -5.0F);
	GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);

	GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
	GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
	GX_SetAlphaUpdate(GX_TRUE);
	GX_SetColorUpdate(GX_TRUE);

	while(1) {

		PAD_ScanPads();

		if (PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);

		GX_InvVtxCache();
		GX_InvalidateTexAll();

		GX_ClearVtxDesc();
		GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
		GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);


		for(i = 0; i < NUM_SPRITES; i++) {
			sprites[i].x += sprites[i].dx;
			sprites[i].y += sprites[i].dy;
			
			//check for collision with the screen boundaries
			if(sprites[i].x < (1<<8) || sprites[i].x > ((640-32) << 8))
				sprites[i].dx = -sprites[i].dx;

			if(sprites[i].y < (1<<8) || sprites[i].y > ((480-32) << 8))
				sprites[i].dy = -sprites[i].dy;

			drawSpriteTex( sprites[i].x >> 8, sprites[i].y >> 8, 32, 32, sprites[i].image);
		}

		GX_DrawDone();
		
		GX_CopyDisp(frameBuffer[fb],GX_TRUE);

		VIDEO_SetNextFramebuffer(frameBuffer[fb]);
		if(first_frame) {
			VIDEO_SetBlack(FALSE);
			first_frame = 0;
		}
		VIDEO_Flush();
		VIDEO_WaitVSync();
		fb ^= 1;		// flip framebuffer
	}
	return 0;
}
示例#26
0
文件: menu.c 项目: perabuss/np2wii
load_entry wiimenu_choosefromlist(gamelistentry *gamesunk, gamelistentry *gamesfdd, gamelistentry *gameshdd, \
				  int* listcnt, load_entry* ent)
{
	int go = 1;
	int position = 0;
	int cur_off = 0;
	int i = 0;
	int eol = 0; //End of list
	int redraw = 1;
	int devnum = 0;
	int devtype = BASETYPE_HDD;
	char *devices[] = { "HDD0", "HDD1", "FDD0", "FDD1" };
	int sel[] = { -1, -1, -1, -1 };
	VIDEO_Flush();
	VIDEO_WaitVSync();
	while(go) {
		if(time_to_leave)
			break;
		WPAD_ScanPads();
		u32 WPAD_Pressed = WPAD_ButtonsDown(0);
		WPAD_Pressed	|= WPAD_ButtonsDown(1);
		WPAD_Pressed	|= WPAD_ButtonsDown(2);
		WPAD_Pressed	|= WPAD_ButtonsDown(3);
		
		if(WPAD_Pressed & WPAD_BUTTON_B){
			go = 0;
		}
		if(WPAD_Pressed & WPAD_BUTTON_1) {
			devnum++;
			devnum %= 4;
			switch(devnum) {
				case 0:
				case 1:
					devtype = BASETYPE_HDD;
					break;
				case 2:
				case 3:
					devtype = BASETYPE_FDD;
					break;
			}
			position = 0;
			cur_off = 0;
			i = 0;
			eol = 0;
			redraw = 1;
		}
		if(WPAD_Pressed & WPAD_BUTTON_A) {
			switch(devnum) {
				case 0:
					if(ent->hdd0 == NULL) {
						ent->hdd0  = calloc(256, 1);
					}
					if(ent->hdd0n != NULL) {
						free(ent->hdd0n);
					}
					sprintf(ent->hdd0, "sd:/PC98/ROMS/%s", gameshdd[position].path);
					ent->hdd0n = strdup(gameshdd[position].name);
					break;
				case 1:
					if(ent->hdd1 == NULL) {
						ent->hdd1  = calloc(256, 1);
					}
					if(ent->hdd1n != NULL) {
						free(ent->hdd1n);
					}
					sprintf(ent->hdd1, "sd:/PC98/ROMS/%s", gameshdd[position].path);
					ent->hdd1n = strdup(gameshdd[position].name);
					break;
				case 2:
					if(ent->fdd0 == NULL) {
						ent->fdd0  = calloc(256, 1);
					}
					if(ent->fdd0n != NULL) {
						free(ent->fdd0n);
					}
					sprintf(ent->fdd0, "sd:/PC98/ROMS/%s", gamesfdd[position].path);
					ent->fdd0n = strdup(gamesfdd[position].name);
					break;
				case 3:
					if(ent->fdd1 == NULL) {
						ent->fdd1  = calloc(256, 1);
					}
					if(ent->fdd1n != NULL) {
						free(ent->fdd1n);
					}
					sprintf(ent->fdd1, "sd:/PC98/ROMS/%s", gamesfdd[position].path);
					ent->fdd1n = strdup(gamesfdd[position].name);
					break;
			}
			sel[devnum] = position;
			redraw = 1;
		}
		if(WPAD_Pressed & WPAD_BUTTON_2) {
			switch(devnum) {
				case 0:
					if(ent->hdd0 != NULL) {
						free(ent->hdd0);
						ent->hdd0 = NULL;
					}
					if(ent->hdd0n != NULL) {
						free(ent->hdd0n);
						ent->hdd0n = NULL;
					}
					break;
				case 1:
					if(ent->hdd1 != NULL) {
						free(ent->hdd1);
						ent->hdd1 = NULL;
					}
					if(ent->hdd1n != NULL) {
						free(ent->hdd1n);
						ent->hdd1n = NULL;
					}
					break;
				case 2:
					if(ent->fdd0 != NULL) {
						free(ent->fdd0);
						ent->fdd0 = NULL;
					}
					if(ent->fdd0n != NULL) {
						free(ent->fdd0n);
						ent->fdd0n = NULL;
					}
					break;
				case 3:
					if(ent->fdd1 != NULL) {
						free(ent->fdd1);
						ent->fdd1 = NULL;
					}
					if(ent->fdd1n != NULL) {
						free(ent->fdd1n);
						ent->fdd1n = NULL;
					}
					break;
			}
			sel[devnum] = -1;
			redraw = 1;
		}
		if(WPAD_Pressed & WPAD_BUTTON_DOWN) {
			printf("\x1b[%d;0H   ", HEIGHT_BEGIN + cur_off);
			if((sel[devnum] != -1) && (sel[devnum] == position)) {
				printf("\x1b[%d;0H*", HEIGHT_BEGIN + cur_off);
			}
			cur_off++;
			position++;
			
			redraw = 1;

			if(position >= listcnt[devtype]) {
				eol = 1;
				position = listcnt[devtype] - 1;
			}
			if(cur_off >= MAX_ENTRIES) {
				cur_off = MAX_ENTRIES - 1;
				if(!eol)
					redraw = 1;
			}
			if(cur_off >= listcnt[devtype]) {
				cur_off = listcnt[devtype] - 1;
				if(!eol)
					redraw = 1;
			}
			printf("\x1b[%d;0H  \x1A", HEIGHT_BEGIN + cur_off);
			if((sel[devnum] != -1) && (sel[devnum] == position)) {
				printf("\x1b[%d;0H*", HEIGHT_BEGIN + cur_off);
			}
		} else if(WPAD_Pressed & WPAD_BUTTON_UP) {
			printf("\x1b[%d;0H   ", HEIGHT_BEGIN + cur_off);
			if((sel[devnum] != -1) && (sel[devnum] == position)) {
				printf("\x1b[%d;0H*", HEIGHT_BEGIN + cur_off);
			}
			cur_off--;
			position--;

			redraw = 1;

			if(cur_off < 0) {
				cur_off = 0;
				redraw = 1;
			}
			if(position < 0)
				position = 0;
			if(position >= listcnt[devtype])
				eol = 1;
			else
				eol = 0;
			printf("\x1b[%d;0H  \x1A", HEIGHT_BEGIN + cur_off);
			if((sel[devnum] != -1) && (sel[devnum] == position)) {
				printf("\x1b[%d;0H*", HEIGHT_BEGIN + cur_off);
			}
		}
		
		if(redraw) {
			printf("\x1b[J");
			printf("\x1b[%d;0H  Load %s\n  Currently loaded: %s\n  Press 1 to change device. Press 2 to eject.\n\n", HEIGHT_BEGIN - 4, devices[devnum], \
			       (devnum == 0) ? ((ent->hdd0 != NULL) ? ent->hdd0n : "None") : (\
			       (devnum == 1) ? ((ent->hdd1 != NULL) ? ent->hdd1n : "None") : (\
			       (devnum == 2) ? ((ent->fdd0 != NULL) ? ent->fdd0n : "None") : (\
			       (devnum == 3) ? ((ent->fdd1 != NULL) ? ent->fdd1n : "None") : "None"))));
			i = 0;
			// position == real  location
			// cur_off  == arrow location
			i = position - (MAX_ENTRIES - 1);
			if(i < 0)
				i = 0;
			if(i > (MAX_ENTRIES - 1)) {
				while(i > (MAX_ENTRIES - 1)) {
					i -= MAX_ENTRIES;
				}
			}
			int x;
			int bak = -1;
			for(x = 0; (i < listcnt[devtype]) && (x < MAX_ENTRIES); i++, x++) {
				switch(devtype) {
					case BASETYPE_FDD:
						printf("\x1b[%d;0H   %s\n", HEIGHT_BEGIN + x, gamesfdd[i].name);
						break;
					case BASETYPE_HDD:
						printf("\x1b[%d;0H   %s\n", HEIGHT_BEGIN + x, gameshdd[i].name);
						break;
					default:
						break;
				}
				if((sel[devnum] != -1) && (sel[devnum] == i)) {
					printf("\x1b[%d;0H*", HEIGHT_BEGIN + x);
					bak = x;
				}
			}
			printf("\x1b[%d;0H  \x1A", HEIGHT_BEGIN + cur_off);
			if((bak == cur_off)) {
				printf("\x1b[%d;0H*", HEIGHT_BEGIN + cur_off);
			}
			redraw = 0;
			BorderOverlay();
		}
		VIDEO_Flush();
		VIDEO_WaitVSync();
	}
	return *ent;
}
示例#27
0
文件: video.c 项目: MANICX100/wiimc
/****************************************************************************
 * ResetVideo_Menu
 *
 * Reset the video/rendering mode for the menu
****************************************************************************/
void
ResetVideo_Menu()
{
	Mtx44 p;
	f32 yscale;
	u32 xfbHeight;

	VIDEO_Configure (vmode);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if (vmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();
	else
		while (VIDEO_GetNextField())
			VIDEO_WaitVSync();

	// clears the bg to color and clears the z buffer
	GXColor background = {0, 0, 0, 255};
	GX_SetCopyClear (background, 0x00ffffff);

	yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight);
	xfbHeight = GX_SetDispCopyYScale(yscale);
	GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight);
	GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
	GX_SetDispCopyDst(vmode->fbWidth,xfbHeight);
	GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter);
	GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE));

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

	// setup the vertex descriptor
	// tells the flipper to expect direct data
	GX_ClearVtxDesc();
	GX_InvVtxCache ();
	GX_InvalidateTexAll();

	GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT);

	GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
	GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
	GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
	GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);

	GX_SetNumChans(1);
	GX_SetNumTexGens(1);
	GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
	GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
	GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);

	guMtxIdentity(GXmodelView2D);
	guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -200.0F);
	GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);

	guOrtho(p,0,479,0,639,0,300);
	GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC);

	GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
	GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
	GX_SetAlphaUpdate(GX_TRUE);
}
示例#28
0
/**
 * Taken from the devkitPPC template...
 */
void WiiEnvironment::setup()
{

    // Mtx view;
    Mtx model, modelview;
    GXColor background = {0, 0, 0, 0xff};

    // init the vi.
    VIDEO_Init();
    WPAD_Init();
    WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC );

    rmode = VIDEO_GetPreferredMode(NULL);

    // Attempt to initiate the fat filesystem...
    if ( !fatInitDefault() )
    {
        // TODO: Logging somehow?
        exit( 1 );
    }

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

    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(frameBuffer[fb]);
    VIDEO_SetBlack(FALSE);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

    // setup the fifo and then init the flipper
    void *gp_fifo = NULL;
    gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);
    memset(gp_fifo,0,DEFAULT_FIFO_SIZE);

    GX_Init(gp_fifo,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));

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


    // setup the vertex descriptor
    // tells the flipper to expect direct data
    GX_ClearVtxDesc();
    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

    // 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_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0);

    GX_SetNumChans(1);
    GX_SetNumTexGens(0);
    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
    GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);

    // setup our camera at the origin
    // looking down the -z axis with y up
    guVector cam = {0.0F, 0.0F, -100.0F},
             up = {0.0F, 1.0F, 0.0F},
             look = {0.0F, 0.0F, 0.0F};
    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);

}
示例#29
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 )
    }
}
示例#30
0
int main(int argc, char **argv) 
{
int ret;

	VIDEO_Init();                                        //Inicialización del Vídeo.
                                      
	rmode = VIDEO_GetPreferredMode(NULL);                //mediante esta función rmode recibe el valor de tu modo de vídeo.
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));  //inicialización del buffer.
	console_init(xfb,20,20,rmode->fbWidth,rmode->        //inicialización de la consola.
	xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);  
	VIDEO_Configure(rmode);                              //configuración del vídeo.
	VIDEO_SetNextFramebuffer(xfb);                       //Configura donde guardar el siguiente buffer .
	VIDEO_SetBlack(FALSE);                               //Hace visible el display  .                     
	VIDEO_Flush();
	VIDEO_WaitVSync();                                   
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	SYS_SetResetCallback(reset_call);

	IOS_ReloadIOS(222);
	sleep(1);

	/* secuencias de escape 

	\33[2J -> borra pantalla y posiciona en 1,1
	\33[1;1H -> posiciona en 1,1
	\33[42m -> color de fondo verde (0->negro, 1->rojo, 2->verde, 3-> amarillo, 4->azul, 5->magenta 6->cyan 7->blanco )
	\33[32m -> color de letras verde

	*/

	printf("\33[2J\n\n\n \33[42m dev/mload Test \33[40m \n\n\n\n");

	ret=mload_init();
	if(ret<0)
		{
		printf("fail to get dev/mload\n");
		
		goto out;
		}
	else
		{
		u32 addr;
		int len;

		printf("Hello!: my name is dev/mload and my thread id is %i\n", mload_get_thread_id());
		mload_get_load_base(&addr, &len);
		printf("You have from 0x%x to 0x%x to work\n\n", addr, addr+len-1);
		}
	/*
	mload_elf((void *) ehcmodule_elf, &my_data_elf);
	my_thread_id=mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio);
	*/

	printf("Loading example1.elf (Starlet)\n");

	if(((u32) example1_elf) & 3) {printf("Unaligned elf!\n"); goto out;}

	mload_elf((void *) example1_elf, &my_data_elf);

	printf("Running... at 0x%x\n", (u32) my_data_elf.start);

	my_thread_id=mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio);

    if(my_thread_id<0) {printf("fail to init the starlet thread: %i\n", my_thread_id); goto out;}

	printf("Module thread id: %i Priority in elf: 0x%x\n", my_thread_id, my_data_elf.prio);

	printf("The example Module counts seconds and report the thread id and the priority\n");

	{
	#if 0
		int n,m;

		sleep(1);
		#define UMS_BASE			(('U'<<24)|('M'<<16)|('S'<<8))
		#define USB_IOCTL_UMS_INIT	        (UMS_BASE+0x1)
		
		s32 hid2 = -1;
		hid2 = iosCreateHeap(1024);
		n=IOS_Open(ehc_fs, 0);
		if(n<0) printf("Error: device not found\n");
		else {
			printf("OK\n");
		     /* Initialize USB storage */
		     m=IOS_IoctlvFormat(hid2, n, USB_IOCTL_UMS_INIT, ":");

			 }

    #endif	
	}

	while(1)
		{
		static u32 data[8] ATTRIBUTE_ALIGN(32);

		if(exit_by_reset) break;

		mload_seek(0x13740000, SEEK_SET);
		mload_read(&data,32);
		printf("\33[16;16H Starlet activity: %i Thid: %i Prio: 0x%x    \n",data[0],data[1],data[2]);
		
		VIDEO_WaitVSync();
		}

	// you can stops the Starlet thread using this function:
	 mload_stop_thread(my_thread_id);
out:
	mload_close();
VIDEO_WaitVSync();
sleep(4);

return 0;
}