mirror of
https://github.com/suloku/savegame-manager.git
synced 2026-04-25 07:27:24 -05:00
- fix support for unknown chips, add a few lines to template ini file
- add a new method for Slot 2 mode detection; the program now looks for your DLDI driver name (fortunately, no new Slot 2 cards are being built!)
This commit is contained in:
parent
611c3305e8
commit
cd3c114e44
|
|
@ -170,7 +170,7 @@ void displayPrintUpper()
|
|||
break;
|
||||
case 3:
|
||||
if (size == 0)
|
||||
sprintf(&name[0], "Flash (? kB, ID=%x)", auxspi_save_jedec_id(ir));
|
||||
sprintf(&name[0], "Flash (ID:%x)", auxspi_save_jedec_id(ir));
|
||||
else
|
||||
sprintf(&name[0], "Flash (%i kB)", 1 << (size - 10));
|
||||
break;
|
||||
|
|
@ -209,7 +209,7 @@ void displayPrintUpper()
|
|||
sprintf(name, "3in1 (???M)");
|
||||
} else if (gba)
|
||||
sprintf(name, "%.4s", (char*)0x080000ac);
|
||||
else if (slot2)
|
||||
else if (slot2 > 0)
|
||||
sprintf(name, "Flash Card");
|
||||
else if (dstype == 0)
|
||||
sprintf(name, "----");
|
||||
|
|
@ -224,7 +224,7 @@ void displayPrintUpper()
|
|||
sprintf(name, "3in1");
|
||||
else if (gba)
|
||||
sprintf(name, "%.12s", (char*)0x080000a0);
|
||||
else if (slot2)
|
||||
else if (slot2 > 0)
|
||||
sprintf(name, "Flash Card");
|
||||
else if (dstype == 0)
|
||||
sprintf(name, "----");
|
||||
|
|
@ -256,7 +256,7 @@ void displayPrintUpper()
|
|||
sprintf(name, "(none)");
|
||||
}
|
||||
}
|
||||
else if (slot2)
|
||||
else if (slot2 > 0)
|
||||
sprintf(name, "Flash Card");
|
||||
else if (dstype == 0)
|
||||
sprintf(name, "----");
|
||||
|
|
@ -272,7 +272,7 @@ void displayPrintUpper()
|
|||
else if (gba)
|
||||
// TODO: test for RTC, add function for syncing RTC?
|
||||
sprintf(name, "???");
|
||||
else if (slot2)
|
||||
else if (slot2 > 0)
|
||||
sprintf(name, "----");
|
||||
else if (dstype == 0)
|
||||
sprintf(name, "----");
|
||||
|
|
|
|||
|
|
@ -51,26 +51,6 @@ inline u32 min(u32 i, u32 j) { return (i < j) ? i : j;}
|
|||
inline u32 max(u32 i, u32 j) { return (i > j) ? i : j;}
|
||||
|
||||
|
||||
bool slot2Init()
|
||||
{
|
||||
static bool doonce = false;
|
||||
static bool init_3in1 = false;
|
||||
|
||||
if (doonce)
|
||||
return init_3in1;
|
||||
|
||||
doonce = true;
|
||||
OpenNorWrite();
|
||||
uint32 test = ReadNorFlashID();
|
||||
CloseNorWrite();
|
||||
|
||||
init_3in1 = test;
|
||||
if (test)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
#define MAGIC_EEPR 0x52504545
|
||||
|
|
@ -112,32 +92,6 @@ cartTypeGBA GetSlot2Type(uint32 id)
|
|||
}
|
||||
};
|
||||
|
||||
void IdentifySlot2(dataSlot2 &data)
|
||||
{
|
||||
// FIXME...
|
||||
#if 0
|
||||
// Identify an EZFlash 3in1
|
||||
OpenNorWrite();
|
||||
cartTypeGBA ezflash = slot2IsEZFlash3in1(data.ez_ID);
|
||||
//chip_reset();
|
||||
CloseNorWrite();
|
||||
if (ezflash != CART_GBA_NONE) {
|
||||
data.type = cartTypeGBA(ezflash);
|
||||
return; // 3in1 has no classic save memory
|
||||
} else {
|
||||
// it's not a 3in1
|
||||
sGBAHeader *gba = (sGBAHeader*)0x08000000;
|
||||
memcpy(&data.name[0], &gba->title[0], 12);
|
||||
data.name[12] = 0;
|
||||
memcpy(&data.iid, &gba->gamecode[0], 4);
|
||||
data.cid[4] = 0;
|
||||
data.type = GetSlot2Type(data.iid);
|
||||
}
|
||||
|
||||
data.save = GetSlot2SaveType(data.type);
|
||||
#endif
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------
|
||||
bool gbaIsGame()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,9 +58,6 @@ struct dataSlot2 {
|
|||
|
||||
cartTypeGBA GetSlot2Type(uint32 id);
|
||||
saveTypeGBA GetSlot2SaveType(cartTypeGBA type);
|
||||
void IdentifySlot2(dataSlot2 &data);
|
||||
|
||||
bool slot2Init();
|
||||
|
||||
// --------------------
|
||||
bool gbaIsGame();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ char txt[256] = "";
|
|||
u32 mode = 0;
|
||||
u32 ezflash = 0;
|
||||
|
||||
int slot2 = 0;
|
||||
int slot2 = -1;
|
||||
|
||||
u32 extra_id[EXTRA_ARRAY_SIZE];
|
||||
u8 extra_size[EXTRA_ARRAY_SIZE];
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <nds.h>
|
||||
#include <fat.h>
|
||||
#include <nds/arm9/dldi.h>
|
||||
|
||||
#include <nds/interrupts.h>
|
||||
#include <nds/arm9/console.h>
|
||||
|
|
@ -127,6 +128,60 @@ bool swap_card_game(uint32 size)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Since there are no new Slot 2 cards out there, we test the presence of Slot 2
|
||||
// mode by looking at the DLDI driver IDs.
|
||||
bool hwDetectSlot2DLDI()
|
||||
{
|
||||
// The driver name is stored in io_dldi_data->friendlyName
|
||||
|
||||
// EZ Flash 4
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "EZ Flash 4", 10))
|
||||
return true;
|
||||
|
||||
// CycloDS (Slot 2)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "CycloDS", 7)
|
||||
&& strnicmp(io_dldi_data->friendlyName, "CycloDS Evolution", 17))
|
||||
return true;
|
||||
|
||||
// Ewin2
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "Ewin2", 5))
|
||||
return true;
|
||||
|
||||
// G6 Lite
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "G6 Lite DLDI", 12))
|
||||
return true;
|
||||
|
||||
// GBA Movie Player (CF and SD versions)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "GBA Movie Player", 16))
|
||||
return true;
|
||||
|
||||
// M3 (CF and SD versions)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "M3 Adapter", 10))
|
||||
return true;
|
||||
|
||||
// Max Media Dock
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "Max Media Dock", 14))
|
||||
return true;
|
||||
|
||||
// Neo2
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "Neo2", 4))
|
||||
return true;
|
||||
|
||||
// Supercard (CF/SD)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "SuperCard (", 11))
|
||||
return true;
|
||||
|
||||
// Supercard (lite)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "SuperCard Lite", 14))
|
||||
return true;
|
||||
|
||||
// Supercard (Rumble)
|
||||
if (!strnicmp(io_dldi_data->friendlyName, "SuperCard Rumble", 16))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// This function is called on boot; it detects the hardware configuration and selects the mode.
|
||||
u32 hwDetect()
|
||||
{
|
||||
|
|
@ -140,8 +195,29 @@ u32 hwDetect()
|
|||
}
|
||||
size_buf = 1 << 21; // 2 MB memory buffer
|
||||
|
||||
// Identify Slot 2 device.
|
||||
// First, look for an EZFlash 3in1
|
||||
// Identify Slot 2 device.
|
||||
// First, look for a Slot 2 flash card. This must be done before any 3in1 Test, because
|
||||
// the EZFlash 4 also detects as a 3in1.
|
||||
|
||||
// Detecting slot 2 flash cards is very evil:
|
||||
// - They don't usually support argv, so we can't simply test that we are
|
||||
// running from "fat2".
|
||||
// - We need a passme compatible slot 1 device, i.e. we can't verify that
|
||||
// there is a flash card in slot 1 (which usually is).
|
||||
// - There is only a limited number of Slot 2 flash cards on the market, so
|
||||
// we test for this. We look for a valid Slot 2 DLDI driver name, which pretty
|
||||
// much ensures that we are writing to Slot 2.
|
||||
//
|
||||
// ... HOWEVER: We are also using a Slot 2 ini parameter, so WiFi mode can also be
|
||||
// accessed from Slot 2 (if you need it).
|
||||
//
|
||||
if (hwDetectSlot2DLDI()) {
|
||||
slot2 = 1;
|
||||
return 4;
|
||||
} else
|
||||
slot2 = 0;
|
||||
|
||||
// Look for an EZFlash 3in1
|
||||
uint32 ime = enterCriticalSection();
|
||||
sysSetBusOwners(true, true);
|
||||
OpenNorWrite();
|
||||
|
|
@ -155,27 +231,6 @@ u32 hwDetect()
|
|||
// Okay, maybe it is a regular GBA game instead
|
||||
if (gbaIsGame())
|
||||
return 1;
|
||||
|
||||
// Maybe it is a Slot 2 flash card.
|
||||
|
||||
// Detecting slot 2 flash cards is very evil:
|
||||
// - They don't usually support argv, so we can't simply test that we are
|
||||
// running from "fat2".
|
||||
// - We need a passme compatible slot 1 device, i.e. we can't verify that
|
||||
// there is a flash card in slot 1 (which usually is).
|
||||
// - There is only a limited number of Slot 2 flash cards on the market, so
|
||||
// we could test for this (I think there is a library for this). But if we
|
||||
// boot from Slot 1, a positive Slot 2 test does not mean that we did boot
|
||||
// from there - the card may be sitting there unused!
|
||||
//
|
||||
// --> So we select slot 2 mode the "dumb" way - with an ini parameter. Unless you swap
|
||||
// the same microSD card between Slot 1 and Slot 2, this should be the safest mode.
|
||||
// (If you know a smarter way of doing this, feel free to commit a patch!)
|
||||
//
|
||||
// EDIT: and we can't test this here, since the ini file has not been parsed yet!
|
||||
//
|
||||
//if (slot2)
|
||||
//return 4;
|
||||
|
||||
// Try to identify download play mode. This also introduces various complications:
|
||||
// - The latest libnds versions include code for the SD-slot on the DSi. It does not work
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#define HARDWARE_H
|
||||
|
||||
#include <nds.h>
|
||||
#include <fat.h>
|
||||
#include <sys/unistd.h>
|
||||
|
||||
#define RS_BACKUP 0x4b434142
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <nds.h>
|
||||
#include <fat.h>
|
||||
#include <nds/arm9/dldi.h>
|
||||
|
||||
#include <sys/dir.h>
|
||||
#include <nds/arm9/console.h>
|
||||
|
|
@ -101,9 +102,6 @@ void mode_slot2()
|
|||
displayPrintUpper();
|
||||
displayPrintLower();
|
||||
|
||||
//displayWarning2F(STR_BOOT_MODE_UNSUPPORTED);
|
||||
//while(1);
|
||||
|
||||
touchPosition touchXY;
|
||||
while(1) {
|
||||
swiWaitForVBlank();
|
||||
|
|
@ -256,6 +254,10 @@ void mode_dlp()
|
|||
displayPrintUpper();
|
||||
displayPrintLower();
|
||||
|
||||
// DSi mode, does nothing at the moment
|
||||
displayMessage2F(STR_STR, "I did not expect that you can trigger this mode at all!");
|
||||
while(1);
|
||||
|
||||
touchPosition touchXY;
|
||||
while(1) {
|
||||
swiWaitForVBlank();
|
||||
|
|
@ -325,8 +327,8 @@ bool loadIniFile(char* path)
|
|||
ini_readInt(ini, &ir_delay);
|
||||
ir_delay = max(ir_delay, 1000);
|
||||
|
||||
ini_locateKey(ini, "slot2");
|
||||
ini_readInt(ini, &slot2);
|
||||
if (ini_locateKey(ini, "slot2"))
|
||||
ini_readInt(ini, &slot2);
|
||||
|
||||
// load additional Flash chip signatures (JEDEC IDs)
|
||||
ini_locateHeading(ini, "new chips");
|
||||
|
|
@ -335,7 +337,7 @@ bool loadIniFile(char* path)
|
|||
sprintf(txt, "%i-id", i);
|
||||
ini_locateKey(ini, txt);
|
||||
ini_readString(ini, txt, 256);
|
||||
sscanf(txt, "%x", &extra_id[i]);
|
||||
sscanf(txt, "%x", &tmp);
|
||||
extra_id[i] = (u32)tmp;
|
||||
//
|
||||
sprintf(txt, "%i-size", i);
|
||||
|
|
@ -400,9 +402,6 @@ int main(int argc, char* argv[])
|
|||
// Init the screens
|
||||
displayInit();
|
||||
|
||||
// detect hardware
|
||||
mode = hwDetect();
|
||||
|
||||
// Init DLDI (file system driver)
|
||||
sysSetBusOwners(true, true);
|
||||
int fat = fatInitDefault();
|
||||
|
|
@ -411,18 +410,24 @@ int main(int argc, char* argv[])
|
|||
iprintf("DLDI error");
|
||||
while (1);
|
||||
}
|
||||
iprintf("Found DLDI: %s\n", io_dldi_data->friendlyName);
|
||||
|
||||
// detect hardware
|
||||
mode = hwDetect();
|
||||
|
||||
// Load the ini file with the FTP settings and more options
|
||||
for (int i = 0; i < EXTRA_ARRAY_SIZE; i++) {
|
||||
extra_id[i] = 0xff000000;
|
||||
extra_size[i] = 0;
|
||||
}
|
||||
iprintf("Loading INI file\n");
|
||||
if (has_argv(argc, argv))
|
||||
loadIniFile(argv[0]);
|
||||
else
|
||||
loadIniFile(0);
|
||||
iprintf("Done!\n");
|
||||
|
||||
if (slot2)
|
||||
if (slot2 > 0)
|
||||
mode = 4;
|
||||
|
||||
// load strings
|
||||
|
|
|
|||
|
|
@ -5,3 +5,9 @@ ftp_port = 8080
|
|||
#language = /sgm_german.ini
|
||||
|
||||
[new chips]
|
||||
# The following lines are an example for the most commonly used Flash chip.
|
||||
# You do not need the following lines, but you can use them as a template when
|
||||
# the program reports "Save: Flash (ID:...)"
|
||||
|
||||
#0-id = 204013
|
||||
#0-size = 19
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user