mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-16 00:15:08 +01:00
0e7d37b18b
*Fixed freeze in theme menu when its empty *Optimized the game list loading on fat/ntfs/ext. This should speed up the loading process. *Added cache of game titles. This will speed up the startup after the cache file is written (in other words on second start of this rev). A TitlesCache.bin will be created in the same path as the wiitdb.xml for this. This should especial speed up the startup of fat/ntfs/ext partitions by a lot if no sub folders with the game titles are used, like GAMEID.wbfs only. That must have been painfully slow before on a lot of games. Should be at about the same speed as with sub folders now. I would still recommend to use sub folders. *Removed wiilight (disc slot) blinking when switching USB port on Hermes cIOSes (thanks rodries) *Added the ehcmodule sources from rodries to the branches *Updated language files
132 lines
2.9 KiB
C
132 lines
2.9 KiB
C
/*
|
|
Custom IOS module for Wii.
|
|
wbfs glue
|
|
Copyright (C) 2009 kwiirk.
|
|
Copyright (C) 2008 neimod.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* oh0_loop.c - IOS module main code
|
|
* even if we are "ehc" driver, we still pretend to be "oh0"
|
|
* and implement "standard" ios oh0 usb api
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "syscalls.h"
|
|
#include "libwbfs.h"
|
|
|
|
u32 n_sec,sec_size;
|
|
|
|
|
|
|
|
|
|
|
|
/*static*/ int read_sector(void *ign,u32 lba,u32 count,void*buf)
|
|
{
|
|
int ret;
|
|
|
|
|
|
os_sync_after_write(buf, count*sec_size);
|
|
|
|
/* do
|
|
{*/
|
|
ret = USBStorage_Read_Sectors(lba,count, buf);
|
|
/*}*/
|
|
if(!ret) return 1;
|
|
|
|
os_sync_before_read(buf, count*sec_size);
|
|
return 0;
|
|
}
|
|
|
|
static wbfs_disc_t *wbfs_disc=NULL;
|
|
|
|
u8 *disc_buff=NULL;
|
|
extern u32 current_disc_lba;
|
|
|
|
|
|
void wbfs_perform_disc(void)
|
|
{
|
|
if(wbfs_disc)
|
|
{
|
|
|
|
wbfs_close_disc(wbfs_disc);wbfs_disc=NULL;
|
|
}
|
|
if(!disc_buff) {disc_buff=WBFS_Alloc(0x8020);}
|
|
|
|
current_disc_lba=0xffffffff;
|
|
|
|
}
|
|
static wbfs_t *p=NULL;
|
|
|
|
void release_wbfs_mem(void)
|
|
{
|
|
if(disc_buff) WBFS_Free(disc_buff);disc_buff=NULL;
|
|
|
|
if(wbfs_disc)
|
|
{
|
|
wbfs_close_disc(wbfs_disc);wbfs_disc=NULL;
|
|
}
|
|
if(p)
|
|
wbfs_close(p);p= NULL;
|
|
|
|
}
|
|
|
|
wbfs_disc_t * wbfs_init_with_partition(u8*discid, int partition)
|
|
{
|
|
|
|
|
|
static u8 old_discid[6]="";
|
|
|
|
if(disc_buff) WBFS_Free(disc_buff);disc_buff=NULL;
|
|
|
|
// opens the hd only is is not opened
|
|
if(!p)
|
|
{
|
|
USBStorage_Init();
|
|
n_sec = USBStorage_Get_Capacity(&sec_size);
|
|
//debug_printf("hd found n_sec:%x sec_size %x\n",n_sec,sec_size);
|
|
if (n_sec==0)
|
|
return NULL; //no hd
|
|
p = wbfs_open_hd(read_sector, 0, 0, sec_size, n_sec,partition, 0);
|
|
if(!p) // no partition
|
|
return NULL;
|
|
}
|
|
// close previously disc opened except if discid is equal
|
|
if(wbfs_disc)
|
|
{
|
|
|
|
if(!memcmp(old_discid,discid,6)) return wbfs_disc;
|
|
|
|
wbfs_close_disc(wbfs_disc);wbfs_disc=NULL;
|
|
}
|
|
|
|
// open the disc
|
|
wbfs_disc=wbfs_open_disc(p, discid);
|
|
|
|
if(wbfs_disc) memcpy(old_discid,discid,6);
|
|
|
|
return wbfs_disc;
|
|
}
|