mirror of
https://github.com/suloku/savegame-manager.git
synced 2026-04-18 13:08:03 -05:00
Source code for the 0.2.1 release (1-9-2011).
This commit is contained in:
parent
13de622eaf
commit
97bdcc76ad
|
|
@ -55,7 +55,7 @@ void displayInit()
|
|||
consoleInit(&lowerScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
|
||||
consoleSelect(&upperScreen);
|
||||
iprintf("\n\n\n\n\nDS savegame manager\nVersion 0.2 Beta\nBy Pokedoc");
|
||||
iprintf("\n\n\n\n\nDS savegame manager\nVersion 0.2.1 Beta\nBy Pokedoc");
|
||||
|
||||
displayPrintState("Press (B) to continue");
|
||||
while (!(keysCurrent() & KEY_B));
|
||||
|
|
|
|||
51
trunk/arm9/source/dsi.cpp
Normal file
51
trunk/arm9/source/dsi.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* savegame_manager: a tool to backup and restore savegames from Nintendo
|
||||
* DS cartridges. Nintendo DS and all derivative names are trademarks
|
||||
* by Nintendo. EZFlash 3-in-1 is a trademark by EZFlash.
|
||||
*
|
||||
* dsi.cpp: A happy collection of functions dealing with DSi-specific things
|
||||
*
|
||||
* Copyright (C) Pokedoc (2010)
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <nds.h>
|
||||
|
||||
#include "dsi.h"
|
||||
|
||||
bool isDsi()
|
||||
{
|
||||
// This code attempts to identify an application running in DSi mode. We
|
||||
// make use of the fact that the DSi has 16 MB of memory, while the DS
|
||||
// only has 4 MB. Since the Chinese iQue DS has 8 MB, we will read above
|
||||
// this boundary.
|
||||
u32 test = *(u32*)0x02800000; // this is 8 MB into the main memory
|
||||
u32 test2 = *(u32*)0x02000000; // this is 8 MB into the main memory
|
||||
|
||||
if (test == 0x00000000)
|
||||
return false;
|
||||
if (test == test2)
|
||||
return false;
|
||||
|
||||
// Try writing to this address. If the value is accepted, we are on a DSi in DSi mode.
|
||||
*(u32*)0x02800000 = 0x12345678;
|
||||
if (*(u32*)0x02800000 == 0x12345678)
|
||||
return true;
|
||||
|
||||
// The memory address does not exist, so we are on a DS (or a DSi in DS mode)
|
||||
return false;
|
||||
}
|
||||
31
trunk/arm9/source/dsi.h
Normal file
31
trunk/arm9/source/dsi.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* savegame_manager: a tool to backup and restore savegames from Nintendo
|
||||
* DS cartridges. Nintendo DS and all derivative names are trademarks
|
||||
* by Nintendo. EZFlash 3-in-1 is a trademark by EZFlash.
|
||||
*
|
||||
* dsi.h: header file for dsi.cpp
|
||||
*
|
||||
* Copyright (C) Pokedoc (2010)
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DSI
|
||||
#define HEADER_DSI
|
||||
|
||||
bool isDsi();
|
||||
|
||||
#endif
|
||||
|
|
@ -136,6 +136,8 @@ void hwBackup3in1()
|
|||
int size_blocks = 1 << max(0, (int8(size) - 18)); // ... in units of 0x40000 bytes - that's 256 kB
|
||||
uint8 type = auxspi_save_type();
|
||||
|
||||
// EZFlash Vi needs this line
|
||||
sysSetBusOwners(true, true);
|
||||
hwFormatNor(0, size_blocks);
|
||||
|
||||
// Dump save and write it to NOR
|
||||
|
|
@ -197,10 +199,8 @@ void hwDump3in1(uint32 size, const char *gamename)
|
|||
}
|
||||
char fullpath[512];
|
||||
sprintf(fullpath, "%s/%s", path, fname);
|
||||
//sprintf(fullpath, "%s", fname);
|
||||
displayMessage(fname);
|
||||
|
||||
// TODO: add support for smaller files!
|
||||
FILE *file = fopen(fullpath, "wb");
|
||||
if (size < 15)
|
||||
size_blocks = 1;
|
||||
|
|
@ -209,10 +209,11 @@ void hwDump3in1(uint32 size, const char *gamename)
|
|||
for (u32 i = 0; i < size_blocks; i++) {
|
||||
displayProgressBar(i+1, size_blocks);
|
||||
u32 LEN = 0x8000;
|
||||
// EZFlash Vi needs this line
|
||||
sysSetBusOwners(true, true);
|
||||
ReadNorFlash(data, i << 15, LEN);
|
||||
fwrite(data, 1, LEN, file);
|
||||
}
|
||||
//free(data);
|
||||
fclose(file);
|
||||
|
||||
displayPrintState("Done! Please power off...");
|
||||
|
|
@ -238,6 +239,8 @@ void hwRestore3in1()
|
|||
}
|
||||
int size_blocks = 1 << max(0, int8(size) - 18); // ... in units of 0x40000 bytes - that's 256 kB
|
||||
|
||||
// EZFlash Vi needs this line
|
||||
sysSetBusOwners(true, true);
|
||||
hwFormatNor(0, size_blocks);
|
||||
|
||||
// Read save and write it to NOR
|
||||
|
|
@ -252,6 +255,8 @@ void hwRestore3in1()
|
|||
for (int i = 0; i < size_blocks; i++) {
|
||||
displayProgressBar(i+1, size_blocks);
|
||||
fread(data, 1, 0x8000, file);
|
||||
// EZFlash Vi needs this line
|
||||
sysSetBusOwners(true, true);
|
||||
WriteNorFlash(i << 15, data, 0x8000);
|
||||
}
|
||||
CloseNorWrite();
|
||||
|
|
@ -321,6 +326,8 @@ void hwRestore3in1_b(uint32 size_file)
|
|||
for (unsigned int i = 0; i < num_blocks; i++) {
|
||||
if (i % (num_blocks >> 6) == 0)
|
||||
displayProgressBar(i+1, num_blocks);
|
||||
// EZFlash Vi needs this line
|
||||
//sysSetBusOwners(true, true);
|
||||
ReadNorFlash(data, i << shift, LEN);
|
||||
auxspi_write_data(i << shift, data, LEN, type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <dirent.h>
|
||||
|
||||
#include "gba.h"
|
||||
#include "dsi.h"
|
||||
#include "display.h"
|
||||
#include "dsCard.h"
|
||||
#include "hardware.h"
|
||||
|
|
@ -64,7 +65,7 @@ char bootdir[256] = "/";
|
|||
void mode_dsi()
|
||||
{
|
||||
// DSi mode, does nothing at the moment
|
||||
displayPrintState("DSi mode - unsupported!");
|
||||
displayPrintState("DSi mode - still unsupported!");
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
|
@ -273,11 +274,13 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Identify hardware and branch to corresponding mode
|
||||
displayPrintState("Identifying hardware...");
|
||||
chip_reset();
|
||||
// EZFlash Vi needs this line
|
||||
sysSetBusOwners(true, true);
|
||||
OpenNorWrite();
|
||||
ezflash = ReadNorFlashID();
|
||||
CloseNorWrite();
|
||||
dstype = 0; // DS/DSL, no idea how to identify DSi etc.
|
||||
// First attempt to identify the DSi. Read address > 8 MB
|
||||
dstype = isDsi() ? 1 : 0; // DS/DSL, no idea how to identify DSi etc.
|
||||
gba = gbaIsGame();
|
||||
|
||||
// Try to identify slot-2 device. Try opening slot-2 root directory
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<Project name="Savegame Manager"><MagicFolder excludeFolders="CVS;.svn" filter="*" name="arm9" path="arm9\"><MagicFolder excludeFolders="CVS;.svn" filter="*" name="build" path="build\"><File path=".map"></File><File path="auxspi.d"></File><File path="auxspi.o"></File><File path="auxspi_core.d"></File><File path="auxspi_core.o"></File><File path="display.d"></File><File path="display.o"></File><File path="dsCard.d"></File><File path="dsCard.o"></File><File path="fileselect.d"></File><File path="fileselect.o"></File><File path="ftplib.d"></File><File path="ftplib.o"></File><File path="gba.d"></File><File path="gba.o"></File><File path="hardware.d"></File><File path="hardware.o"></File><File path="ini.d"></File><File path="ini.o"></File><File path="main.d"></File><File path="main.o"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*" name="source" path="source\"><File path="auxspi.cpp"></File><File path="auxspi.h"></File><File path="auxspi_core.cpp"></File><File path="display.cpp"></File><File path="display.h"></File><File path="dsCard.cpp"></File><File path="dsCard.h"></File><File path="fileselect.cpp"></File><File path="fileselect.h"></File><File path="ftplib.c"></File><File path="ftplib.h"></File><File path="gba.cpp"></File><File path="gba.h"></File><File path="hardware.cpp"></File><File path="hardware.h"></File><File path="headings.i"></File><File path="ini.cpp"></File><File path="ini.h"></File><File path="iniconfig.h"></File><File path="iniheadings.h"></File><File path="inikeys.h"></File><File path="inilist.h"></File><File path="keys.i"></File><File path="libini.h"></File><File path="list.i"></File><File path="main.cpp"></File><File path="types.i"></File></MagicFolder><File path="Makefile"></File><File path="savegame_manager.arm9.elf"></File></MagicFolder><File path="Makefile"></File></Project>
|
||||
<Project name="Savegame Manager"><MagicFolder excludeFolders="CVS;.svn" filter="*" name="arm9" path="arm9\"><MagicFolder excludeFolders="CVS;.svn" filter="*" name="build" path="build\"><File path=".map"></File><File path="auxspi.d"></File><File path="auxspi.o"></File><File path="auxspi_core.d"></File><File path="auxspi_core.o"></File><File path="display.d"></File><File path="display.o"></File><File path="dsCard.d"></File><File path="dsCard.o"></File><File path="dsi.d"></File><File path="dsi.o"></File><File path="fileselect.d"></File><File path="fileselect.o"></File><File path="ftplib.d"></File><File path="ftplib.o"></File><File path="gba.d"></File><File path="gba.o"></File><File path="hardware.d"></File><File path="hardware.o"></File><File path="ini.d"></File><File path="ini.o"></File><File path="main.d"></File><File path="main.o"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*" name="source" path="source\"><File path="auxspi.cpp"></File><File path="auxspi.h"></File><File path="auxspi_core.cpp"></File><File path="display.cpp"></File><File path="display.h"></File><File path="dsCard.cpp"></File><File path="dsCard.h"></File><File path="dsi.cpp"></File><File path="dsi.h"></File><File path="fileselect.cpp"></File><File path="fileselect.h"></File><File path="ftplib.c"></File><File path="ftplib.h"></File><File path="gba.cpp"></File><File path="gba.h"></File><File path="hardware.cpp"></File><File path="hardware.h"></File><File path="headings.i"></File><File path="ini.cpp"></File><File path="ini.h"></File><File path="iniconfig.h"></File><File path="iniheadings.h"></File><File path="inikeys.h"></File><File path="inilist.h"></File><File path="keys.i"></File><File path="libini.h"></File><File path="list.i"></File><File path="main.cpp"></File><File path="types.i"></File></MagicFolder><File path="Makefile"></File><File path="savegame_manager.arm9.elf"></File></MagicFolder><File path="Makefile"></File></Project>
|
||||
Loading…
Reference in New Issue
Block a user