diff options
author | Nebuleon Fumika | 2013-02-08 05:50:22 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2013-02-08 05:50:22 -0500 |
commit | 927d456306672110870eb3386742c1c1ef8eb4f6 (patch) | |
tree | 509da9ac1727570b02572068aefb9cdf102ad75b /sdk-modifications/libsrc/fs/disc_io/disc.c | |
parent | 433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1 (diff) | |
parent | d4fcf2697c9a45594e3ee0b8bf82e480ddd0b69b (diff) | |
download | snes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.tar.gz snes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.tar.bz2 snes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.zip |
Merge branch 'master' into 8bitsound
Conflicts:
source/nds/entry.cpp
Diffstat (limited to 'sdk-modifications/libsrc/fs/disc_io/disc.c')
-rwxr-xr-x | sdk-modifications/libsrc/fs/disc_io/disc.c | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/sdk-modifications/libsrc/fs/disc_io/disc.c b/sdk-modifications/libsrc/fs/disc_io/disc.c new file mode 100755 index 0000000..8b50953 --- /dev/null +++ b/sdk-modifications/libsrc/fs/disc_io/disc.c @@ -0,0 +1,194 @@ +/*
+
+ disc.c
+
+ uniformed io-interface to work with Chishm's FAT library
+
+ Written by MightyMax
+
+
+ Copyright (c) 2006 Michael "Chishm" Chisholm
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ 2005-11-06 - Chishm
+ * Added WAIT_CR modifications for NDS
+
+ 2006-02-03 www.neoflash.com
+ * Added SUPPORT_* defines, comment out any of the SUPPORT_* defines in disc_io.h to remove support
+ for the given interface and stop code being linked to the binary
+
+ * Added support for MK2 MMC interface
+
+ * Added disc_Cache* functions
+
+ 2006-02-05 - Chishm
+ * Added Supercard SD support
+
+ 2006-02-26 - Cytex
+ * Added EFA2 support
+
+ 2006-05-18 - Chishm
+ * Rewritten for FATlib disc.c
+
+ 2006-06-19 - Chishm
+ * Changed read and write interface to accept a u32 instead of a u8 for the number of sectors
+
+ 2006-07-11 - Chishm
+ * Removed disc_Cache* functions, since there is now a proper unified cache
+ * Removed SUPPORT_* defines
+ * Rewrote device detection functions
+ * First libfat release
+
+ 2006-07-25 - Chishm
+ * Changed IO_INTERFACEs to const
+
+ 2006-08-02 - Chishm
+ * Added NinjaDS
+*/
+
+#include "disc.h"
+#include "disc_io.h"
+
+// Include known io-interfaces:
+//#include "io_dldi.h"
+//#include "io_mpcf.h"
+//#include "io_m3cf.h"
+//#include "io_m3sd.h"
+//#include "io_sccf.h"
+//#include "io_scsd.h"
+//#include "io_fcsr.h"
+//#include "io_nmmc.h"
+//#include "io_efa2.h"
+//#include "io_mmcf.h"
+//#include "io_njsd.h"
+//#include "io_acekard.h"
+//#include "io_rpg_nand.h"
+//#include "io_rpg_sd.h"
+//#include "iointerface_sc.h" +#include "io_ds2_mmcf.h"
+
+const IO_INTERFACE* ioInterfaces[] = {
+ //&_io_dldi,
+ //&_io_fcsr,
+#ifdef NDS
+ // Place Slot 1 (DS Card) interfaces here
+ //&_io_rpg_sd, //&_io_rpg_nand, /*&_io_acekard, */
+ // Place Slot 2 (GBA Cart) interfaces here
+ //&_io_scsd, &_io_mpcf, &_io_m3cf, &_io_sccf, &_io_m3sd, &_io_fcsr
+ // Experimental Slot 2 interfaces
+ //, &_io_mmcf, &_io_efa2
+ &_io_ds2_mmcf,
+#endif
+};
+
+/*
+
+ Hardware level disc funtions
+
+*/
+
+
+const IO_INTERFACE* _FAT_disc_gbaSlotFindInterface (void)
+{
+ // If running on an NDS, make sure the correct CPU can access
+ // the GBA cart. First implemented by SaTa.
+#ifdef NDS
+ #ifdef ARM9
+ REG_EXMEMCNT &= ~ARM7_OWNS_ROM;
+ #endif
+ #ifdef ARM7
+ REG_EXMEMCNT |= ARM7_OWNS_ROM;
+ #endif
+#endif
+
+ int i;
+
+ for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
+ if ((ioInterfaces[i]->features & FEATURE_SLOT_GBA) && (ioInterfaces[i]->fn_startup())) {
+ return ioInterfaces[i];
+ }
+ }
+ return NULL;
+}
+
+#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
+ * and it returns true. Otherwise the default interface is left
+ * untouched and it returns false.
+ */
+const IO_INTERFACE* _FAT_disc_dsSlotFindInterface (void)
+{
+#ifdef ARM9
+ REG_EXMEMCNT &= ~ARM7_OWNS_CARD;
+#endif
+#ifdef ARM7
+ REG_EXMEMCNT |= ARM7_OWNS_CARD;
+#endif
+ int i;
+
+ for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
+ if ((ioInterfaces[i]->features & FEATURE_SLOT_NDS) && (ioInterfaces[i]->fn_startup())) {
+ return ioInterfaces[i];
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+/*
+ * When running on an NDS, check the either slot for a valid memory
+ * card interface.
+ * When running on a GBA, call _FAT_disc_gbaSlotFindInterface
+ * If an interface is found, it is set as the default interace
+ * and it returns true. Otherwise the default interface is left
+ * untouched and it returns false.
+ */
+#ifdef NDS
+const IO_INTERFACE* _FAT_disc_findInterface (void)
+{
+#ifdef ARM9
+ REG_EXMEMCNT &= ~(ARM7_OWNS_CARD | ARM7_OWNS_ROM);
+#endif
+#ifdef ARM7
+ REG_EXMEMCNT |= (ARM7_OWNS_CARD | ARM7_OWNS_ROM);
+#endif
+
+ int i;
+
+ for (i = 0; i < (sizeof(ioInterfaces) / sizeof(IO_INTERFACE*)); i++) {
+ if (ioInterfaces[i]->fn_startup()) {
+ return ioInterfaces[i];
+ }
+ }
+
+ return NULL;
+}
+#else
+const IO_INTERFACE* _FAT_disc_findInterface (void)
+{
+ return _FAT_disc_gbaSlotFindInterface();
+}
+#endif
|