Merge pull request #223 from mjbudd77/master
Qt iNES Header Editor Feature, Lua emu.loadrom return value
This commit is contained in:
commit
b63f8657a5
|
@ -439,6 +439,7 @@ set(SRC_DRIVERS_SDL
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleUtilities.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleUtilities.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/iNesHeaderEditor.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TraceLogger.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TraceLogger.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp
|
||||||
|
|
|
@ -189,3 +189,64 @@ int parseFilepath( const char *filepath, char *dir, char *base, char *suffix )
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
// FCEU Data Entry Custom Validators
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
fceuDecIntValidtor::fceuDecIntValidtor( int min, int max, QObject *parent)
|
||||||
|
: QValidator(parent)
|
||||||
|
{
|
||||||
|
this->min = min;
|
||||||
|
this->max = max;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
QValidator::State fceuDecIntValidtor::validate(QString &input, int &pos) const
|
||||||
|
{
|
||||||
|
int i, v;
|
||||||
|
//printf("Validate: %i '%s'\n", input.size(), input.toStdString().c_str() );
|
||||||
|
|
||||||
|
if ( input.size() == 0 )
|
||||||
|
{
|
||||||
|
return QValidator::Acceptable;
|
||||||
|
}
|
||||||
|
std::string s = input.toStdString();
|
||||||
|
i=0;
|
||||||
|
|
||||||
|
if (s[i] == '-')
|
||||||
|
{
|
||||||
|
if ( min >= 0 )
|
||||||
|
{
|
||||||
|
return QValidator::Invalid;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if ( s[i] == '+' )
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s[i] == 0 )
|
||||||
|
{
|
||||||
|
return QValidator::Acceptable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isdigit(s[i]) )
|
||||||
|
{
|
||||||
|
while ( isdigit(s[i]) ) i++;
|
||||||
|
|
||||||
|
if ( s[i] == 0 )
|
||||||
|
{
|
||||||
|
v = strtol( s.c_str(), NULL, 0 );
|
||||||
|
|
||||||
|
if ( v < min )
|
||||||
|
{
|
||||||
|
return QValidator::Invalid;
|
||||||
|
}
|
||||||
|
else if ( v > max )
|
||||||
|
{
|
||||||
|
return QValidator::Invalid;
|
||||||
|
}
|
||||||
|
return QValidator::Acceptable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QValidator::Invalid;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// ConsoleUtilities.h
|
// ConsoleUtilities.h
|
||||||
|
#include <QValidator>
|
||||||
|
|
||||||
int getDirFromFile( const char *path, char *dir );
|
int getDirFromFile( const char *path, char *dir );
|
||||||
|
|
||||||
|
@ -7,3 +8,15 @@ const char *getRomFile( void );
|
||||||
int getFileBaseName( const char *filepath, char *base, char *suffix = NULL );
|
int getFileBaseName( const char *filepath, char *base, char *suffix = NULL );
|
||||||
|
|
||||||
int parseFilepath( const char *filepath, char *dir, char *base, char *suffix = NULL );
|
int parseFilepath( const char *filepath, char *dir, char *base, char *suffix = NULL );
|
||||||
|
|
||||||
|
|
||||||
|
class fceuDecIntValidtor : public QValidator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
fceuDecIntValidtor( int min, int max, QObject *parent);
|
||||||
|
|
||||||
|
QValidator::State validate(QString &input, int &pos) const;
|
||||||
|
private:
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
};
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
#include "Qt/ppuViewer.h"
|
#include "Qt/ppuViewer.h"
|
||||||
#include "Qt/NameTableViewer.h"
|
#include "Qt/NameTableViewer.h"
|
||||||
|
#include "Qt/iNesHeaderEditor.h"
|
||||||
#include "Qt/RamWatch.h"
|
#include "Qt/RamWatch.h"
|
||||||
#include "Qt/RamSearch.h"
|
#include "Qt/RamSearch.h"
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
|
@ -638,6 +639,14 @@ void consoleWin_t::createMainMenu(void)
|
||||||
|
|
||||||
debugMenu->addAction(codeDataLogAct);
|
debugMenu->addAction(codeDataLogAct);
|
||||||
|
|
||||||
|
// Debug -> iNES Header Editor
|
||||||
|
iNesEditAct = new QAction(tr("iNES Header Editor..."), this);
|
||||||
|
//iNesEditAct->setShortcut( QKeySequence(tr("Shift+F7")));
|
||||||
|
iNesEditAct->setStatusTip(tr("Open iNES Header Editor"));
|
||||||
|
connect(iNesEditAct, SIGNAL(triggered()), this, SLOT(openNesHeaderEditor(void)) );
|
||||||
|
|
||||||
|
debugMenu->addAction(iNesEditAct);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Movie
|
// Movie
|
||||||
movieMenu = menuBar()->addMenu(tr("Movie"));
|
movieMenu = menuBar()->addMenu(tr("Movie"));
|
||||||
|
@ -1265,6 +1274,24 @@ void consoleWin_t::openCodeDataLogger(void)
|
||||||
cdlWin->show();
|
cdlWin->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::openNesHeaderEditor(void)
|
||||||
|
{
|
||||||
|
iNesHeaderEditor_t *win;
|
||||||
|
|
||||||
|
//printf("Open iNES Header Editor Window\n");
|
||||||
|
|
||||||
|
win = new iNesHeaderEditor_t(this);
|
||||||
|
|
||||||
|
if ( win->isInitialized() )
|
||||||
|
{
|
||||||
|
win->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete win;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::openTraceLogger(void)
|
void consoleWin_t::openTraceLogger(void)
|
||||||
{
|
{
|
||||||
openTraceLoggerWindow(this);
|
openTraceLoggerWindow(this);
|
||||||
|
|
|
@ -102,6 +102,7 @@ class consoleWin_t : public QMainWindow
|
||||||
QAction *hexEditAct;
|
QAction *hexEditAct;
|
||||||
QAction *ppuViewAct;
|
QAction *ppuViewAct;
|
||||||
QAction *ntViewAct;
|
QAction *ntViewAct;
|
||||||
|
QAction *iNesEditAct;
|
||||||
QAction *openMovAct;
|
QAction *openMovAct;
|
||||||
QAction *stopMovAct;
|
QAction *stopMovAct;
|
||||||
QAction *recMovAct;
|
QAction *recMovAct;
|
||||||
|
@ -180,6 +181,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void emuSetFrameAdvDelay(void);
|
void emuSetFrameAdvDelay(void);
|
||||||
void openPPUViewer(void);
|
void openPPUViewer(void);
|
||||||
void openNTViewer(void);
|
void openNTViewer(void);
|
||||||
|
void openNesHeaderEditor(void);
|
||||||
void openCheats(void);
|
void openCheats(void);
|
||||||
void openRamWatch(void);
|
void openRamWatch(void);
|
||||||
void openRamSearch(void);
|
void openRamSearch(void);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,118 @@
|
||||||
|
// HotKeyConf.h
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
|
#include "Qt/main.h"
|
||||||
|
|
||||||
|
class iNES_HEADER;
|
||||||
|
|
||||||
|
class iNesHeaderEditor_t : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
iNesHeaderEditor_t(QWidget *parent = 0);
|
||||||
|
~iNesHeaderEditor_t(void);
|
||||||
|
|
||||||
|
bool isInitialized(void){ return initOK; };
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
QRadioButton *iNes1Btn;
|
||||||
|
QRadioButton *iNes2Btn;
|
||||||
|
QComboBox *mapperComboBox;
|
||||||
|
QLineEdit *mapperSubEdit;
|
||||||
|
QLineEdit *miscRomsEdit;
|
||||||
|
QComboBox *prgRomBox;
|
||||||
|
QComboBox *prgRamBox;
|
||||||
|
QComboBox *prgNvRamBox;
|
||||||
|
QComboBox *chrRomBox;
|
||||||
|
QComboBox *chrRamBox;
|
||||||
|
QComboBox *chrNvRamBox;
|
||||||
|
QComboBox *vsHwBox;
|
||||||
|
QComboBox *vsPpuBox;
|
||||||
|
QComboBox *extCslBox;
|
||||||
|
QComboBox *inputDevBox;
|
||||||
|
QCheckBox *trainerCBox;
|
||||||
|
QCheckBox *iNesUnOfBox;
|
||||||
|
QCheckBox *iNesDualRegBox;
|
||||||
|
QCheckBox *iNesBusCfltBox;
|
||||||
|
QCheckBox *iNesPrgRamBox;
|
||||||
|
QCheckBox *battNvRamBox;
|
||||||
|
QRadioButton *horzMirrorBtn;
|
||||||
|
QRadioButton *vertMirrorBtn;
|
||||||
|
QRadioButton *fourMirrorBtn;
|
||||||
|
QRadioButton *ntscRegionBtn;
|
||||||
|
QRadioButton *palRegionBtn;
|
||||||
|
QRadioButton *dendyRegionBtn;
|
||||||
|
QRadioButton *dualRegionBtn;
|
||||||
|
QRadioButton *normSysbtn;
|
||||||
|
QRadioButton *vsSysbtn;
|
||||||
|
QRadioButton *plySysbtn;
|
||||||
|
QRadioButton *extSysbtn;
|
||||||
|
QPushButton *restoreBtn;
|
||||||
|
QPushButton *saveAsBtn;
|
||||||
|
QPushButton *closeBtn;
|
||||||
|
QGroupBox *iNesUnOfGroupBox;
|
||||||
|
QGroupBox *sysGroupBox;
|
||||||
|
QGroupBox *vsGroupBox;
|
||||||
|
QGroupBox *extGroupBox;
|
||||||
|
QLabel *prgRamLbl;
|
||||||
|
QLabel *prgNvRamLbl;
|
||||||
|
QLabel *mapperSubLbl;
|
||||||
|
QLabel *chrRamLbl;
|
||||||
|
QLabel *chrNvRamLbl;
|
||||||
|
QLabel *inputDevLbl;
|
||||||
|
QLabel *miscRomsLbl;
|
||||||
|
iNES_HEADER *iNesHdr;
|
||||||
|
|
||||||
|
bool initOK;
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool openFile(void);
|
||||||
|
void printHeader(iNES_HEADER* _header);
|
||||||
|
bool loadHeader(iNES_HEADER *header);
|
||||||
|
bool SaveINESFile(const char* path, iNES_HEADER* header);
|
||||||
|
bool WriteHeaderData(iNES_HEADER* header);
|
||||||
|
void setHeaderData(iNES_HEADER *header);
|
||||||
|
void showErrorMsgWindow(const char *str);
|
||||||
|
void ToggleINES20(bool ines20);
|
||||||
|
void ToggleUnofficialPropertiesEnabled(bool ines20, bool check);
|
||||||
|
void ToggleUnofficialExtraRegionCode(bool ines20, bool unofficial_check, bool check);
|
||||||
|
void ToggleUnofficialPrgRamPresent(bool ines20, bool unofficial_check, bool check);
|
||||||
|
void ToggleVSSystemGroup(bool enable);
|
||||||
|
void ToggleExtendSystemList(bool enable);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void closeWindow(void);
|
||||||
|
private slots:
|
||||||
|
void saveHeader(void);
|
||||||
|
void saveFileAs(void);
|
||||||
|
void restoreHeader(void);
|
||||||
|
void iNes1Clicked(bool checked);
|
||||||
|
void iNes2Clicked(bool checked);
|
||||||
|
void normSysClicked(bool checked);
|
||||||
|
void vsSysClicked(bool checked);
|
||||||
|
void plySysClicked(bool checked);
|
||||||
|
void extSysClicked(bool checked);
|
||||||
|
void unofficialStateChange(int state);
|
||||||
|
void unofficialPrgRamStateChange(int state);
|
||||||
|
void unofficialDualRegionStateChange(int state);
|
||||||
|
|
||||||
|
};
|
|
@ -600,7 +600,7 @@ static int emu_loadrom(lua_State *L)
|
||||||
const char* str = lua_tostring(L,1);
|
const char* str = lua_tostring(L,1);
|
||||||
|
|
||||||
//special case: reload rom
|
//special case: reload rom
|
||||||
if(!str) {
|
if (!str) {
|
||||||
ReloadRom();
|
ReloadRom();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -611,10 +611,14 @@ static int emu_loadrom(lua_State *L)
|
||||||
if (!ALoad(nameo)) {
|
if (!ALoad(nameo)) {
|
||||||
extern void LoadRecentRom(int slot);
|
extern void LoadRecentRom(int slot);
|
||||||
LoadRecentRom(0);
|
LoadRecentRom(0);
|
||||||
return 0;
|
}
|
||||||
} else {
|
if ( GameInfo )
|
||||||
|
{
|
||||||
|
//printf("Currently Loaded ROM: '%s'\n", GameInfo->filename );
|
||||||
|
lua_pushstring(L, GameInfo->filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
const char *nameo2 = luaL_checkstring(L,1);
|
const char *nameo2 = luaL_checkstring(L,1);
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
|
@ -623,16 +627,22 @@ static int emu_loadrom(lua_State *L)
|
||||||
{
|
{
|
||||||
strncpy(nameo, nameo2, sizeof(nameo));
|
strncpy(nameo, nameo2, sizeof(nameo));
|
||||||
}
|
}
|
||||||
//printf("Load ROM: '%s'\n", nameo );
|
//printf("Attempting to Load ROM: '%s'\n", nameo );
|
||||||
if (!LoadGame(nameo, true))
|
if (!LoadGame(nameo, true))
|
||||||
{
|
{
|
||||||
|
//printf("Failed to Load ROM: '%s'\n", nameo );
|
||||||
reloadLastGame();
|
reloadLastGame();
|
||||||
return 0;
|
}
|
||||||
} else {
|
if ( GameInfo )
|
||||||
|
{
|
||||||
|
//printf("Currently Loaded ROM: '%s'\n", GameInfo->filename );
|
||||||
|
lua_pushstring(L, GameInfo->filename);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue