aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds
diff options
context:
space:
mode:
authorNeil Millstone2007-01-19 21:36:47 +0000
committerNeil Millstone2007-01-19 21:36:47 +0000
commitbcef1cb04d326ffffe71ad3fab267520b872aa11 (patch)
treecedd2883029d4c85c42fa3a90a5fce92c62a5ffa /backends/platform/ds
parent37f94f7cba8135a8ee28a0ce1fe18337f8b764b6 (diff)
downloadscummvm-rg350-bcef1cb04d326ffffe71ad3fab267520b872aa11.tar.gz
scummvm-rg350-bcef1cb04d326ffffe71ad3fab267520b872aa11.tar.bz2
scummvm-rg350-bcef1cb04d326ffffe71ad3fab267520b872aa11.zip
Adding libcartreset to ARM7 binary
svn-id: r25122
Diffstat (limited to 'backends/platform/ds')
-rw-r--r--backends/platform/ds/arm7/source/libcartreset/cartreset.c109
-rw-r--r--backends/platform/ds/arm7/source/libcartreset/cartreset_nolibfat.h56
2 files changed, 165 insertions, 0 deletions
diff --git a/backends/platform/ds/arm7/source/libcartreset/cartreset.c b/backends/platform/ds/arm7/source/libcartreset/cartreset.c
new file mode 100644
index 0000000000..2f27c1884e
--- /dev/null
+++ b/backends/platform/ds/arm7/source/libcartreset/cartreset.c
@@ -0,0 +1,109 @@
+/**********************************
+ Copyright (C) Rick Wong (Lick)
+ http://licklick.wordpress.com/
+***********************************/
+#include <cartreset_nolibfat.h>
+
+
+#ifdef ARM9
+
+bool cartSetMenuMode(u32 _deviceType)
+{
+ *(vu16*)(0x04000204) &= ~0x0880; //sysSetBusOwners(true, true);
+ u32 deviceType = _deviceType;
+
+ *((vu32*)0x027FFFF8) = 0x080000C0; // ARM7 reset address
+
+ if(deviceType == DEVICE_TYPE_EFA2)
+ {
+ *(u16 *)0x9FE0000 = 0xD200;
+ *(u16 *)0x8000000 = 0x1500;
+ *(u16 *)0x8020000 = 0xD200;
+ *(u16 *)0x8040000 = 0x1500;
+ *(u16 *)0x9880000 = 1 << 15;
+ *(u16 *)0x9FC0000 = 0x1500;
+ return true;
+ }
+ else if(deviceType == DEVICE_TYPE_MPCF)
+ {
+ return true;
+ }
+ else if(deviceType == DEVICE_TYPE_EZSD)
+ {
+ return true;
+ }
+ else if(deviceType == DEVICE_TYPE_M3CF || deviceType == DEVICE_TYPE_M3SD)
+ {
+ u32 mode = 0x00400004;
+ vu16 tmp;
+ tmp = *(vu16*)(0x08E00002);
+ tmp = *(vu16*)(0x0800000E);
+ tmp = *(vu16*)(0x08801FFC);
+ tmp = *(vu16*)(0x0800104A);
+ tmp = *(vu16*)(0x08800612);
+ tmp = *(vu16*)(0x08000000);
+ tmp = *(vu16*)(0x08801B66);
+ tmp = *(vu16*)(0x08000000 + (mode << 1));
+ tmp = *(vu16*)(0x0800080E);
+ tmp = *(vu16*)(0x08000000);
+
+ tmp = *(vu16*)(0x080001E4);
+ tmp = *(vu16*)(0x080001E4);
+ tmp = *(vu16*)(0x08000188);
+ tmp = *(vu16*)(0x08000188);
+ return true;
+ }
+ else if(deviceType == DEVICE_TYPE_SCCF || deviceType == DEVICE_TYPE_SCSD)
+ {
+ *(vu16*)0x09FFFFFE = 0xA55A;
+ *(vu16*)0x09FFFFFE = 0xA55A;
+ *(vu16*)0x09FFFFFE = 0;
+ *(vu16*)0x09FFFFFE = 0;
+ *((vu32*)0x027FFFF8) = 0x08000000; // Special ARM7 reset address
+ return true;
+ }
+
+ return false;
+}
+
+
+
+void passmeloopEnter()
+{
+ *(vu16*)(0x04000208) = 0; //REG_IME = IME_DISABLE;
+ *(vu16*)(0x04000204) |= 0x0880; //sysSetBusOwners(false, false);
+ *((vu32*)0x027FFFFC) = 0;
+ *((vu32*)0x027FFE04) = (u32)0xE59FF018;
+ *((vu32*)0x027FFE24) = (u32)0x027FFE04;
+ asm("swi 0x00"); //swiSoftReset();
+ asm("bx lr");
+}
+
+#endif
+
+
+#ifdef ARM7
+
+//#include <nds.h>
+
+bool passmeloopQuery()
+{
+ if(*((vu32*)0x027FFE24) == (u32)0x027FFE04)
+ return true;
+ return false;
+}
+
+
+
+void cartExecute()
+{
+ *(vu16*)(0x04000208) = 0; //REG_IME = IME_DISABLE;
+ *((vu32*)0x027FFE34) = *((vu32*)0x027FFFF8);
+ asm("swi 0x00"); //swiSoftReset();
+ asm("bx lr");
+}
+
+#endif
+
+
+
diff --git a/backends/platform/ds/arm7/source/libcartreset/cartreset_nolibfat.h b/backends/platform/ds/arm7/source/libcartreset/cartreset_nolibfat.h
new file mode 100644
index 0000000000..133ae97e0f
--- /dev/null
+++ b/backends/platform/ds/arm7/source/libcartreset/cartreset_nolibfat.h
@@ -0,0 +1,56 @@
+/**********************************
+ Copyright (C) Rick Wong (Lick)
+ http://licklick.wordpress.com/
+***********************************/
+#ifndef CARTRESET_H
+#define CARTRESET_H
+
+#include <fat.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef ARM9
+// Auto detect:
+#define DEVICE_TYPE_AUTO 0x00000000 // doesn't work in libcartreset "nolibfat" version
+
+// Not supported:
+#define DEVICE_TYPE_FCSR 0x52534346
+#define DEVICE_TYPE_MMCF 0x46434D4D
+#define DEVICE_TYPE_NJSD 0x44534A4E
+#define DEVICE_TYPE_NMMC 0x434D4D4E
+
+// Supported:
+#define DEVICE_TYPE_EFA2 0x32414645
+#define DEVICE_TYPE_MPCF 0x4643504D
+#define DEVICE_TYPE_M3CF 0x4643334D
+#define DEVICE_TYPE_M3SD 0x4453334D
+#define DEVICE_TYPE_SCCF 0x46434353
+#define DEVICE_TYPE_SCSD 0x44534353
+
+// Supported, but libfat doesn't detect the device:
+#define DEVICE_TYPE_EZSD 0x44535A45
+
+
+bool cartSetMenuMode(u32 _deviceType);
+void passmeloopEnter();
+
+#endif
+
+
+#ifdef ARM7
+
+bool passmeloopQuery();
+void cartExecute();
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+