parent
60070208a4
commit
350627e09c
|
@ -14,6 +14,8 @@ TRANSLATIONS += ../../lang/spanish.ts
|
|||
|
||||
PRECOMPILED_HEADER = ../../src/qt/precompile.h
|
||||
|
||||
HEADERS += ../../src/qt/version.h
|
||||
|
||||
HEADERS += ../../src/qt/main.h
|
||||
SOURCES += ../../src/qt/main.cpp
|
||||
|
||||
|
@ -32,3 +34,6 @@ SOURCES += ../../src/qt/MainOptions.cpp
|
|||
|
||||
HEADERS += ../../src/qt/configdialog.h
|
||||
SOURCES += ../../src/qt/configdialog.cpp
|
||||
|
||||
HEADERS += ../../src/qt/EmuManager.h
|
||||
SOURCES += ../../src/qt/EmuManager.cpp
|
||||
|
|
|
@ -174,6 +174,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="EmuManager"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\qt\EmuManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\qt\EmuManager.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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 "EmuManager.h"
|
||||
|
||||
|
||||
EmuManager::EmuManager()
|
||||
: romBuffer( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EmuManager::~EmuManager()
|
||||
{
|
||||
if( romBuffer != 0 ) {
|
||||
free( romBuffer );
|
||||
romBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EmuManager::setROM( QString &file )
|
||||
{
|
||||
romPath = file;
|
||||
}
|
||||
|
||||
|
||||
QString &EmuManager::getROM()
|
||||
{
|
||||
return romPath;
|
||||
}
|
||||
|
||||
|
||||
bool EmuManager::loadROM()
|
||||
{
|
||||
// validate ROM
|
||||
if( romPath.isEmpty() ) return false;
|
||||
|
||||
QFile file( romPath );
|
||||
|
||||
if( !file.exists() ) return false;
|
||||
|
||||
qint64 size = file.size();
|
||||
if( ( size == 0 ) || ( size > 0x2000000 /* 32MB */ ) ) return false;
|
||||
|
||||
// TODO: add further validation
|
||||
|
||||
// read ROM into memory
|
||||
if( !file.open( QIODevice::ReadOnly ) ) return false;
|
||||
|
||||
if( romBuffer != 0 ) {
|
||||
// resize the buffer
|
||||
unsigned char *temp;
|
||||
temp = (unsigned char *)realloc( romBuffer, size );
|
||||
if( temp == 0 ) {
|
||||
free( romBuffer );
|
||||
return false;
|
||||
} else {
|
||||
romBuffer = temp;
|
||||
}
|
||||
} else {
|
||||
// create the buffer
|
||||
romBuffer = (unsigned char *)malloc( size );
|
||||
if( romBuffer == 0 ) return false;
|
||||
}
|
||||
|
||||
if( -1 == file.read( (char *)romBuffer, size ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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 EMUMANAGER_H
|
||||
#define EMUMANAGER_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
// class to abstract emulation control
|
||||
class EmuManager
|
||||
{
|
||||
public:
|
||||
EmuManager();
|
||||
~EmuManager();
|
||||
|
||||
void setROM( QString &file );
|
||||
QString &getROM();
|
||||
|
||||
bool loadROM();
|
||||
|
||||
private:
|
||||
QString romPath;
|
||||
unsigned char *romBuffer;
|
||||
};
|
||||
|
||||
#endif // #ifndef EMUMANAGER_H
|
|
@ -33,7 +33,8 @@ MainWnd::MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent )
|
|||
toolsMenu( 0 ),
|
||||
helpMenu( 0 ),
|
||||
enableTranslationAct( 0 ),
|
||||
dockWidget_cheats( 0 )
|
||||
dockWidget_cheats( 0 ),
|
||||
emuManager( 0 )
|
||||
{
|
||||
createDisplay();
|
||||
setMinimumSize( 320, 240 );
|
||||
|
@ -44,11 +45,17 @@ MainWnd::MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent )
|
|||
createMenus();
|
||||
|
||||
loadSettings();
|
||||
|
||||
emuManager = new EmuManager();
|
||||
}
|
||||
|
||||
|
||||
MainWnd::~MainWnd()
|
||||
{
|
||||
if( emuManager != 0 ) {
|
||||
delete emuManager;
|
||||
emuManager = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,10 +297,21 @@ void MainWnd::showAbout()
|
|||
|
||||
void MainWnd::showOpenROM()
|
||||
{
|
||||
QString info;
|
||||
info += tr ( "Enter ROM loader code here." );
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select ROM" ),
|
||||
"",
|
||||
tr( "Game Boy Advance ROMs (*.gba);;All Files (*.*)" ) );
|
||||
|
||||
QMessageBox::about( this, tr( "Status" ), info );
|
||||
if( file.isNull() ) return;
|
||||
|
||||
emuManager->setROM( file );
|
||||
if( !emuManager->loadROM() ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Can not load ROM!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: start emulation
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "precompile.h"
|
||||
|
||||
#include "EmuManager.h"
|
||||
|
||||
class MainWnd : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -50,6 +52,7 @@ private:
|
|||
QMenu *toolsMenu;
|
||||
QMenu *helpMenu;
|
||||
QDockWidget *dockWidget_cheats;
|
||||
EmuManager *emuManager;
|
||||
|
||||
private slots:
|
||||
bool selectLanguage();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
// Add C++ includes here
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtOpenGL/QtOpenGL>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#endif // #ifndef PRECOMPILE_H
|
||||
|
|
Loading…
Reference in New Issue