Пример #1
0
s32 Disc_Open()
{
	/* Reset drive */
	s32 ret = WDVD_Reset();
	if(ret < 0)
		return ret;

	/* Read disc ID */
	ret = WDVD_ReadDiskId((u8*)Disc_ID);
	return ret;
}
Пример #2
0
s32 Disc_Open(void) {
    s32 ret;

    /* Reset drive */
    ret = WDVD_Reset();
    if (ret < 0)
        return ret;

    /* Read disc ID */
    return WDVD_ReadDiskId(diskid);
}
Пример #3
0
s32 Disc_Open(u8 type)
{
	if(type > 0)
	{	/* Reset drive */
		s32 ret = WDVD_Reset();
		if(ret < 0)
			return ret;
	}

	/* Read disc ID */
	return WDVD_ReadDiskId((u8*)Disc_ID);
}
Пример #4
0
s32 Disc_Open(void)
{
	/* Reset drive */
	s32 ret = WDVD_Reset();
	if (ret < 0) return ret;

	memset(diskid, 0, 32);

	/* Read disc ID */
	ret = WDVD_ReadDiskId(diskid);
	
	/* Directly set Audio Streaming for GC */
	WDVD_setstreaming();
	
	return ret;
}
Пример #5
0
s32 Disc_Open(bool boot_disc)
{
	/* Reset drive */
	s32 ret = WDVD_Reset();
	if (ret < 0) return ret;

	memset(diskid, 0, 32);

	/* Read disc ID */
	ret = WDVD_ReadDiskId(diskid);

	/* Directly set Audio Streaming for GC*/
	if(boot_disc)
		gprintf("Setting Audio Streaming for GC Games %s\n", WDVD_SetStreaming() == 0 ? "succeed" : "failed");

	return ret;
}
Пример #6
0
//---------------------------------------------------------------------------------
int main(int argc, char **argv) 
	{
	VIDEO_Init();
	VIDEO_SetBlack(true);  // Disable video output during initialisation

	net_wc24cleanup();
	
	if (fatMountSimple("sd", &__io_wiisd))
		DebugStart (true, "sd://ploader.log");
	else
		DebugStart (true, NULL);

	configbytes[0] = 0xCD;
	//configbytes[0] = 0;

	Debug ("---------------------------------------------------------------------------");
	Debug ("                             di "VER" by stfour");
	Debug ("                       (part of postLoader project)");
	Debug ("---------------------------------------------------------------------------");
	
	struct discHdr *header;
	header = (struct discHdr *)memalign(32, sizeof(struct discHdr));

	s32 rr = Disc_Init();
	Debug("Disc_Init() returned: %d", rr);
	
	rr = Disc_Open();
	Debug("Disc_Open() returned: %d", rr);

	// Check disc 
	rr = Disc_IsGC();
	Debug("Disc_IsGC() returned: %d", rr);
	
	if (rr == 0)
		{
		rr = WDVD_ReadDiskId ((void*)0x80000000);
		Debug("WDVD_ReadDiskId() returned: %d", rr);
		
		rr = WDVD_EnableAudio(*(u8*)0x80000008);
		Debug("WDVD_EnableAudio() returned: %d", rr);
		
		*(volatile unsigned int *)0xCC003024 |= 7;

		int retval = ES_GetTicketViews(BC, &view, 1);

		if (retval != 0)
			{
			Debug("ES_GetTicketViews fail %d", retval);
			exit (0);
			}
			
		retval = ES_LaunchTitle(BC, &view);
		exit (0);
		}
		
	// Check disc 
	rr = Disc_IsWii();
	Debug("Disc_IsWii() returned: %d", rr);

	if (rr == 0)
		{
		// Read header 
		rr = Disc_ReadHeader(header);
		Debug("Disc_ReadHeader() returned: %d", rr);

		Disc_WiiBoot (0, FALSE, TRUE, 0);
		}
	
	exit (0);
	}
void *DiHandler::ThreadMain( void *arg )
{
	enum State
	{
		St_Init,
		St_Reset,
		St_WaitForDisc,
		St_CheckDiscType,
		St_OpenPartition,
		St_WaitForDiscEject,	// some error happened, dont do anything until the current disc is ejected
		St_Idle
	};

	State state = St_Init;

	u32 coverState = 0;

	while( !threadExit )
	{
		usleep( 1000 );

		if( threadSleep )
			LWP_SuspendThread( thread );

		if( state == St_Init )
		{
			if( WDVD_Init() )
			{
				instance->ErrorHappened( E_Init, true );
				threadExit = true;
			}
			state = St_Reset;
			continue;
		}
		else if( state == St_Reset )
		{
			if( WDVD_Reset() )
			{
				instance->ErrorHappened( E_Init, false );
				continue;
			}
			state = St_WaitForDisc;
		}

		// check for disc
		u32 cover = 0;
		if( WDVD_GetCoverStatus( &cover ) )
		{
			gprintf( "WDVD_GetCoverStatus() failed\n" );
			WDVD_Close();
			state = St_Init;
			continue;
		}

		// check if disc status is changed
		if( cover != coverState )
		{
			//gprintf( "cover status: %08x %08x\n", cover, coverState );
			if( cover & 2 )// disc is present and wasnt before
			{
				//gprintf( "disc inserted\n" );
				instance->StartingToReadDisc();
				WDVD_Reset();
				state = St_CheckDiscType;
			}
			else if( coverState & 2 )// disc was present before isnt is gone now
			{
				instance->DiscEjected();
				//gprintf( "disc ejected\n" );
				state = St_WaitForDisc;
			}
			coverState = cover;
		}
		if( !( cover & 2 ) )// if theres no disc inserted, then loop
		{
			continue;
		}

		if( state == St_WaitForDiscEject )
		{
			continue;
		}
		else if( state == St_CheckDiscType )
		{
			s32 ret = WDVD_ReadDiskId( (void*)0x80000000 );
			if( ret < 0 )
			{
				gprintf("WDVD_ReadDiskId(): %d\n", ret );
				instance->ErrorHappened( E_DVD_ReadError, false );
				//state = St_WaitForDiscEject;
				WDVD_Close();
				state = St_Init;
				//coverState = 0;
				continue;
			}

			// check disc type
			if( *(u32*)( 0x80000018 ) == 0x5d1c9ea3 )
			{
				//gprintf( "disc is wii\n" );
				state = St_OpenPartition;
				//instance->DiscInserted( T_Wii );
			}
			else if( *(u32*)( 0x8000001c ) == 0xc2339f3d )
			{
				//gprintf( "disc is gamecube\n" );
				instance->DiscInserted( T_GC );
				state = St_Idle;
			}
			else
			{
				//gprintf( "disc is unknown\n" );
				instance->DiscInserted( T_Unknown );
				state = St_WaitForDiscEject;
				//hexdump( (void*)0x80000000, 0x20 );
			}
		}
		else if( state == St_OpenPartition )
		{
			if( WDVD_OpenDataPartition() < 0 )
			{
				instance->ErrorHappened( E_OpenPartition, false );
				state = St_WaitForDiscEject;
				continue;
			}
			//gprintf( "partition is open\n" );

			// search for the opening.bnr
			s32 ret;
			FST_INFO fst_info __attribute(( aligned( 32 ) ));

			//find FST inside partition
			ret = WDVD_Read( (u8*)&fst_info, sizeof( FST_INFO ), 0x420LL );
			if( ret < 0 )
			{
				gprintf("WDVD_Read( fst_info ): %d\n", ret );
				instance->ErrorHappened( E_DVD_ReadError, false );
				state = St_WaitForDiscEject;
				WDVD_ClosePartition();
				continue;
			}
			fst_info.fst_offset <<= 2;
			fst_info.fst_size <<= 2;
			//gprintf( "%s %i\n", __FILE__, __LINE__ );

			fst_buffer = (u8*)memalign( 32, RU( fst_info.fst_size, 0x40 ) );
			if( !fst_buffer )
			{
				instance->ErrorHappened( E_NoMem, true );
				threadExit = true;
				WDVD_ClosePartition();
				continue;
			}
			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			//gprintf( " %p  %08x %08x\n", fst_buffer, fst_info.fst_size, fst_info.fst_offset );

			//read fst into memory
			ret = WDVD_Read( fst_buffer, fst_info.fst_size, fst_info.fst_offset );
			if( ret < 0 )
			{
				gprintf("WDVD_Read( fst_buffer ): %d\n", ret );
				instance->ErrorHappened( E_DVD_ReadError, false );
				state = St_WaitForDiscEject;
				WDVD_ClosePartition();
				continue;
			}
			//gprintf( "%s %i\n", __FILE__, __LINE__ );

			//set the pointers
			fst = (FST_ENTRY *)fst_buffer;
			u32 name_table_offset = fst->filelen * 0xC;
			name_table = (char *)( fst_buffer + name_table_offset );

			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			// find the opening.bnr
			int fd = EntryFromPath( "/opening.bnr", 0 );
			if( fd < 2 )
			{
				instance->ErrorHappened( E_NoOpeningBnr, false );
				instance->DiscInserted( T_Wii );
				FREE( fst );
				name_table = NULL;
				state = St_Idle;
				WDVD_ClosePartition();
				continue;
			}
			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			u32 len = fst[ fd ].filelen;
			u8 *buf = (u8*)memalign( 32, RU( len, 0x40 ) );
			if( !buf )
			{
				instance->ErrorHappened( E_NoMem, true );
				threadExit = true;
				FREE( fst );
				name_table = NULL;
				WDVD_ClosePartition();
				continue;
			}
			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			ret = WDVD_Read( buf, len, (u64)( fst[ fd ].fileoffset ) << 2 );
			if( ret < 0 )
			{
				gprintf("WDVD_Read( opening.bnr ): %d\n", ret );
				instance->ErrorHappened( E_DVD_ReadError, false );
				state = St_WaitForDiscEject;
				FREE( fst );
				name_table = NULL;
				free( buf );
				WDVD_ClosePartition();
				continue;
			}

			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			// done with these
			FREE( fst );
			name_table = NULL;
			WDVD_ClosePartition();

			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			bool rec = false;
			// got the opening.bnr.  send it to whoever cares
			instance->OpeningBnrReady( buf, len, rec );
			if( !rec )
			{
				gprintf( "nobody got the banner.  freeing it\n" );
				free( buf );
			}
			instance->DiscInserted( T_Wii );
			//gprintf( "%s %i\n", __FILE__, __LINE__ );
			state = St_Idle;
		}
	}

	return NULL;
}