win32: fix virtual from constructor random crash bug in tool windows; fix some more finicky cflash configuration; core: add devkitpro argv support; add --gbaslot-rom commandline
This commit is contained in:
parent
4327d8725a
commit
56468eda49
|
@ -6,6 +6,8 @@ General/Core:
|
|||
bug: fix rom close memory corruption
|
||||
bug: fix div and sqrt busy flag bug
|
||||
bug: fix vectest
|
||||
enh: support devkitpro argv
|
||||
enh: add gbaslot-rom commandline
|
||||
|
||||
Graphics:
|
||||
bug: fix a mistakenly rendered OBJ window
|
||||
|
|
|
@ -2663,10 +2663,8 @@ void NDS_Reset()
|
|||
|
||||
resetUserInput();
|
||||
|
||||
/*
|
||||
* Setup a copy of the firmware user settings in memory.
|
||||
* (this is what the DS firmware would do).
|
||||
*/
|
||||
//Setup a copy of the firmware user settings in memory.
|
||||
//(this is what the DS firmware would do).
|
||||
{
|
||||
u8 temp_buffer[NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT];
|
||||
int fw_index;
|
||||
|
@ -2688,6 +2686,30 @@ void NDS_Reset()
|
|||
// Write the header checksum to memory (the firmware needs it to see the cart)
|
||||
_MMU_write16<ARMCPU_ARM9>(0x027FF808, T1ReadWord(MMU.CART_ROM, 0x15E));
|
||||
|
||||
//--------------------------------
|
||||
//setup the homebrew argv
|
||||
//this is useful for nitrofs apps which are emulating themselves via cflash
|
||||
//struct __argv {
|
||||
// int argvMagic; //!< argv magic number, set to 0x5f617267 ('_arg') if valid
|
||||
// char *commandLine; //!< base address of command line, set of null terminated strings
|
||||
// int length; //!< total length of command line
|
||||
// int argc; //!< internal use, number of arguments
|
||||
// char **argv; //!< internal use, argv pointer
|
||||
//};
|
||||
std::string rompath = "fat:/" + path.RomName;
|
||||
const u32 kCommandline = 0x027E0000;
|
||||
//const u32 kCommandline = 0x027FFF84;
|
||||
_MMU_write32<ARMCPU_ARM9>(0x027FFF70, 0x5f617267);
|
||||
_MMU_write32<ARMCPU_ARM9>(0x027FFF74, kCommandline); //(commandline starts here)
|
||||
_MMU_write32<ARMCPU_ARM9>(0x027FFF78, rompath.size()+1);
|
||||
//0x027FFF7C (argc)
|
||||
//0x027FFF80 (argv)
|
||||
for(size_t i=0;i<rompath.size();i++)
|
||||
_MMU_write08<ARMCPU_ARM9>(kCommandline+i, rompath[i]);
|
||||
_MMU_write08<ARMCPU_ARM9>(kCommandline+rompath.size(), 0);
|
||||
//--------------------------------
|
||||
|
||||
|
||||
// Save touchscreen calibration info in a structure
|
||||
// so we can easily access it at any time
|
||||
TSCal.adc.x1 = _MMU_read16<ARMCPU_ARM9>(0x027FFC80 + 0x58);
|
||||
|
|
|
@ -25,14 +25,12 @@
|
|||
#include "addons.h"
|
||||
#include <string>
|
||||
|
||||
std::string CFlash_Path;
|
||||
//this is the currently-configured cflash mode
|
||||
ADDON_CFLASH_MODE CFlash_Mode;
|
||||
|
||||
|
||||
//char CFlashName[MAX_PATH];
|
||||
//char CFlashPath[MAX_PATH];
|
||||
//u8 CFlashUseRomPath = TRUE;
|
||||
//u8 CFlashUsePath = TRUE;
|
||||
//this is the currently-configured path (directory or filename) for cflash.
|
||||
//it should be viewed as a parameter for the above.
|
||||
std::string CFlash_Path;
|
||||
|
||||
char GBAgameName[MAX_PATH];
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ CommandLine::CommandLine()
|
|||
, _record_movie_file(0)
|
||||
, _cflash_image(0)
|
||||
, _cflash_path(0)
|
||||
, _gbaslot_rom(0)
|
||||
, _bios_arm9(NULL)
|
||||
, _bios_arm7(NULL)
|
||||
, _bios_swi(0)
|
||||
|
@ -69,6 +70,7 @@ void CommandLine::loadCommonOptions()
|
|||
{ "start-paused", 0, 0, G_OPTION_ARG_NONE, &start_paused, "Indicates that emulation should start paused", "START_PAUSED"},
|
||||
{ "cflash-image", 0, 0, G_OPTION_ARG_FILENAME, &_cflash_image, "Requests cflash in gbaslot with fat image at this path", "CFLASH_IMAGE"},
|
||||
{ "cflash-path", 0, 0, G_OPTION_ARG_FILENAME, &_cflash_path, "Requests cflash in gbaslot with filesystem rooted at this path", "CFLASH_PATH"},
|
||||
{ "gbaslot-rom", 0, 0, G_OPTION_ARG_FILENAME, &_gbaslot_rom, "Requests this GBA rom in gbaslot", "GBASLOT_ROM"},
|
||||
{ "bios-arm9", 0, 0, G_OPTION_ARG_FILENAME, &_bios_arm9, "Uses the arm9 bios provided at the specified path", "BIOS_ARM9_PATH"},
|
||||
{ "bios-arm7", 0, 0, G_OPTION_ARG_FILENAME, &_bios_arm7, "Uses the arm7 bios provided at the specified path", "BIOS_ARM7_PATH"},
|
||||
{ "bios-swi", 0, 0, G_OPTION_ARG_INT, &_bios_swi, "Uses SWI from the provided bios files", "BIOS_SWI"},
|
||||
|
@ -100,6 +102,7 @@ bool CommandLine::parse(int argc,char **argv)
|
|||
if(_record_movie_file) record_movie_file = _record_movie_file;
|
||||
if(_cflash_image) cflash_image = _cflash_image;
|
||||
if(_cflash_path) cflash_path = _cflash_path;
|
||||
if(_gbaslot_rom) gbaslot_rom = _gbaslot_rom;
|
||||
|
||||
if(_num_cores != -1) CommonSettings.num_cores = _num_cores;
|
||||
|
||||
|
@ -147,6 +150,10 @@ bool CommandLine::validate()
|
|||
g_printerr("If either bios-swi is used, bios-arm9 and bios-arm7 must be specified.\n");
|
||||
}
|
||||
|
||||
if(_cflash_image && _gbaslot_rom || _cflash_path && _gbaslot_rom) {
|
||||
g_printerr("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
int start_paused;
|
||||
std::string cflash_image;
|
||||
std::string cflash_path;
|
||||
std::string gbaslot_rom;
|
||||
|
||||
//load up the common commandline options
|
||||
void loadCommonOptions();
|
||||
|
@ -73,6 +74,7 @@ private:
|
|||
char* _record_movie_file;
|
||||
char* _cflash_image;
|
||||
char* _cflash_path;
|
||||
char* _gbaslot_rom;
|
||||
char* _bios_arm9, *_bios_arm7;
|
||||
int _bios_swi;
|
||||
int _num_cores;
|
||||
|
|
|
@ -1791,6 +1791,12 @@ common_gtk_main( struct configured_features *my_config)
|
|||
if (my_config->is_cflash_configured)
|
||||
addon_type = NDS_ADDON_CFLASH;
|
||||
|
||||
if(my_config->gbaslot_rom != "")
|
||||
{
|
||||
addon_type = NDS_ADDON_GBAGAME;
|
||||
strcpy(GBAgameName, my_config->gbaslot_rom.c_str());
|
||||
}
|
||||
|
||||
switch (addon_type) {
|
||||
case NDS_ADDON_CFLASH:
|
||||
case NDS_ADDON_RUMBLEPAK:
|
||||
|
|
|
@ -135,14 +135,21 @@ CToolWindow::CToolWindow(char* className, WNDPROC proc, char* title, int width,
|
|||
rc.right - rc.left, rc.bottom - rc.top, HWND_DESKTOP, NULL, hAppInst, (LPVOID)this);
|
||||
}
|
||||
|
||||
CToolWindow::CToolWindow(int ID, DLGPROC proc, char* title)
|
||||
CToolWindow::CToolWindow(int _ID, DLGPROC _proc, char* _title)
|
||||
: hWnd(NULL)
|
||||
, ID(_ID)
|
||||
, proc(_proc)
|
||||
, title(_title)
|
||||
{
|
||||
}
|
||||
|
||||
void CToolWindow::PostInitialize()
|
||||
{
|
||||
hWnd = CreateDialogParam(hAppInst, MAKEINTRESOURCE(ID), HWND_DESKTOP, proc, (LPARAM)this);
|
||||
if (hWnd == NULL)
|
||||
return;
|
||||
|
||||
SetWindowText(hWnd, title);
|
||||
SetWindowText(hWnd, title.c_str());
|
||||
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hAppInst, "ICONDESMUME"));
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,9 @@ public:
|
|||
// can unregister any window classes they use.
|
||||
virtual ~CToolWindow();
|
||||
|
||||
// this must be called by the derived class constructor. sigh.
|
||||
void PostInitialize();
|
||||
|
||||
// Show(), Hide()
|
||||
// These ones are quite self-explanatory, I guess.
|
||||
void Show() { ShowWindow(hWnd, SW_SHOW); }
|
||||
|
@ -102,6 +105,11 @@ public:
|
|||
|
||||
// Handle to the window.
|
||||
HWND hWnd;
|
||||
|
||||
private:
|
||||
int ID;
|
||||
DLGPROC proc;
|
||||
std::string title;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -304,6 +304,7 @@ CIORegView::CIORegView()
|
|||
{
|
||||
liveIORegViews.push_back(this);
|
||||
anyLiveIORegViews = true;
|
||||
PostInitialize();
|
||||
}
|
||||
|
||||
CIORegView::~CIORegView()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gbaslot_config.h"
|
||||
#include <windowsx.h>
|
||||
#include "resource.h"
|
||||
#include "main.h"
|
||||
#include "debug.h"
|
||||
#include "../addons.h"
|
||||
#include "../NDSSystem.h"
|
||||
|
@ -39,7 +40,10 @@ bool _OKbutton = false;
|
|||
SGuitar tmp_Guitar;
|
||||
bool needReset = true;
|
||||
|
||||
std::string CFlashPath, CFlashName;
|
||||
//these are the remembered preset values for directory and filename
|
||||
//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;
|
||||
|
||||
INT_PTR CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
|
@ -442,8 +446,8 @@ void GBAslotDialog(HWND hwnd)
|
|||
{
|
||||
temp_type = addon_type;
|
||||
last_type = temp_type;
|
||||
strcpy(tmp_cflash_filename, CFlashName.c_str());
|
||||
strcpy(tmp_cflash_path, CFlashPath.c_str());
|
||||
strcpy(tmp_cflash_filename, win32_CFlash_cfgFileName.c_str());
|
||||
strcpy(tmp_cflash_path, win32_CFlash_cfgDirectory.c_str());
|
||||
strcpy(tmp_gbagame_filename, GBAgameName);
|
||||
memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar));
|
||||
tmp_CFlashMode = CFlash_Mode;
|
||||
|
@ -461,16 +465,17 @@ void GBAslotDialog(HWND hwnd)
|
|||
needReset = false;
|
||||
break;
|
||||
case NDS_ADDON_CFLASH:
|
||||
CFlash_Mode = tmp_CFlashMode;
|
||||
//save current values for win32 configuration
|
||||
//(no tmp for mode, a little weird but thats just how it evolved)
|
||||
win32_CFlash_cfgMode = CFlash_Mode;
|
||||
win32_CFlash_cfgDirectory = tmp_cflash_path;
|
||||
win32_CFlash_cfgFileName = tmp_cflash_filename;
|
||||
WritePrivateProfileInt("GBAslot.CFlash","fileMode",CFlash_Mode,IniName);
|
||||
WritePrivateProfileString("GBAslot.CFlash","path",tmp_cflash_path,IniName);
|
||||
WritePrivateProfileString("GBAslot.CFlash","filename",tmp_cflash_filename,IniName);
|
||||
if(CFlash_Mode == ADDON_CFLASH_MODE_Path)
|
||||
CFlash_Path = tmp_cflash_path;
|
||||
else if(CFlash_Mode == ADDON_CFLASH_MODE_RomPath)
|
||||
CFlash_Path = "";
|
||||
else
|
||||
CFlash_Path = tmp_cflash_filename;
|
||||
|
||||
WIN_InstallCFlash();
|
||||
|
||||
needReset = true;
|
||||
break;
|
||||
case NDS_ADDON_RUMBLEPAK:
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include "../common.h"
|
||||
#include <string>
|
||||
|
||||
extern std::string CFlashPath, CFlashName;
|
||||
extern std::string win32_CFlash_cfgDirectory, win32_CFlash_cfgFileName;
|
||||
extern UINT win32_CFlash_cfgMode;
|
||||
|
||||
extern void GBAslotDialog(HWND hwnd);
|
||||
|
||||
|
|
|
@ -2188,36 +2188,14 @@ int _main()
|
|||
GetINIPath();
|
||||
|
||||
addon_type = GetPrivateProfileInt("GBAslot", "type", NDS_ADDON_NONE, IniName);
|
||||
UINT CFlashFileMode = GetPrivateProfileInt("GBAslot.CFlash", "fileMode", 2, IniName);
|
||||
|
||||
CFlashPath = GetPrivateProfileStdString("GBAslot.CFlash", "path", "");
|
||||
CFlashName = GetPrivateProfileStdString("GBAslot.CFlash", "filename", "");
|
||||
win32_CFlash_cfgMode = GetPrivateProfileInt("GBAslot.CFlash", "fileMode", 2, IniName);
|
||||
win32_CFlash_cfgDirectory = GetPrivateProfileStdString("GBAslot.CFlash", "path", "");
|
||||
win32_CFlash_cfgFileName = GetPrivateProfileStdString("GBAslot.CFlash", "filename", "");
|
||||
GetPrivateProfileString("GBAslot.GBAgame", "filename", "", GBAgameName, MAX_PATH, IniName);
|
||||
|
||||
if(CFlashFileMode==ADDON_CFLASH_MODE_Path)
|
||||
{
|
||||
CFlash_Path = CFlashPath;
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_Path;
|
||||
}
|
||||
else
|
||||
if(CFlashFileMode==ADDON_CFLASH_MODE_File)
|
||||
{
|
||||
CFlash_Path = CFlashName;
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_File;
|
||||
}
|
||||
else
|
||||
{
|
||||
CFlash_Path = "";
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_RomPath;
|
||||
}
|
||||
WIN_InstallCFlash();
|
||||
|
||||
//init_configured_features( &my_config);
|
||||
/*if ( !fill_configured_features( &my_config, lpszArgument)) {
|
||||
MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK);
|
||||
return 0;
|
||||
}*/
|
||||
ColorCtrl_Register();
|
||||
|
||||
if (!RegWndClass("DeSmuME", WindowProcedure, CS_DBLCLKS, LoadIcon(hAppInst, "ICONDESMUME")))
|
||||
{
|
||||
MessageBox(NULL, "Error registering windows class", "DeSmuME", MB_OK);
|
||||
|
@ -2308,7 +2286,7 @@ int _main()
|
|||
|
||||
gpu_SetRotateScreen(video.rotation);
|
||||
|
||||
/* default the firmware settings, they may get changed later */
|
||||
//default the firmware settings, they may get changed later
|
||||
NDS_FillDefaultFirmwareConfigData( &win_fw_config);
|
||||
|
||||
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
|
||||
|
@ -2364,11 +2342,16 @@ int _main()
|
|||
addon_type = NDS_ADDON_CFLASH;
|
||||
//push the commandline-provided options into the current config slots
|
||||
if(CFlash_Mode == ADDON_CFLASH_MODE_Path)
|
||||
CFlashPath = CFlash_Path;
|
||||
win32_CFlash_cfgDirectory = CFlash_Path;
|
||||
else
|
||||
CFlashName = CFlash_Path;
|
||||
win32_CFlash_cfgFileName = CFlash_Path;
|
||||
}
|
||||
|
||||
if(cmdline.gbaslot_rom != "")
|
||||
{
|
||||
addon_type = NDS_ADDON_GBAGAME;
|
||||
strcpy(GBAgameName, cmdline.gbaslot_rom.c_str());
|
||||
}
|
||||
|
||||
switch (addon_type)
|
||||
{
|
||||
|
@ -5876,3 +5859,26 @@ const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, boo
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//TODO maybe should be repurposed into an entire WIN_InstallAddon
|
||||
void WIN_InstallCFlash()
|
||||
{
|
||||
//install cflash values into emulator
|
||||
if(win32_CFlash_cfgMode==ADDON_CFLASH_MODE_Path)
|
||||
{
|
||||
CFlash_Path = win32_CFlash_cfgDirectory;
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_Path;
|
||||
}
|
||||
else
|
||||
if(win32_CFlash_cfgMode==ADDON_CFLASH_MODE_File)
|
||||
{
|
||||
CFlash_Path = win32_CFlash_cfgFileName;
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_File;
|
||||
}
|
||||
else
|
||||
{
|
||||
CFlash_Path = "";
|
||||
CFlash_Mode = ADDON_CFLASH_MODE_RomPath;
|
||||
}
|
||||
|
||||
}
|
|
@ -32,5 +32,6 @@ extern void Change3DCoreWithFallbackAndSave(int newCore, int fallbackCore=GPU3D_
|
|||
extern int backupmemorytype;
|
||||
extern u32 backupmemorysize;
|
||||
|
||||
void WIN_InstallCFlash();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@ CMemView::CMemView()
|
|||
, selAddress(0x00000000)
|
||||
, selNewVal(0x00000000)
|
||||
{
|
||||
PostInitialize();
|
||||
}
|
||||
|
||||
CMemView::~CMemView()
|
||||
|
|
Loading…
Reference in New Issue