forked from Mirror/GodMode9
Fix all occurences of VCART_BUFFER
This commit is contained in:
parent
b204921554
commit
ae6c1c61c1
@ -55,9 +55,6 @@
|
||||
// buffer area defines (in use by vgame.c)
|
||||
#define VGAME_BUFFER ((u8*)0x20400000)
|
||||
#define VGAME_BUFFER_SIZE (0x200000) // 2MB, big RomFS
|
||||
// buffer area defines (in use by vcart.c)
|
||||
#define VCART_BUFFER ((u8*)0x20600000)
|
||||
#define VCART_BUFFER_SIZE (0x20000) // 128kB, this is more than enough
|
||||
|
||||
// buffer area defines (in use by image.c, for RAMdrive)
|
||||
#define RAMDRV_BUFFER ((u8*)0x22800000) // top of STACK
|
||||
|
@ -4,11 +4,16 @@
|
||||
#define FAT_LIMIT 0x100000000
|
||||
#define VFLAG_PRIV_HDR (1UL<<31)
|
||||
|
||||
static CartData* cdata = (CartData*) VCART_BUFFER; // 128kB reserved (~64kB required)
|
||||
static CartData* cdata = NULL;
|
||||
static bool cart_init = false;
|
||||
|
||||
u32 InitVCartDrive(void) {
|
||||
cart_init = ((InitCardRead(cdata) == 0) && (cdata->cart_size <= FAT_LIMIT));
|
||||
if (!cdata) cdata = (CartData*) malloc(sizeof(CartData));
|
||||
cart_init = (cdata && (InitCardRead(cdata) == 0) && (cdata->cart_size <= FAT_LIMIT));
|
||||
if (!cart_init && cdata) {
|
||||
free(cdata);
|
||||
cdata = NULL;
|
||||
}
|
||||
return cart_init ? cdata->cart_id : 0;
|
||||
}
|
||||
|
||||
@ -56,6 +61,7 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
|
||||
int ReadVCartFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count) {
|
||||
u32 foffset = vfile->offset + offset;
|
||||
if (!cdata) return -1;
|
||||
if (vfile->flags & VFLAG_PRIV_HDR)
|
||||
return ReadCartPrivateHeader(buffer, foffset, count, cdata);
|
||||
else return ReadCartBytes(buffer, foffset, count, cdata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user