mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Add a vfile to show the JEDEC id for the inserted cart
This is meant to replace the Prompt I was using previously. Fun fact: WarioWare DIY seems to have *something* on the SPI bus, as it returns an ID of 0x000001 consistently. Or am I just glitching the parallel flash? Or did I get a fake?
This commit is contained in:
parent
fd48c95deb
commit
f60a4c1f63
@ -252,3 +252,18 @@ u32 WriteCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata) {
|
|||||||
if (offset + count > cdata->save_size) count = cdata->save_size - offset;
|
if (offset + count > cdata->save_size) count = cdata->save_size - offset;
|
||||||
return (SPIWriteSaveData((CardType) cdata->save_type, offset, buffer, count) == 0) ? 0 : 1;
|
return (SPIWriteSaveData((CardType) cdata->save_type, offset, buffer, count) == 0) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 ReadCartSaveJedecId(u8* buffer, u64 offset, u64 count, CartData* cdata) {
|
||||||
|
u8 ownBuf[JEDECID_AND_SREG_SIZE] = { 0 };
|
||||||
|
u32 id;
|
||||||
|
u8 sReg;
|
||||||
|
if (offset >= JEDECID_AND_SREG_SIZE) return 1;
|
||||||
|
if (offset + count > JEDECID_AND_SREG_SIZE) count = JEDECID_AND_SREG_SIZE - offset;
|
||||||
|
SPIReadJEDECIDAndStatusReg((CardType) cdata->save_type, &id, &sReg);
|
||||||
|
ownBuf[0] = (id >> 16) & 0xff;
|
||||||
|
ownBuf[1] = (id >> 8) & 0xff;
|
||||||
|
ownBuf[2] = id & 0xff;
|
||||||
|
ownBuf[JEDECID_AND_SREG_SIZE - 1] = sReg;
|
||||||
|
memcpy(buffer, ownBuf, count);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#define MODC_AREA_SIZE 0x4000
|
#define MODC_AREA_SIZE 0x4000
|
||||||
#define PRIV_HDR_SIZE 0x50
|
#define PRIV_HDR_SIZE 0x50
|
||||||
|
#define JEDECID_AND_SREG_SIZE 0x4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 header[0x8000]; // NTR header + secure area / CTR header + private header
|
u8 header[0x8000]; // NTR header + secure area / CTR header + private header
|
||||||
@ -29,3 +30,4 @@ u32 ReadCartBytes(void* buffer, u64 offset, u64 count, CartData* cdata);
|
|||||||
u32 ReadCartPrivateHeader(void* buffer, u64 offset, u64 count, CartData* cdata);
|
u32 ReadCartPrivateHeader(void* buffer, u64 offset, u64 count, CartData* cdata);
|
||||||
u32 ReadCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
u32 ReadCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
||||||
u32 WriteCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
u32 WriteCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
||||||
|
u32 ReadCartSaveJedecId(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
#include "spicard.h"
|
#include "spicard.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
// Deliberately written in C! (except for a few lines)
|
// Deliberately written in C! (except for a few lines)
|
||||||
|
|
||||||
@ -89,8 +88,6 @@ int SPIReadJEDECIDAndStatusReg(CardType type, u32* id, u8* statusReg) {
|
|||||||
if(id) *id = id_;
|
if(id) *id = id_;
|
||||||
if(statusReg) *statusReg = reg;
|
if(statusReg) *statusReg = reg;
|
||||||
|
|
||||||
ShowPrompt(false, "JEDEC = %lx, StatusReg = %hhx", *id, reg);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "gamecart.h"
|
#include "gamecart.h"
|
||||||
|
|
||||||
#define FAT_LIMIT 0x100000000
|
#define FAT_LIMIT 0x100000000
|
||||||
|
#define VFLAG_JEDECID_AND_SRFG (1UL<<29)
|
||||||
#define VFLAG_SAVEGAME (1UL<<30)
|
#define VFLAG_SAVEGAME (1UL<<30)
|
||||||
#define VFLAG_PRIV_HDR (1UL<<31)
|
#define VFLAG_PRIV_HDR (1UL<<31)
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir) {
|
|||||||
vfile->keyslot = 0xFF; // unused
|
vfile->keyslot = 0xFF; // unused
|
||||||
vfile->flags = VFLAG_READONLY;
|
vfile->flags = VFLAG_READONLY;
|
||||||
|
|
||||||
while (++vdir->index <= 6) {
|
while (++vdir->index <= 7) {
|
||||||
if ((vdir->index == 0) && (cdata->data_size < FAT_LIMIT)) { // standard full rom
|
if ((vdir->index == 0) && (cdata->data_size < FAT_LIMIT)) { // standard full rom
|
||||||
snprintf(vfile->name, 32, "%s.%s", name, ext);
|
snprintf(vfile->name, 32, "%s.%s", name, ext);
|
||||||
vfile->size = cdata->cart_size;
|
vfile->size = cdata->cart_size;
|
||||||
@ -61,6 +62,11 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir) {
|
|||||||
vfile->size = cdata->save_size;
|
vfile->size = cdata->save_size;
|
||||||
vfile->flags = VFLAG_SAVEGAME;
|
vfile->flags = VFLAG_SAVEGAME;
|
||||||
return true;
|
return true;
|
||||||
|
} else if (vdir->index == 7) { // JEDEC id and status register
|
||||||
|
strcpy(vfile->name, "jedecid_and_sreg.bin");
|
||||||
|
vfile->size = JEDECID_AND_SREG_SIZE;
|
||||||
|
vfile->flags = VFLAG_JEDECID_AND_SRFG;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +80,8 @@ int ReadVCartFile(const VirtualFile* vfile, void* buffer, u64 offset, u64 count)
|
|||||||
return ReadCartPrivateHeader(buffer, foffset, count, cdata);
|
return ReadCartPrivateHeader(buffer, foffset, count, cdata);
|
||||||
else if (vfile->flags & VFLAG_SAVEGAME)
|
else if (vfile->flags & VFLAG_SAVEGAME)
|
||||||
return ReadCartSave(buffer, foffset, count, cdata);
|
return ReadCartSave(buffer, foffset, count, cdata);
|
||||||
|
else if (vfile->flags & VFLAG_JEDECID_AND_SRFG)
|
||||||
|
return ReadCartSaveJedecId(buffer, foffset, count, cdata);
|
||||||
else return ReadCartBytes(buffer, foffset, count, cdata);
|
else return ReadCartBytes(buffer, foffset, count, cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user