Slot-2:
- Clean up GBA Cartridge device code, and also add the ability to have the SRAM file be on a different file path from the ROM file. - Force Rumble Pak to turn off rumble upon disconnect. - Fix file path issue when trying to use a disk image file for an MPCF device.
This commit is contained in:
parent
38f02e0804
commit
e568f8c4fd
|
@ -320,51 +320,60 @@ public:
|
|||
|
||||
virtual Slot2Info const* info()
|
||||
{
|
||||
static Slot2InfoSimple info("GBA cartridge", "GBA cartridge in slot", 0x03);
|
||||
static Slot2InfoSimple info("GBA Cartridge", "GBA cartridge in slot", 0x03);
|
||||
return &info;
|
||||
}
|
||||
|
||||
virtual void connect()
|
||||
{
|
||||
Close();
|
||||
romSize = 0;
|
||||
currentROMPos = 0;
|
||||
sramSize = 0;
|
||||
currentSRAMPos = 0;
|
||||
|
||||
if (gameInfo.romsize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GBACartridge_RomPath.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(GBACartridge_RomPath.c_str(), "self"))
|
||||
{
|
||||
GBACartridge_RomPath = path.path;
|
||||
GBACartridge_SRAMPath = Path::GetFileNameWithoutExt(GBACartridge_RomPath) + "." + GBA_SRAM_FILE_EXT;
|
||||
}
|
||||
|
||||
printf("GBASlot opening ROM: %s", GBACartridge_RomPath.c_str());
|
||||
fROM = new EMUFILE_FILE(GBACartridge_RomPath, "rb");
|
||||
if (fROM->fail())
|
||||
{
|
||||
printf(" - Failed\n");
|
||||
Close();
|
||||
romSize = 0;
|
||||
currentROMPos = 0;
|
||||
sramSize = 0;
|
||||
currentSRAMPos = 0;
|
||||
|
||||
if (gameInfo.romsize == 0) return;
|
||||
|
||||
if (!strcasecmp(GBAgameName, "self"))
|
||||
strcpy(GBAgameName, path.path.c_str());
|
||||
|
||||
if (!strlen(GBAgameName)) return;
|
||||
|
||||
printf("GBASlot opening ROM: %s", GBAgameName);
|
||||
|
||||
fROM = new EMUFILE_FILE(GBAgameName, "rb");
|
||||
if (fROM->fail())
|
||||
goto FAIL;
|
||||
|
||||
romSize = fROM->size();
|
||||
printf(" - Success (%u bytes)\n", romSize);
|
||||
|
||||
//try loading the sram. build the filename from the rom, and expect it to be a .sav
|
||||
char *dot = strrchr(GBAgameName, '.');
|
||||
if(!dot) return;
|
||||
|
||||
std::string sram_fname = GBAgameName;
|
||||
sram_fname.resize(dot-GBAgameName);
|
||||
sram_fname += ".sav";
|
||||
fSRAM = new EMUFILE_FILE(sram_fname.c_str(), "rb+");
|
||||
if(fSRAM->fail())
|
||||
{
|
||||
delete fSRAM; fSRAM = NULL;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
romSize = fROM->size();
|
||||
printf(" - Success (%u bytes)\n", romSize);
|
||||
|
||||
// Load the GBA cartridge SRAM.
|
||||
fSRAM = new EMUFILE_FILE(GBACartridge_SRAMPath, "rb+");
|
||||
if(fSRAM->fail())
|
||||
{
|
||||
delete fSRAM;
|
||||
fSRAM = NULL;
|
||||
printf("GBASlot did not load associated SRAM.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sramSize = fSRAM->size();
|
||||
saveType = getSaveTypeGBA();
|
||||
printf("GBASlot found SRAM %s (%s - %u bytes)\n", sram_fname.c_str(), (saveType == 0xFF)?"Unknown":saveTypes[saveType], sramSize);
|
||||
printf("GBASlot found SRAM %s (%s - %u bytes)\n", GBACartridge_SRAMPath.c_str(), (saveType == 0xFF)?"Unknown":saveTypes[saveType], sramSize);
|
||||
gbaFlash.size = sramSize;
|
||||
if (gbaFlash.size <= (64 * 1024))
|
||||
{
|
||||
|
@ -376,14 +385,7 @@ public:
|
|||
gbaFlash.idDevice = 0x09;
|
||||
gbaFlash.idManufacturer = 0xC2;
|
||||
}
|
||||
|
||||
//success!
|
||||
return;
|
||||
}
|
||||
|
||||
FAIL:
|
||||
Close();
|
||||
printf(" - Failed\n");
|
||||
}
|
||||
|
||||
virtual void disconnect()
|
||||
|
|
|
@ -84,6 +84,15 @@ static BOOL cflash_init()
|
|||
sFlashPath = CFlash_Path;
|
||||
INFO("Using CFlash directory: %s\n", sFlashPath.c_str());
|
||||
}
|
||||
else if(CFlash_Mode == ADDON_CFLASH_MODE_File)
|
||||
{
|
||||
sFlashPath = CFlash_Path;
|
||||
INFO("Using CFlash disk image file %s\n", sFlashPath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (sFlashPath == "") return FALSE;
|
||||
|
||||
|
@ -112,8 +121,6 @@ static BOOL cflash_init()
|
|||
}
|
||||
else
|
||||
{
|
||||
sFlashPath = CFlash_Path;
|
||||
INFO("Using CFlash disk image file %s\n", sFlashPath.c_str());
|
||||
file = new EMUFILE_FILE(sFlashPath.c_str(),"rb+");
|
||||
if(file->fail())
|
||||
{
|
||||
|
|
|
@ -38,6 +38,11 @@ public:
|
|||
if (!FeedbackON) return;
|
||||
FeedbackON(false);
|
||||
}
|
||||
|
||||
virtual void disconnect()
|
||||
{
|
||||
FeedbackON(false);
|
||||
}
|
||||
|
||||
virtual void writeWord(u8 PROCNUM, u32 addr, u16 val)
|
||||
{
|
||||
|
|
|
@ -27,8 +27,9 @@ ADDON_CFLASH_MODE CFlash_Mode = ADDON_CFLASH_MODE_RomPath;
|
|||
//it should be viewed as a parameter for the above.
|
||||
std::string CFlash_Path;
|
||||
|
||||
char GBAgameName[MAX_PATH] = {0};
|
||||
|
||||
// GBA file paths for cartridge and SRAM
|
||||
std::string GBACartridge_RomPath;
|
||||
std::string GBACartridge_SRAMPath;
|
||||
|
||||
ISlot2Interface* slot2_List[NDS_SLOT2_COUNT] = {0};
|
||||
|
||||
|
@ -247,7 +248,7 @@ NDS_SLOT2_TYPE slot2_DetermineTypeByGameCode(const char *theGameCode)
|
|||
{"CB6", NDS_SLOT2_PADDLE}, // Space Bust-A-Move
|
||||
{"YXX", NDS_SLOT2_PADDLE}, // Space Invaders Extreme
|
||||
{"CV8", NDS_SLOT2_PADDLE}, // Space Invaders Extreme 2
|
||||
{"AP2", NDS_SLOT2_RUMBLEPAK}, // Metroid Prime Hunters Pinball
|
||||
{"AP2", NDS_SLOT2_RUMBLEPAK}, // Metroid Prime Pinball
|
||||
};
|
||||
|
||||
for(size_t i = 0; i < ARRAY_SIZE(gameCodeDeviceTypes); i++)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "types.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define GBA_SRAM_FILE_EXT "sav"
|
||||
|
||||
class Slot2Info
|
||||
{
|
||||
public:
|
||||
|
@ -134,7 +136,8 @@ bool slot2_read(u32 addr, T &val);
|
|||
|
||||
|
||||
// =================================================================================
|
||||
extern char GBAgameName[MAX_PATH]; // file name for GBA game (rom)
|
||||
extern std::string GBACartridge_RomPath;
|
||||
extern std::string GBACartridge_SRAMPath;
|
||||
extern void (*FeedbackON)(bool enable); // feedback on/off
|
||||
|
||||
enum ADDON_CFLASH_MODE
|
||||
|
|
|
@ -43,6 +43,7 @@ SPaddle tmp_Paddle;
|
|||
//they are named very verbosely to distinguish them from the currently-configured values in addons.cpp
|
||||
std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
|
||||
UINT win32_CFlash_cfgMode;
|
||||
std::string win32_GBA_cfgRomPath;
|
||||
|
||||
INT_PTR CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
|
@ -560,7 +561,7 @@ void GBAslotDialog(HWND hwnd)
|
|||
last_type = temp_type;
|
||||
strcpy(tmp_cflash_filename, win32_CFlash_cfgFileName.c_str());
|
||||
strcpy(tmp_cflash_path, win32_CFlash_cfgDirectory.c_str());
|
||||
strcpy(tmp_gbagame_filename, GBAgameName);
|
||||
strcpy(tmp_gbagame_filename, win32_GBA_cfgRomPath.c_str());
|
||||
memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar));
|
||||
memcpy(&tmp_Piano, &Piano, sizeof(Piano));
|
||||
memcpy(&tmp_Paddle, &Paddle, sizeof(Paddle));
|
||||
|
@ -597,8 +598,9 @@ void GBAslotDialog(HWND hwnd)
|
|||
WritePrivateProfileInt("Slot2.Paddle","INC",Paddle.INC,IniName);
|
||||
break;
|
||||
case NDS_SLOT2_GBACART:
|
||||
strcpy(GBAgameName, tmp_gbagame_filename);
|
||||
WritePrivateProfileString("Slot2.GBAgame","filename",GBAgameName,IniName);
|
||||
win32_GBA_cfgRomPath = tmp_gbagame_filename;
|
||||
WritePrivateProfileString("Slot2.GBAgame", "filename", tmp_gbagame_filename, IniName);
|
||||
WIN_InstallGBACartridge();
|
||||
break;
|
||||
case NDS_SLOT2_GUITARGRIP:
|
||||
memcpy(&Guitar, &tmp_Guitar, sizeof(tmp_Guitar));
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
extern std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
|
||||
extern UINT win32_CFlash_cfgMode;
|
||||
extern std::string win32_GBA_cfgRomPath;
|
||||
|
||||
extern void GBAslotDialog(HWND hwnd);
|
||||
|
||||
|
|
|
@ -3170,10 +3170,11 @@ int _main()
|
|||
win32_CFlash_cfgMode = GetPrivateProfileInt("Slot2.CFlash", "fileMode", ADDON_CFLASH_MODE_RomPath, IniName);
|
||||
win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", "");
|
||||
win32_CFlash_cfgFileName = GetPrivateProfileStdString("Slot2.CFlash", "filename", "");
|
||||
GetPrivateProfileString("Slot2.GBAgame", "filename", "", GBAgameName, MAX_PATH, IniName);
|
||||
win32_GBA_cfgRomPath = GetPrivateProfileStdString("Slot2.GBAgame", "filename", "");
|
||||
|
||||
cmdline.process_addonCommands();
|
||||
WIN_InstallCFlash();
|
||||
WIN_InstallGBACartridge();
|
||||
|
||||
slot1_R4_path_type = cmdline._slot1_fat_dir_type;
|
||||
|
||||
|
@ -3200,7 +3201,7 @@ int _main()
|
|||
if(cmdline.gbaslot_rom != "")
|
||||
{
|
||||
slot2_device_type = NDS_SLOT2_GBACART;
|
||||
strcpy(GBAgameName, cmdline.gbaslot_rom.c_str());
|
||||
win32_GBA_cfgRomPath = cmdline.gbaslot_rom;
|
||||
}
|
||||
|
||||
switch (slot2_device_type)
|
||||
|
@ -3214,7 +3215,7 @@ int _main()
|
|||
case NDS_SLOT2_RUMBLEPAK:
|
||||
break;
|
||||
case NDS_SLOT2_GBACART:
|
||||
if (!strlen(GBAgameName))
|
||||
if (win32_GBA_cfgRomPath.empty())
|
||||
{
|
||||
slot2_device_type = NDS_SLOT2_NONE;
|
||||
break;
|
||||
|
@ -7180,6 +7181,12 @@ void WIN_InstallCFlash()
|
|||
}
|
||||
}
|
||||
|
||||
void WIN_InstallGBACartridge()
|
||||
{
|
||||
GBACartridge_RomPath = win32_GBA_cfgRomPath;
|
||||
GBACartridge_SRAMPath = Path::GetFileNameWithoutExt(win32_GBA_cfgRomPath) + "." + GBA_SRAM_FILE_EXT;
|
||||
}
|
||||
|
||||
// ================================================================= DDraw
|
||||
u32 DDRAW::create(HWND hwnd)
|
||||
{
|
||||
|
|
|
@ -67,6 +67,7 @@ extern int backupmemorytype;
|
|||
extern u32 backupmemorysize;
|
||||
|
||||
void WIN_InstallCFlash();
|
||||
void WIN_InstallGBACartridge();
|
||||
|
||||
#define IDM_RECENT_RESERVED0 65500
|
||||
#define IDM_RECENT_RESERVED1 65501
|
||||
|
|
Loading…
Reference in New Issue