aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorNeil Millstone2007-02-15 23:23:03 +0000
committerNeil Millstone2007-02-15 23:23:03 +0000
commit45ed48a8609bbf41360f124c272b788c5ee315ee (patch)
treef0d5fe33763be134ad49bfe65ed4e8a617c62ca7 /backends/platform/ds/arm9/source
parent26a3ad56e5fbceea3b8fc111a9b1ad37ca2bd78a (diff)
downloadscummvm-rg350-45ed48a8609bbf41360f124c272b788c5ee315ee.tar.gz
scummvm-rg350-45ed48a8609bbf41360f124c272b788c5ee315ee.tar.bz2
scummvm-rg350-45ed48a8609bbf41360f124c272b788c5ee315ee.zip
Changes made for 0.9.1a beta2 release backported to trunk
svn-id: r25617
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp124
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c22
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.h1
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.h2
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.s2
5 files changed, 101 insertions, 50 deletions
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index da78f10ea7..209deeb82b 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -44,6 +44,7 @@
// - 100% scale
#define USE_LIBCARTRESET
+//#define USE_BUILT_IN_DRIVER_SELECTION
#include <nds.h>
@@ -1995,19 +1996,21 @@ bool getIndyFightState() {
bool GBAMPAvail = false;
-void initGBAMP(int mode) {
+bool initGBAMP(int mode) {
if (FAT_InitFiles()) {
if (mode == 2) {
disc_IsInserted();
}
GBAMPAvail = true;
- consolePrintf("Found flash card reader!\n");
+// consolePrintf("Found flash card reader!\n");
+ return true;
} else {
GBAMPAvail = false;
- consolePrintf("Flash card reader not found!\n");
+// consolePrintf("Flash card reader not found!\n");
+ return false;
}
}
-
+
bool isGBAMPAvailable() {
return GBAMPAvail;
}
@@ -2038,45 +2041,51 @@ void debug_print_stub(char *string) {
#endif
#ifdef USE_LIBCARTRESET
+
+struct cardTranslate {
+ int cartResetId;
+ int svmId;
+ char dldiId[5];
+};
+
+#define NUM_CARD_READERS 7
+
+cardTranslate cardReaderTable[] = {
+ {DEVICE_TYPE_M3SD, DEVICE_M3SD, "M3SD"},
+ {DEVICE_TYPE_M3CF, DEVICE_M3CF, "M3CF"},
+ {DEVICE_TYPE_MPCF, DEVICE_MPCF, "MPCF"},
+ {DEVICE_TYPE_SCCF, DEVICE_SCCF, "SCCF"},
+ {DEVICE_TYPE_SCSD, DEVICE_SCSD, "SCSD"},
+ {DEVICE_TYPE_SCSD, DEVICE_SCSD, "SCLT"},
+ {DEVICE_TYPE_NMMC, DEVICE_NMMC, "NMMC"},
+};
+
void reboot() {
int deviceType = -1;
- switch (disc_getDeviceId()) {
- case DEVICE_M3SD: {
- deviceType = DEVICE_TYPE_M3SD;
- break;
- }
- case DEVICE_MMCF: {
- deviceType = -1;
- break;
- }
- case DEVICE_M3CF: {
- deviceType = DEVICE_TYPE_M3CF;
- break;
- }
- case DEVICE_MPCF: {
- deviceType = DEVICE_TYPE_MPCF;
- break;
- }
- case DEVICE_SCCF: {
- deviceType = DEVICE_TYPE_SCCF;
- break;
- }
- case DEVICE_NJSD: {
- deviceType = -1;
- break;
- }
- case DEVICE_SCSD: {
- deviceType = DEVICE_TYPE_SCSD;
- break;
+
+ if (disc_getDeviceId() == DEVICE_DLDI) {
+
+ char id[6];
+ disc_getDldiId(id);
+
+ consolePrintf("DLDI Device ID: %s\n", id);
+
+ for (int r = 0; r < NUM_CARD_READERS; r++) {
+ if (!stricmp(id, cardReaderTable[r].dldiId)) {
+ deviceType = cardReaderTable[r].cartResetId;
+ }
}
- case DEVICE_NMMC: {
- deviceType = DEVICE_TYPE_NMMC;
- break;
+ } else {
+ for (int r = 0; r < NUM_CARD_READERS; r++) {
+ if (disc_getDeviceId() == cardReaderTable[r].svmId) {
+ deviceType = cardReaderTable[r].cartResetId;
+ }
}
}
- consolePrintf("Device: %x\n", deviceType);
+
+ consolePrintf("Device number: %x\n", deviceType);
if (deviceType == -1) {
IPC->reset = true; // Send message to ARM7 to turn power off
@@ -2202,34 +2211,35 @@ int main(void)
- consolePrintf("---------------------------\n");
+ consolePrintf("-------------------------------\n");
consolePrintf("ScummVM DS\n");
consolePrintf("Ported by Neil Millstone\n");
consolePrintf("Version 0.10.0SVN ");
#if defined(DS_BUILD_A)
consolePrintf("build A\n");
consolePrintf("Supports: Lucasarts SCUMM\n");
- consolePrintf("---------------------------\n");
+ consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_B)
consolePrintf("build B\n");
consolePrintf("Supports: BASS, QUEEN\n");
- consolePrintf("---------------------------\n");
+ consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_C)
consolePrintf("build C\n");
- consolePrintf("---------------------------\n");
consolePrintf("Supports: SIMON, KYRA, GOB\n");
+ consolePrintf("-------------------------------\n");
#endif
- consolePrintf("L/R + D-pad/pen: Scroll view\n");
- consolePrintf("D-pad left: Left mouse button\n");
+ consolePrintf("L/R + D-pad/pen: Scroll view\n");
+ consolePrintf("D-pad left: Left mouse button\n");
consolePrintf("D-pad right: Right mouse button\n");
- consolePrintf("D-pad up: Hover mouse\n");
- consolePrintf("B button: Skip cutscenes\n");
- consolePrintf("Select: DS Options menu\n");
- consolePrintf("Start: Game menu\n");
- consolePrintf("Y (in game): Toggle console\n");
- consolePrintf("X: Toggle keyboard\n");
- consolePrintf("A: Swap screens\n");
- consolePrintf("L+R (on start): Clear SRAM\n");
+ consolePrintf("D-pad up: Hover mouse\n");
+ consolePrintf("B button: Skip cutscenes\n");
+ consolePrintf("Select: DS Options menu\n");
+ consolePrintf("Start: Game menu (some games)\n");
+ consolePrintf("Y (in game): Toggle console\n");
+ consolePrintf("X: Toggle keyboard\n");
+ consolePrintf("A: Swap screens\n");
+ consolePrintf("L+R (on start): Clear SRAM\n");
+
#if defined(DS_BUILD_A)
consolePrintf("For a complete key list see the\n");
@@ -2239,6 +2249,7 @@ int main(void)
#endif
+#ifdef USE_BUILT_IN_DRIVER_SELECTION
// Do M3 detection selectioon
int extraData = DSSaveFileManager::getExtraData();
bool present = DSSaveFileManager::isExtraDataPresent();
@@ -2275,6 +2286,11 @@ int main(void)
disc_setEnable(mode);
DSSaveFileManager::setExtraData(mode);
+#else
+
+ int mode = 0;
+
+#endif
/*
@@ -2306,6 +2322,14 @@ int main(void)
if (!node->getZip() || (!node->getZip()->isReady())) {
// If not found, init CF/SD driver
initGBAMP(mode);
+
+ if (!initGBAMP(mode)) {
+ consolePrintf("\nNo file system was found.\n");
+ consolePrintf("View the README_DLDI.TXT file\n");
+ consolePrintf("for more information.\n");
+
+ while (1);
+ }
}
delete node;
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c
index 988810073d..006d4f3d0f 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.c
+++ b/backends/platform/ds/arm9/source/fat/disc_io.c
@@ -92,6 +92,8 @@ LPIO_INTERFACE active_interface = 0;
*/
int discDetect = 0;
+int dldiFound = FALSE;
+
#ifdef DISC_CACHE
#include <string.h>
@@ -339,6 +341,15 @@ FATDevice disc_getDeviceId() {
return currentDevice;
}
+void disc_getDldiId(char* id) {
+ char* driverId = (char *) &_io_dldi;
+ id[0] = driverId[0];
+ id[1] = driverId[1];
+ id[2] = driverId[2];
+ id[3] = driverId[3];
+ id[4] = '\0';
+}
+
#ifdef NDS
// Check the DS card slot for a valid memory card interface
// If an interface is found, it is set as the default interace
@@ -355,6 +366,17 @@ bool disc_setDsSlotInterface (void)
active_interface = DLDI_GetInterface();
+ if (stricmp(&_dldi_driver_name, "Default (No interface)")) {
+ char name[48];
+ memcpy(name, &_dldi_driver_name, 48);
+ name[47] = '\0';
+ consolePrintf("DLDI Device:\n'%s'\n", name);
+ dldiFound = TRUE;
+ } else {
+ consolePrintf("DLDI Driver not patched!\n");
+ dldiFound = FALSE;
+ }
+
if (active_interface->fn_StartUp()) {
consolePrintf("DLDI Driver Initialised OK!\n");
currentDevice = DEVICE_DLDI;
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.h b/backends/platform/ds/arm9/source/fat/disc_io.h
index 2fff7f3bd5..1fbcc78c19 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.h
+++ b/backends/platform/ds/arm9/source/fat/disc_io.h
@@ -105,6 +105,7 @@ extern bool disc_IsInserted(void) ;
extern void disc_setEnable(int en);
extern FATDevice disc_getDeviceId();
+void disc_getDldiId(char* id);
/*-----------------------------------------------------------------
disc_ReadSectors
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h
index 6f97ca7b45..4ef3625eba 100644
--- a/backends/platform/ds/arm9/source/fat/io_dldi.h
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.h
@@ -23,6 +23,8 @@
extern IO_INTERFACE _io_dldi;
+extern u8 _dldi_driver_name;
+
// export interface
static inline LPIO_INTERFACE DLDI_GetInterface(void) {
#ifdef NDS
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.s b/backends/platform/ds/arm9/source/fat/io_dldi.s
index 8d21522baf..c2314e772d 100644
--- a/backends/platform/ds/arm9/source/fat/io_dldi.s
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.s
@@ -2,6 +2,7 @@
.align 4
.arm
.global _io_dldi
+ .global _dldi_driver_name
@---------------------------------------------------------------------------------
.equ FEATURE_MEDIUM_CANREAD, 0x00000001
.equ FEATURE_MEDIUM_CANWRITE, 0x00000002
@@ -21,6 +22,7 @@
@---------------------------------------------------------------------------------
@ Text identifier - can be anything up to 47 chars + terminating null -- 16 bytes
.align 4
+_dldi_driver_name:
.asciz "Default (No interface)"
@---------------------------------------------------------------------------------