Drop gtk and mfc interfaces. Things are changing and for the better.

This commit is contained in:
DoctorWho11 2016-12-20 17:34:34 -05:00
parent ac32a524a3
commit a1bf0f3f82
218 changed files with 3 additions and 52082 deletions

View File

@ -18,8 +18,6 @@ SET( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts )
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
option( ENABLE_SDL "Build the SDL port" OFF )
option( ENABLE_GTK "Build the GTK+ GUI" OFF )
option( ENABLE_GTK3 "Build the GTK+ GUI" OFF )
option( ENABLE_WX "Build the wxWidgets port" ON )
option( ENABLE_DEBUGGER "Enable the debugger" ON )
option( ENABLE_NLS "Enable translations" ON )
@ -652,22 +650,17 @@ IF( ENABLE_SDL )
ENDIF( WIN32 )
ENDIF( ENABLE_SDL )
IF( ENABLE_GTK OR ENABLE_GTK3 )
add_subdirectory (src/gtk)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/gvbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin)
ENDIF( ENABLE_GTK OR ENABLE_GTK3 )
IF( ENABLE_WX )
add_subdirectory(src/wx)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin)
ENDIF( ENABLE_WX )
if( ENABLE_GTK OR ENABLE_GTK3 OR ENABLE_WX )
if( ENABLE_WX )
# Native Language Support
if( ENABLE_NLS )
add_subdirectory(po)
endif( ENABLE_NLS )
endif( ENABLE_GTK OR ENABLE_GTK3 OR ENABLE_WX )
endif( ENABLE_WX )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vba-over.ini DESTINATION ${DATA_INSTALL_DIR})
IF(NOT APPLE)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/gtk/icons/ DESTINATION share/icons/hicolor PATTERN ".svn" EXCLUDE)
@ -678,9 +671,6 @@ IF( UNIX )
IF( ENABLE_SDL )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6)
ENDIF( ENABLE_SDL )
IF( ENABLE_GTK OR ENABLE_GTK3 )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/gvbam.6 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6)
ENDIF( ENABLE_GTK OR ENABLE_GTK3 )
IF( ENABLE_WX )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6)
ENDIF( ENABLE_WX )
@ -688,10 +678,6 @@ ENDIF( UNIX )
# linux data files
IF( NOT WIN32 AND NOT APPLE )
IF( ENABLE_GTK OR ENABLE_GTK3 )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/gtk/gvbam.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/gtk/gvbam.appdata.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/appdata)
ENDIF( ENABLE_GTK OR ENABLE_GTK3 )
IF( ENABLE_WX )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/wx/wxvbam.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/wx/wxvbam.appdata.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/appdata)

19
src/debian/control Normal file → Executable file
View File

@ -7,9 +7,7 @@ Build-Depends: debhelper (>= 9),
libpng12-dev,
imagemagick,
libopenal-dev,
libsdl1.2-dev,
libgtkmm-2.4-dev,
libgtkglextmm-x11-1.2-dev,
libsdl2.0-dev,
libwxbase3.0-dev,
libwxgtk3.0-dev,
libcairo2-dev,
@ -45,21 +43,6 @@ Description: Nintendo Game Boy Advance emulator
trademarks of Nintendo of America Inc. VBA-M is not affiliated with or endorsed
by any of the companies mentioned.
#Package: vbam-gtk
#Architecture: any
#Depends: ${shlibs:Depends}, ${misc:Depends}
#Description: Nintendo Game Boy Advance emulator (GTK+ frontend)
# VisualBoyAdvance-M is a Nintendo Game Boy Emulator with high compatibility
# with commercial games. It emulates the Nintendo Game Boy Advance handheld
# console, in addition to the original Game Boy handhelds and its Super and
# Color variants.
# .
# This package provides the GTK+ GUI version of VBA-M.
# .
# Game Boy, Game Boy Color, Super Game Boy and Game Boy Advance are registered
# trademarks of Nintendo of America Inc. VBA-M is not affiliated with or endorsed
# by any of the companies mentioned.
Package: vbam-wx
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}

View File

@ -1,32 +0,0 @@
.TH gvbam 6 "December 10, 2016"
.SH NAME
VBAM-GTK \- (aka
.B gvbam
) A gtk+ GUI for a high compatibility Gameboy Advance
Emulator integrating the best features from various Visual Boy Advance builds.
.SH SYNOPSIS
.B GVBAM
.RI [ options ]
.SH DESCRIPTION
.B VisualBoyAdvance-M
is a Nintendo Game Boy Emulator with high compatibility with
commercial games.
.P
It emulates the Nintendo Game Boy Advance hand held console, in
addition to the original Game Boy hand held systems and its Super and Color
variants.
.P
VBA-M is a continued development of the now inactive VisualBoy
Advance project, with many improvements from various builds of VBA.
.P
This application is the GTK GUI version of VisualBoyAdvance-M.
.SH OPTIONS
.TP
.BI "\-h, \-\-help
Output version information
.TP
.B \-v, \-\-version
Output version information
.SH AUTHOR
This manual page was written by Jeremy Newton (Mystro256).
This man page is licensed as GPLv2 or later.

View File

@ -1,5 +0,0 @@
usr/bin/gvbam
usr/share/icons
usr/share/vbam
usr/share/locale/*/*/gvbam.*
usr/share/applications/gvbam.desktop

View File

@ -1 +0,0 @@
debian/gvbam.1

View File

@ -1 +0,0 @@
?package(vbam-gtk):needs="X11" section="Applications/Emulators" title="VisualBoyAdvance-M" command="/usr/bin/gvbam"

View File

@ -1,101 +0,0 @@
#Do not use this file directly. Always use the top level CMakeLists.txt file
SET( CMAKE_CXX_FLAGS -std=gnu++11 )
#GTK dependencies
FIND_PACKAGE ( PkgConfig REQUIRED )
FIND_PACKAGE ( Gettext REQUIRED )
# These dependencies require pkg-config to be found
PKG_CHECK_MODULES ( GLIBMM REQUIRED glibmm-2.4 )
PKG_CHECK_MODULES ( GIOMM REQUIRED giomm-2.4 )
if(ENABLE_GTK)
PKG_CHECK_MODULES ( GTKMM REQUIRED gtkmm-2.4 )
PKG_CHECK_MODULES ( GDKMM REQUIRED gdkmm-2.4 )
PKG_CHECK_MODULES ( GTKGLMM REQUIRED gtkglextmm-x11-1.2 )
endif(ENABLE_GTK)
if(ENABLE_GTK3)
PKG_CHECK_MODULES ( GTKMM REQUIRED gtkmm-3.0 )
PKG_CHECK_MODULES ( GDKMM REQUIRED gdkmm-3.0 )
endif(ENABLE_GTK3)
if(NOT APPLE AND NOT WIN32)
FIND_PACKAGE ( X11 REQUIRED )
endif(NOT APPLE AND NOT WIN32)
#Make sure the gtk ui elements are available for out of tree builds
#See window.cpp:1544 (the sGetUiFilePath function) for more details
#file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ui/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ui/)
SET(SRC_GTK
configfile.cpp
main.cpp
system.cpp
windowcallbacks.cpp
filters.cpp
generalconfig.cpp
gameboyconfig.cpp
gameboyadvanceconfig.cpp
cheatlist.cpp
cheatedit.cpp
gameboyadvancecheatlist.cpp
gameboycheatlist.cpp
joypadconfig.cpp
directoriesconfig.cpp
displayconfig.cpp
soundconfig.cpp
screenarea.cpp
screenarea-cairo.cpp
screenarea-opengl.cpp
tools.cpp
window.cpp
../sdl/inputSDL.cpp
)
INCLUDE_DIRECTORIES(
${GLIBMM_INCLUDE_DIRS}
${GIOMM_INCLUDE_DIRS}
${GTKMM_INCLUDE_DIRS}
${GDKMM_INCLUDE_DIRS}
${GTKGLMM_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
)
LINK_DIRECTORIES(
${GLIBMM_LIBRARY_DIRS}
${GIOMM_LIBRARY_DIRS}
${GTKMM_LIBRARY_DIRS}
${GTKGLMM_LIBRARY_DIRS}
)
ADD_EXECUTABLE (
gvbam
WIN32
MACOSX_BUNDLE
${SRC_GTK}
../common/SoundSDL.cpp
)
TARGET_LINK_LIBRARIES (
gvbam
${VBAMCORE_LIBS}
${GTKMM_LIBRARIES}
${GTKGLMM_LIBRARIES}
${X11_LIBRARIES}
)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/gvbam DESTINATION bin)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ui DESTINATION ${DATA_INSTALL_DIR})
IF(NOT WIN32 AND NOT APPLE)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gvbam.desktop DESTINATION share/applications)
ENDIF(NOT WIN32 AND NOT APPLE)
if(APPLE)
#Probably don't need this
SET(CMAKE_EXECUTABLE_SUFFIX .app)
# this should set ROM file types correctly
SET_PROPERTY(TARGET wxvbam APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in)
endif(APPLE)
SET(WX_EXE_NAME gvbam${CMAKE_EXECUTABLE_SUFFIX})

View File

@ -1,120 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cheatedit.h"
#include "intl.h"
namespace VBA {
/**
* GameBoyAdvanceCheatEditDialog
*
* A unified cheat editing dialog for multiple code types.
*/
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
{
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
refBuilder->get_widget("CheatInputTextView", m_poCheatInputTextView);
refBuilder->get_widget("CheatApplyButton", m_poCheatApplyButton);
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
// Tree View model
m_poCheatTypeStore = Gtk::ListStore::create(m_oTypeModel);
m_poCheatTypeComboBox->set_model(m_poCheatTypeStore);
m_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply));
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
}
Glib::RefPtr<Gtk::TextBuffer> CheatEditDialog::vGetCode()
{
return m_poCheatInputTextView->get_buffer();
}
Glib::ustring CheatEditDialog::vGetDesc()
{
return m_poCheatDescEntry->get_text();
}
ECheatType CheatEditDialog::vGetType()
{
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
if (iter) {
Gtk::TreeModel::Row row = *iter;
return row[m_oTypeModel.iType];
}
return CheatGeneric;
}
void CheatEditDialog::vSetWindow(VBA::Window* _poWindow)
{
m_poWindow = _poWindow;
// GameBoy Advance
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA) {
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGeneric;
row[m_oTypeModel.uText] = _("Generic Code");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGSA;
row[m_oTypeModel.uText] = _("Gameshark Advance");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatCBA;
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
m_poCheatTypeComboBox->set_active(CheatGeneric);
}
// GameBoy
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) {
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGS;
row[m_oTypeModel.uText] = _("GameShark");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGG;
row[m_oTypeModel.uText] = _("GameGenie");
m_poCheatTypeComboBox->set_active(0);
}
}
void CheatEditDialog::vOnApply()
{
response(Gtk::RESPONSE_APPLY);
}
void CheatEditDialog::vOnCancel()
{
response(Gtk::RESPONSE_CANCEL);
}
} // namespace VBA

View File

@ -1,79 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_CHEATEDIT_H__
#define __VBA_CHEATEDIT_H__
#include <gtkmm/combobox.h>
#include <gtkmm/entry.h>
#include <gtkmm/liststore.h>
#include <gtkmm/textview.h>
#include <gtkmm/treemodel.h>
#include "window.h"
namespace VBA {
enum ECheatType { CheatGeneric,
CheatGSA,
CheatCBA,
CheatGS,
CheatGG };
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
public:
EditCheatCodeColumns()
{
add(uText);
add(iType);
}
~EditCheatCodeColumns()
{
}
Gtk::TreeModelColumn<Glib::ustring> uText;
Gtk::TreeModelColumn<ECheatType> iType;
};
class CheatEditDialog : public Gtk::Dialog {
public:
CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
Glib::ustring vGetDesc();
ECheatType vGetType();
void vSetWindow(VBA::Window* _poWindow);
private:
void vOnApply();
void vOnCancel();
VBA::Window* m_poWindow;
Gtk::Entry* m_poCheatDescEntry;
Gtk::ComboBox* m_poCheatTypeComboBox;
Gtk::TextView* m_poCheatInputTextView;
Gtk::Button* m_poCheatApplyButton;
Gtk::Button* m_poCheatCancelButton;
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
EditCheatCodeColumns m_oTypeModel;
};
} // namespace VBA
#endif

View File

@ -1,168 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cheatlist.h"
#include <glibmm/miscutils.h>
#include <gtkmm/stock.h>
#include "intl.h"
#include <vector>
namespace VBA {
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
{
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
refBuilder->get_widget("CheatAddButton", m_poCheatAddButton);
refBuilder->get_widget("CheatRemoveButton", m_poCheatRemoveButton);
refBuilder->get_widget("CheatRemoveAllButton", m_poCheatRemoveAllButton);
refBuilder->get_widget("CheatMarkAllButton", m_poCheatMarkAllButton);
refBuilder->get_widget("CheatTreeView", m_poCheatTreeView);
// Tree View model
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
m_poCheatTreeView->set_model(m_poCheatListStore);
Gtk::CellRendererToggle* pRenderer = Gtk::manage(new Gtk::CellRendererToggle());
int cols_count = m_poCheatTreeView->append_column("", *pRenderer);
pRenderer->signal_toggled().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatToggled));
Gtk::TreeViewColumn* pColumn = m_poCheatTreeView->get_column(cols_count - 1);
if (pColumn)
pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);
m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);
m_poCheatOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListOpen));
m_poCheatSaveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListSave));
m_poCheatAddButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatAdd));
m_poCheatRemoveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemove));
m_poCheatRemoveAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemoveAll));
m_poCheatMarkAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatMarkAll));
bMark = false;
}
void CheatListDialog::vOnCheatListOpen()
{
Gtk::FileChooserDialog oDialog(*this, _("Open cheat list"));
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
oDialog.set_current_folder(Glib::get_home_dir());
while (oDialog.run() == Gtk::RESPONSE_OK) {
// delete existing cheats before loading the list
vRemoveAllCheats();
m_poCheatListStore->clear();
if (vCheatListOpen(oDialog.get_filename().c_str())) {
vUpdateList();
break;
}
}
}
void CheatListDialog::vOnCheatListSave()
{
Gtk::FileChooserDialog sDialog(*this, _("Save cheat list"));
sDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
sDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
sDialog.set_current_folder(Glib::get_home_dir());
if (sDialog.run() == Gtk::RESPONSE_OK)
vCheatListSave(sDialog.get_filename().c_str());
}
void CheatListDialog::vOnCheatAdd()
{
std::string sUiFile = VBA::Window::sGetUiFilePath("cheatedit.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
CheatEditDialog* poDialog = 0;
poBuilder->get_widget_derived("CheatEditDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(m_poWindow);
int response = poDialog->run();
poDialog->hide();
if (response == Gtk::RESPONSE_APPLY)
vAddCheat(poDialog->vGetDesc(), poDialog->vGetType(), poDialog->vGetCode());
}
void CheatListDialog::vOnCheatRemove()
{
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
vRemoveCheat(row[m_oRecordModel.iIndex]);
m_poCheatListStore->erase(iter);
}
}
void CheatListDialog::vOnCheatRemoveAll()
{
vRemoveAllCheats();
m_poCheatListStore->clear();
}
void CheatListDialog::vOnCheatMarkAll()
{
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) {
Gtk::TreeModel::Row row = *iter;
row[m_oRecordModel.bEnabled] = bMark;
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
}
bMark = !bMark;
}
void CheatListDialog::vOnCheatToggled(Glib::ustring const& string_path)
{
Gtk::TreeIter iter = m_poCheatListStore->get_iter(string_path);
Gtk::TreeModel::Row row = *iter;
row[m_oRecordModel.bEnabled] = !row[m_oRecordModel.bEnabled];
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
}
void CheatListDialog::vSetWindow(VBA::Window* _poWindow)
{
m_poWindow = _poWindow;
}
} // namespace VBA

View File

@ -1,90 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_CHEATLIST_H__
#define __VBA_CHEATLIST_H__
#include <gtkmm/toolbutton.h>
#include "cheatedit.h"
#include "window.h"
namespace VBA {
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
public:
ListCheatCodeColumns()
{
add(iIndex);
add(bEnabled);
add(uDesc);
}
~ListCheatCodeColumns()
{
}
Gtk::TreeModelColumn<int> iIndex;
Gtk::TreeModelColumn<bool> bEnabled;
Gtk::TreeModelColumn<Glib::ustring> uDesc;
};
class CheatListDialog : public Gtk::Dialog {
public:
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetWindow(VBA::Window* _poWindow);
protected:
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
Glib::RefPtr<Gtk::TextBuffer> buffer)
= 0;
virtual bool vCheatListOpen(const char* file) = 0;
virtual void vCheatListSave(const char* file) = 0;
virtual void vRemoveCheat(int index) = 0;
virtual void vRemoveAllCheats() = 0;
virtual void vToggleCheat(int index, bool enable) = 0;
virtual void vUpdateList(int previous = 0) = 0;
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
ListCheatCodeColumns m_oRecordModel;
private:
void vOnCheatListOpen();
void vOnCheatListSave();
void vOnCheatAdd();
void vOnCheatRemove();
void vOnCheatRemoveAll();
void vOnCheatMarkAll();
void vOnCheatToggled(Glib::ustring const& string_path);
VBA::Window* m_poWindow;
Gtk::ToolButton* m_poCheatOpenButton;
Gtk::ToolButton* m_poCheatSaveButton;
Gtk::ToolButton* m_poCheatAddButton;
Gtk::ToolButton* m_poCheatRemoveButton;
Gtk::ToolButton* m_poCheatRemoveAllButton;
Gtk::ToolButton* m_poCheatMarkAllButton;
Gtk::TreeView* m_poCheatTreeView;
bool bMark;
};
} // namespace VBA
#endif

View File

@ -1,225 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "configfile.h"
#include <cstring>
#include <glibmm/fileutils.h>
#include <glibmm/iochannel.h>
namespace VBA {
namespace Config {
using std::string;
using Glib::IOChannel;
Line::Line(const string& _rsKey, const string& _rsValue)
: m_sKey(_rsKey)
, m_sValue(_rsValue)
{
}
Section::Section(const string& _rsName)
: m_sName(_rsName)
{
}
bool Section::bKeyExists(const string& _rsKey)
{
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
return true;
}
}
return false;
}
void Section::vSetKey(const string& _rsKey, const string& _rsValue)
{
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
it->m_sValue = _rsValue;
return;
}
}
push_back(Line(_rsKey, _rsValue));
}
string Section::sGetKey(const string& _rsKey) const
{
for (const_iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
return it->m_sValue;
}
}
throw KeyNotFound(m_sName, _rsKey);
}
void Section::vRemoveKey(const string& _rsKey)
{
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
erase(it);
return;
}
}
}
File::File()
{
}
File::File(const string& _rsFile)
{
vLoad(_rsFile);
}
File::~File()
{
}
bool File::bSectionExists(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
return true;
}
}
return false;
}
Section* File::poAddSection(const string& _rsName)
{
Section* poSection = NULL;
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
poSection = &(*it);
}
}
if (poSection == NULL) {
push_back(Section(_rsName));
poSection = &back();
}
return poSection;
}
Section* File::poGetSection(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
return &(*it);
}
}
throw SectionNotFound(_rsName);
}
void File::vRemoveSection(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
erase(it);
return;
}
}
}
void File::vLoad(const string& _rsFile,
bool _bAddSection,
bool _bAddKey)
{
string sBuffer = Glib::file_get_contents(_rsFile);
Section* poSection = NULL;
char** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
char* tmp;
int i = 0;
while (lines[i]) {
if (lines[i][0] == '[') {
if ((tmp = strchr(lines[i], ']'))) {
*tmp = '\0';
if (_bAddSection) {
poSection = poAddSection(&lines[i][1]);
} else {
try {
poSection = poGetSection(&lines[i][1]);
} catch (...) {
poSection = NULL;
}
}
}
} else if (lines[i][0] != '#' && poSection != NULL) {
if ((tmp = strchr(lines[i], '='))) {
*tmp = '\0';
tmp++;
if (_bAddKey || poSection->bKeyExists(lines[i])) {
poSection->vSetKey(lines[i], tmp);
}
}
}
i++;
}
g_strfreev(lines);
}
void File::vSave(const string& _rsFile)
{
Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
poFile->set_encoding("");
for (const_iterator poSection = begin();
poSection != end();
poSection++) {
string sName = "[" + poSection->sGetName() + "]\n";
poFile->write(sName);
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++) {
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
poFile->write(sLine);
}
poFile->write("\n");
}
}
void File::vClear()
{
clear();
}
std::ostream& operator<<(std::ostream& _roOut, const File& _roFile)
{
for (File::const_iterator poSection = _roFile.begin();
poSection != _roFile.end();
poSection++) {
string sName = "[" + poSection->sGetName() + "]\n";
_roOut << sName;
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++) {
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
_roOut << sLine;
}
_roOut << "\n";
}
return _roOut;
}
} // namespace Config
} // namespace VBA

View File

@ -1,206 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_CONFIGFILE_H__
#define __VBA_CONFIGFILE_H__
#include <list>
#include <sstream>
namespace VBA {
namespace Config {
class NotFound {
public:
virtual ~NotFound()
{
}
protected:
NotFound()
{
}
};
class SectionNotFound : public NotFound {
public:
SectionNotFound(const std::string& _rsName)
: m_sName(_rsName)
{
}
virtual ~SectionNotFound()
{
}
inline std::string sGetName() const
{
return m_sName;
}
private:
std::string m_sName;
};
class KeyNotFound : public NotFound {
public:
KeyNotFound(const std::string& _rsSection, const std::string& _rsKey)
: m_sSection(_rsSection)
, m_sKey(_rsKey)
{
}
virtual ~KeyNotFound()
{
}
inline std::string sGetSection() const
{
return m_sSection;
}
inline std::string sGetKey() const
{
return m_sKey;
}
private:
std::string m_sSection;
std::string m_sKey;
};
class Line {
public:
Line(const std::string& _rsKey, const std::string& _rsValue);
std::string m_sKey;
std::string m_sValue;
};
class Section : private std::list<Line> {
public:
explicit Section(const std::string& _rsName);
inline std::string sGetName() const
{
return m_sName;
}
bool bKeyExists(const std::string& _rsKey);
void vSetKey(const std::string& _rsKey, const std::string& _rsValue);
std::string sGetKey(const std::string& _rsKey) const;
void vRemoveKey(const std::string& _rsKey);
template <typename T>
void vSetKey(const std::string& _rsKey, const T& _rValue);
template <typename T>
T oGetKey(const std::string& _rsKey) const;
// read only
typedef std::list<Line>::const_iterator const_iterator;
inline const_iterator begin() const
{
return std::list<Line>::begin();
}
inline const_iterator end() const
{
return std::list<Line>::end();
}
private:
inline iterator begin()
{
return std::list<Line>::begin();
}
inline iterator end()
{
return std::list<Line>::end();
}
std::string m_sName;
};
class File : private std::list<Section> {
public:
File();
File(const std::string& _rsFile);
virtual ~File();
bool bSectionExists(const std::string& _rsName);
Section* poAddSection(const std::string& _rsName);
Section* poGetSection(const std::string& _rsName);
void vRemoveSection(const std::string& _rsName);
void vLoad(const std::string& _rsFile, bool _bAddSection = true, bool _bAddKey = true);
void vSave(const std::string& _rsFile);
void vClear();
// read only
typedef std::list<Section>::const_iterator const_iterator;
inline const_iterator begin() const
{
return std::list<Section>::begin();
}
inline const_iterator end() const
{
return std::list<Section>::end();
}
private:
inline iterator begin()
{
return std::list<Section>::begin();
}
inline iterator end()
{
return std::list<Section>::end();
}
};
// debug
std::ostream& operator<<(std::ostream& _roOut, const File& _roConfig);
template <typename T>
void Section::vSetKey(const std::string& _rsKey, const T& _rValue)
{
std::ostringstream oOut;
oOut << _rValue;
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
it->m_sValue = oOut.str();
return;
}
}
push_back(Line(_rsKey, oOut.str()));
}
template <typename T>
T Section::oGetKey(const std::string& _rsKey) const
{
T oValue;
for (const_iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
std::istringstream oIn(it->m_sValue);
oIn >> oValue;
return oValue;
}
}
throw KeyNotFound(m_sName, _rsKey);
}
} // namespace Config
} // namespace VBA
#endif // __VBA_CONFIGFILE_H__

View File

@ -1,65 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "directoriesconfig.h"
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA {
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = {
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
{ "saves", N_("Saves :"), "SavesDirEntry" },
{ "captures", N_("Captures :"), "CapturesDirEntry" }
};
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section* _poConfig)
: Gtk::Dialog(_("Directories config"), true)
, m_poConfig(_poConfig)
{
Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
poTable->set_border_width(5);
poTable->set_spacings(5);
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END));
m_poButtons[i] = Gtk::manage(new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
poTable->attach(*poLabel, 0, 1, i, i + 1);
poTable->attach(*m_poButtons[i], 1, 2, i, i + 1);
}
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
get_vbox()->pack_start(*poTable);
show_all_children();
}
void DirectoriesConfigDialog::on_response(int response_id)
{
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
m_poConfig->vSetKey(m_astDirs[i].m_csKey, m_poButtons[i]->get_current_folder());
}
}
} // namespace VBA

View File

@ -1,51 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_DIRECTORIESCONFIG_H__
#define __VBA_DIRECTORIESCONFIG_H__
#include <gtkmm/dialog.h>
#include <gtkmm/filechooserbutton.h>
#include <gtkmm/label.h>
#include <gtkmm/table.h>
#include "configfile.h"
namespace VBA {
class DirectoriesConfigDialog : public Gtk::Dialog {
public:
DirectoriesConfigDialog(Config::Section* _poConfig);
protected:
void on_response(int response_id);
private:
struct SDirEntry {
const char* m_csKey;
const char* m_csLabel;
const char* m_csFileChooserButton;
};
Config::Section* m_poConfig;
static const SDirEntry m_astDirs[];
Gtk::FileChooserButton* m_poButtons[6];
};
} // namespace VBA
#endif // __VBA_DIRECTORIESCONFIG_H__

View File

@ -1,136 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "displayconfig.h"
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/stock.h>
#include "filters.h"
#include "intl.h"
namespace VBA {
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
refBuilder->get_widget("DefaultScaleComboBox", m_poDefaultScaleComboBox);
refBuilder->get_widget("OutputOpenGL", m_poOutputOpenGLRadioButton);
refBuilder->get_widget("OutputCairo", m_poOutputCairoRadioButton);
m_poFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterChanged));
m_poIBFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterIBChanged));
m_poDefaultScaleComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnScaleChanged));
m_poOutputOpenGLRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputOpenGL));
m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo));
// Populate the filters combobox
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
for (guint i = FirstFilter; i <= LastFilter; i++) {
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
}
// Populate the interframe blending filters combobox
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
for (guint i = FirstFilterIB; i <= LastFilterIB; i++) {
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
}
}
void DisplayConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
int iDefaultFilter = m_poConfig->oGetKey<int>("filter2x");
m_poFiltersComboBox->set_active(iDefaultFilter);
int iDefaultFilterIB = m_poConfig->oGetKey<int>("filterIB");
m_poIBFiltersComboBox->set_active(iDefaultFilterIB);
int iDefaultScale = m_poConfig->oGetKey<int>("scale");
m_poDefaultScaleComboBox->set_active(iDefaultScale - 1);
// Set the default output module
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
switch (_eOutput) {
case VBA::Window::OutputOpenGL:
m_poOutputOpenGLRadioButton->set_active();
break;
default:
m_poOutputCairoRadioButton->set_active();
break;
}
}
void DisplayConfigDialog::vOnFilterChanged()
{
int iFilter = m_poFiltersComboBox->get_active_row_number();
if (iFilter >= 0) {
m_poConfig->vSetKey("filter2x", iFilter);
m_poWindow->vApplyConfigFilter();
}
}
void DisplayConfigDialog::vOnFilterIBChanged()
{
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
if (iFilterIB >= 0) {
m_poConfig->vSetKey("filterIB", iFilterIB);
m_poWindow->vApplyConfigFilterIB();
}
}
void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
{
VBA::Window::EVideoOutput eOldOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
if (_eOutput == eOldOutput)
return;
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) {
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
m_poWindow->vApplyConfigScreenArea();
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) {
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
m_poWindow->vApplyConfigScreenArea();
}
}
void DisplayConfigDialog::vOnScaleChanged()
{
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
if (iScale > 0) {
m_poConfig->vSetKey("scale", iScale);
m_poWindow->vUpdateScreen();
}
}
} // namespace VBA

View File

@ -1,55 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_DISPLAYCONFIG_H__
#define __VBA_DISPLAYCONFIG_H__
#include <gtkmm/builder.h>
#include <gtkmm/combobox.h>
#include <gtkmm/dialog.h>
#include <gtkmm/radiobutton.h>
#include "configfile.h"
#include "window.h"
namespace VBA {
class DisplayConfigDialog : public Gtk::Dialog {
public:
DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnFilterChanged();
void vOnFilterIBChanged();
void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput);
void vOnScaleChanged();
VBA::Window* m_poWindow;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poFiltersComboBox;
Gtk::ComboBox* m_poIBFiltersComboBox;
Gtk::ComboBox* m_poDefaultScaleComboBox;
Gtk::RadioButton* m_poOutputOpenGLRadioButton;
Gtk::RadioButton* m_poOutputCairoRadioButton;
};
} // namespace VBA
#endif // __VBA_DISPLAYCONFIG_H__

View File

@ -1,102 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "filters.h"
#include "intl.h"
void _2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void _2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Super2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Super2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SuperEagle(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SuperEagle32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Pixelate(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Pixelate32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void AdMame2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void AdMame2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Bilinear(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Bilinear32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void BilinearPlus(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void BilinearPlus32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Scanlines(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Scanlines32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void ScanlinesTV(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void ScanlinesTV32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void hq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void hq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void lq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void lq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void xbrz2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SmartIB(uint8_t*, uint32_t, int, int);
void SmartIB32(uint8_t*, uint32_t, int, int);
void MotionBlurIB(uint8_t*, uint32_t, int, int);
void MotionBlurIB32(uint8_t*, uint32_t, int, int);
namespace VBA {
struct {
char m_csName[30];
int m_iEnlargeFactor;
Filter m_apvFunc[2];
} static const astFilters[] = {
{ N_("None"), 1, { 0, 0 } },
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
{ N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } },
{ N_("Pixelate"), 2, { Pixelate, Pixelate32 } },
{ N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } },
{ N_("Bilinear"), 2, { Bilinear, Bilinear32 } },
{ N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } },
{ N_("Scanlines"), 2, { Scanlines, Scanlines32 } },
{ N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } },
{ N_("hq2x"), 2, { hq2x, hq2x32 } },
{ N_("lq2x"), 2, { lq2x, lq2x32 } },
{ N_("xbrz2x"), 2, { 0, xbrz2x32 } }
};
struct {
char m_csName[30];
FilterIB m_apvFunc[2];
} static const astFiltersIB[] = {
{ N_("None"), { 0, 0 } },
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
};
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth)
{
return astFilters[_eFilter].m_apvFunc[_eDepth];
}
const char* pcsGetFilterName(const EFilter _eFilter)
{
return gettext(astFilters[_eFilter].m_csName);
}
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
{
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
}
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB)
{
return gettext(astFiltersIB[_eFilterIB].m_csName);
}
} // namespace VBA

View File

@ -1,68 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_FILTERS_H__
#define __VBA_FILTERS_H__
#include "../System.h"
int Init_2xSaI(uint32_t);
namespace VBA {
typedef void (*Filter)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
typedef void (*FilterIB)(uint8_t*, uint32_t, int, int);
enum EFilter {
FirstFilter,
FilterNone = FirstFilter,
Filter2xSaI,
FilterSuper2xSaI,
FilterSuperEagle,
FilterPixelate,
FilterAdMame2x,
FilterBilinear,
FilterBilinearPlus,
FilterScanlines,
FilterScanlinesTV,
FilterHq2x,
FilterLq2x,
FilterxBRZ2x,
LastFilter = FilterxBRZ2x
};
enum EFilterIB {
FirstFilterIB,
FilterIBNone = FirstFilterIB,
FilterIBSmart,
FilterIBMotionBlur,
LastFilterIB = FilterIBMotionBlur
};
enum EFilterDepth { FilterDepth16,
FilterDepth32 };
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
const char* pcsGetFilterName(const EFilter _eFilter);
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB);
} // namespace VBA
#endif // __VBA_FILTERS_H__

View File

@ -1,142 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gameboyadvancecheatlist.h"
#include "tools.h"
#include <vector>
namespace VBA {
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: CheatListDialog(_pstDialog, refBuilder)
{
vUpdateList();
}
void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
{
int previous = cheatsNumber;
switch (type) {
// Generic Code
case CheatGeneric: {
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
}
break;
}
// Gameshark Advance & CodeBreaker Advance
case CheatGSA:
case CheatCBA: {
std::vector<Glib::ustring> tokens;
Glib::ustring sToken;
Glib::ustring sCode;
Glib::ustring sPart = "";
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
sToken = it->uppercase();
const char* cToken = sToken.c_str();
if (sToken.size() == 16)
cheatsAddGSACode(cToken, sDesc.c_str(), false);
else if (sToken.size() == 12) {
sCode = sToken.substr(0, 8);
sCode += " ";
sCode += sToken.substr(9, 4);
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} else if (sPart.empty())
sPart = sToken;
else {
if (sToken.size() == 4) {
sCode = sPart;
sCode += " ";
sCode += cToken;
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} else {
sCode = sPart + sToken;
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
}
sPart = "";
}
} // end of loop
} // end of case
default:; // silence warnings
} // end of switch
vUpdateList(previous);
}
bool GameBoyAdvanceCheatListDialog::vCheatListOpen(const char* file)
{
return cheatsLoadCheatList(file);
}
void GameBoyAdvanceCheatListDialog::vCheatListSave(const char* file)
{
cheatsSaveCheatList(file);
}
void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index)
{
cheatsDelete(index, false);
}
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats()
{
cheatsDeleteAll(false);
}
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable)
cheatsEnable(index);
else
cheatsDisable(index);
}
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
{
for (int i = previous; i < cheatsNumber; i++) {
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
}
}
} // namespace VBA

View File

@ -1,46 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_GAMEBOYADVANCECHEATLIST_H__
#define __VBA_GAMEBOYADVANCECHEATLIST_H__
#include "../System.h"
#include "../gba/Cheats.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "cheatlist.h"
namespace VBA {
class GameBoyAdvanceCheatListDialog : public CheatListDialog {
public:
GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char* file);
void vCheatListSave(const char* file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
};
} // namespace VBA
#endif

View File

@ -1,137 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gameboyadvanceconfig.h"
#include "intl.h"
namespace VBA {
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
refBuilder->get_widget("BiosCheckButton", m_poBiosCheckButton);
refBuilder->get_widget("BiosFileChooserButton", m_poBiosFileChooserButton);
refBuilder->get_widget("RTCCheckButton", m_poRTCCheckButton);
m_poSaveTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnSaveTypeChanged));
m_poFlashSizeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnFlashSizeChanged));
m_poBiosCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnUseBiosChanged));
m_poBiosFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged));
m_poRTCCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnEnableRTCChanged));
}
void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
VBA::Window::ESaveType eDefaultSaveType = (VBA::Window::ESaveType)m_poConfig->oGetKey<int>("save_type");
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
if (iDefaultFlashSize == 128) {
m_poFlashSizeComboBox->set_active(1);
} else {
m_poFlashSizeComboBox->set_active(0);
}
bool bUseBios = m_poConfig->oGetKey<bool>("use_bios_file");
m_poBiosCheckButton->set_active(bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
m_poBiosFileChooserButton->set_filename(sBios);
const char* acsPattern[] = {
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
};
#if !GTK_CHECK_VERSION(3, 0, 0)
Gtk::FileFilter oAllFilter;
oAllFilter.set_name(_("All files"));
oAllFilter.add_pattern("*");
Gtk::FileFilter oBiosFilter;
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
oBiosFilter.add_pattern(acsPattern[i]);
}
#else
const Glib::RefPtr<Gtk::FileFilter> oAllFilter = Gtk::FileFilter::create();
oAllFilter->set_name(_("All files"));
oAllFilter->add_pattern("*");
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
oBiosFilter->add_pattern(acsPattern[i]);
}
#endif
m_poBiosFileChooserButton->add_filter(oAllFilter);
m_poBiosFileChooserButton->add_filter(oBiosFilter);
m_poBiosFileChooserButton->set_filter(oBiosFilter);
bool bEnableRTC = m_poConfig->oGetKey<bool>("enable_rtc");
m_poRTCCheckButton->set_active(bEnableRTC);
}
void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
{
int iSaveType = m_poSaveTypeComboBox->get_active_row_number();
m_poConfig->vSetKey("save_type", iSaveType);
m_poWindow->vApplyConfigGBASaveType();
}
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
{
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
if (iFlashSize == 0) {
m_poConfig->vSetKey("flash_size", 64);
} else {
m_poConfig->vSetKey("flash_size", 128);
}
m_poWindow->vApplyConfigGBAFlashSize();
}
void GameBoyAdvanceConfigDialog::vOnUseBiosChanged()
{
bool bUseBios = m_poBiosCheckButton->get_active();
m_poConfig->vSetKey("use_bios_file", bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
}
void GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged()
{
std::string sBios = m_poBiosFileChooserButton->get_filename();
m_poConfig->vSetKey("bios_file", sBios);
}
void GameBoyAdvanceConfigDialog::vOnEnableRTCChanged()
{
bool bEnableRTC = m_poRTCCheckButton->get_active();
m_poConfig->vSetKey("enable_rtc", bEnableRTC);
}
} // namespace VBA

View File

@ -1,56 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_GAMEBOYADVANCECONFIG_H__
#define __VBA_GAMEBOYADVANCECONFIG_H__
#include <gtkmm/checkbutton.h>
#include <gtkmm/combobox.h>
#include <gtkmm/filechooserbutton.h>
#include "configfile.h"
#include "window.h"
namespace VBA {
class GameBoyAdvanceConfigDialog : public Gtk::Dialog {
public:
GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnSaveTypeChanged();
void vOnFlashSizeChanged();
void vOnUseBiosChanged();
void vOnBiosSelectionChanged();
void vOnEnableRTCChanged();
VBA::Window* m_poWindow;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poSaveTypeComboBox;
Gtk::ComboBox* m_poFlashSizeComboBox;
Gtk::CheckButton* m_poBiosCheckButton;
Gtk::FileChooserButton* m_poBiosFileChooserButton;
Gtk::CheckButton* m_poRTCCheckButton;
};
} // namespace VBA
#endif // __VBA_GAMEBOYADVANCECONFIG_H__

View File

@ -1,116 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gameboycheatlist.h"
#include "tools.h"
#include <vector>
namespace VBA {
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: CheatListDialog(_pstDialog, refBuilder)
{
vUpdateList();
}
void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
{
int previous = gbCheatNumber;
switch (type) {
// GameShark
case CheatGS: {
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
}
break;
}
// GameGenie
case CheatGG: {
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
}
break;
}
default:; // silence warnings
}
// end of switch
vUpdateList(previous);
}
bool GameBoyCheatListDialog::vCheatListOpen(const char* file)
{
return gbCheatsLoadCheatList(file);
}
void GameBoyCheatListDialog::vCheatListSave(const char* file)
{
gbCheatsSaveCheatList(file);
}
void GameBoyCheatListDialog::vRemoveCheat(int index)
{
gbCheatRemove(index);
}
void GameBoyCheatListDialog::vRemoveAllCheats()
{
gbCheatRemoveAll();
}
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable)
gbCheatEnable(index);
else
gbCheatDisable(index);
}
void GameBoyCheatListDialog::vUpdateList(int previous)
{
for (int i = previous; i < gbCheatNumber; i++) {
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = gbCheatList[i].enabled;
row[m_oRecordModel.uDesc] = gbCheatList[i].cheatDesc;
}
}
} // namespace VBA

View File

@ -1,42 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_GAMEBOYCHEATLIST_H__
#define __VBA_GAMEBOYCHEATLIST_H__
#include "../gb/gbCheats.h"
#include "cheatlist.h"
namespace VBA {
class GameBoyCheatListDialog : public CheatListDialog {
public:
GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char* file);
void vCheatListSave(const char* file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
};
} // namespace VBA
#endif

View File

@ -1,112 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gameboyconfig.h"
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA {
static const VBA::Window::EEmulatorType aEmulatorType[] = {
VBA::Window::EmulatorAuto,
VBA::Window::EmulatorCGB,
VBA::Window::EmulatorSGB,
VBA::Window::EmulatorGB,
VBA::Window::EmulatorGBA,
VBA::Window::EmulatorSGB2
};
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton);
refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton);
refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton);
m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged));
m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged));
m_poBootRomFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBootRomSelectionChanged));
}
void GameBoyConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
VBA::Window::EEmulatorType eDefaultEmulatorType = (VBA::Window::EEmulatorType)m_poConfig->oGetKey<int>("emulator_type");
m_poSystemComboBox->set_active(aEmulatorType[eDefaultEmulatorType]);
bool bBorder = m_poConfig->oGetKey<bool>("gb_border");
m_poBorderCheckButton->set_active(bBorder);
bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
m_poPrinterCheckButton->set_active(bPrinter);
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
m_poBootRomCheckButton->set_active(bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
m_poBootRomFileChooserButton->set_filename(sBootRom);
}
void GameBoyConfigDialog::vOnSystemChanged()
{
int iSystem = m_poSystemComboBox->get_active_row_number();
m_poConfig->vSetKey("emulator_type", aEmulatorType[iSystem]);
m_poWindow->vApplyConfigGBSystem();
}
void GameBoyConfigDialog::vOnBorderChanged()
{
bool bBorder = m_poBorderCheckButton->get_active();
m_poConfig->vSetKey("gb_border", bBorder);
m_poWindow->vApplyConfigGBBorder();
}
void GameBoyConfigDialog::vOnPrinterChanged()
{
bool bPrinter = m_poPrinterCheckButton->get_active();
m_poConfig->vSetKey("gb_printer", bPrinter);
m_poWindow->vApplyConfigGBPrinter();
}
void GameBoyConfigDialog::vOnUseBootRomChanged()
{
bool bUseBootRom = m_poBootRomCheckButton->get_active();
m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
}
void GameBoyConfigDialog::vOnBootRomSelectionChanged()
{
std::string sBootRom = m_poBootRomFileChooserButton->get_filename();
m_poConfig->vSetKey("gb_bios_file", sBootRom);
}
} // namespace VBA

View File

@ -1,55 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_GAMEBOYCONFIG_H__
#define __VBA_GAMEBOYCONFIG_H__
#include <gtkmm/checkbutton.h>
#include <gtkmm/combobox.h>
#include <gtkmm/filechooserbutton.h>
#include "configfile.h"
#include "window.h"
namespace VBA {
class GameBoyConfigDialog : public Gtk::Dialog {
public:
GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnSystemChanged();
void vOnBorderChanged();
void vOnPrinterChanged();
void vOnUseBootRomChanged();
void vOnBootRomSelectionChanged();
VBA::Window* m_poWindow;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poSystemComboBox;
Gtk::CheckButton* m_poBorderCheckButton;
Gtk::CheckButton* m_poPrinterCheckButton;
Gtk::CheckButton* m_poBootRomCheckButton;
Gtk::FileChooserButton* m_poBootRomFileChooserButton;
};
} // namespace VBA
#endif // __VBA_GAMEBOYCONFIG_H__

View File

@ -1,99 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "generalconfig.h"
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA {
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
refBuilder->get_widget("FrameSkipLevelSpinButton", m_poFrameSkipLevelSpinButton);
refBuilder->get_widget("SpeedIndicatorComboBox", m_poSpeedIndicatorComboBox);
m_poPauseWhenInactiveCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnPauseWhenInactiveChanged));
m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged));
}
void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
bool bPauseWhenInactive = m_poConfig->oGetKey<bool>("pause_when_inactive");
m_poPauseWhenInactiveCheckButton->set_active(bPauseWhenInactive);
std::string sFrameskip = m_poConfig->oGetKey<std::string>("frameskip");
int iFrameskip = 0;
bool bAutoFrameskip = false;
if (sFrameskip == "auto")
bAutoFrameskip = true;
else
iFrameskip = m_poConfig->oGetKey<int>("frameskip");
m_poFrameSkipAutomaticCheckButton->set_active(bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_value(iFrameskip);
int iShowSpeed = m_poConfig->oGetKey<int>("show_speed");
m_poSpeedIndicatorComboBox->set_active(iShowSpeed);
}
void PreferencesDialog::vOnPauseWhenInactiveChanged()
{
bool bPauseWhenInactive = m_poPauseWhenInactiveCheckButton->get_active();
m_poConfig->vSetKey("pause_when_inactive", bPauseWhenInactive);
}
void PreferencesDialog::vOnFrameskipChanged()
{
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
if (bAutoFrameskip) {
m_poConfig->vSetKey("frameskip", "auto");
} else {
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
m_poConfig->vSetKey("frameskip", iFrameskip);
}
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poWindow->vApplyConfigFrameskip();
}
void PreferencesDialog::vOnSpeedIndicatorChanged()
{
int iShowSpeed = m_poSpeedIndicatorComboBox->get_active_row_number();
m_poConfig->vSetKey<int>("show_speed", iShowSpeed);
m_poWindow->vApplyConfigShowSpeed();
}
} // namespace VBA

View File

@ -1,52 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_GENERALCONFIG_H__
#define __VBA_GENERALCONFIG_H__
#include <gtkmm/checkbutton.h>
#include <gtkmm/combobox.h>
#include <gtkmm/spinbutton.h>
#include "configfile.h"
#include "window.h"
namespace VBA {
class PreferencesDialog : public Gtk::Dialog {
public:
PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnPauseWhenInactiveChanged();
void vOnFrameskipChanged();
void vOnSpeedIndicatorChanged();
VBA::Window* m_poWindow;
Config::Section* m_poConfig;
Gtk::CheckButton* m_poPauseWhenInactiveCheckButton;
Gtk::CheckButton* m_poFrameSkipAutomaticCheckButton;
Gtk::SpinButton* m_poFrameSkipLevelSpinButton;
Gtk::ComboBox* m_poSpeedIndicatorComboBox;
};
} // namespace VBA
#endif // __VBA_GENERALCONFIG_H__

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>gvbam.desktop</id>
<metadata_license>GPLv2</metadata_license>
<project_license>GPLv2</project_license>
<name>VBAM (GTK)</name>
<summary>GTK3 GUI for VBA-M, a high compatibility Gameboy Advance Emulator</summary>
<description>
<p>
VisualBoyAdvance-M is a Nintendo Game Boy Emulator with high compatibility with
commercial games. It emulates the Nintendo Game Boy Advance hand held console,
in addition to the original Game Boy hand held systems and its Super and Color
variants. VBA-M is a continued development of the now inactive VisualBoy
Advance project, with many improvements from various developments of VBA.
</p>
</description>
<url type="homepage">http://vba-m.com/</url>
<url type="bugtracker">https://github.com/visualboyadvance-m/visualboyadvance-m/issues</url>
</component>

View File

@ -1,11 +0,0 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=VBA-M (GTK+ frontend)
GenericName=Game Boy Advance Emulator
Comment=Nintendo Game Boy Advance Emulator
Exec=gvbam %f
Icon=vbam
Categories=Game;Emulator;GTK;
Keywords=emulator;Nintendo;gameboy;Game Boy;Game Boy Color;Game Boy Advance;
MimeType=application/x-gameboy-rom;application/x-gameboy-advance-rom;application/x-dmg-rom;application/x-agb-rom;application/x-gb-rom;application/x-gba-rom;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 141 KiB

View File

@ -1,35 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_INTL_H__
#define __VBA_INTL_H__
#ifdef ENABLE_NLS
#include <glibmm/i18n.h>
#else
#define _(String) (String)
#define N_(String) (String)
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain, String) (String)
#define dcgettext(Domain, String, Type) (String)
#define bindtextdomain(Domain, Directory) (Domain)
#endif
#endif // __VBA_INTL_H__

View File

@ -1,308 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "joypadconfig.h"
#include <glibmm/main.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA {
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = {
{ KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") },
{ KEY_RIGHT, N_("Right :") },
{ KEY_BUTTON_A, N_("Button A :") },
{ KEY_BUTTON_B, N_("Button B :") },
{ KEY_BUTTON_L, N_("Button L :") },
{ KEY_BUTTON_R, N_("Button R :") },
{ KEY_BUTTON_SELECT, N_("Select :") },
{ KEY_BUTTON_START, N_("Start :") },
{ KEY_BUTTON_SPEED, N_("Speed :") },
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
};
JoypadConfigDialog::JoypadConfigDialog(Config::Section* _poConfig)
: Gtk::Dialog(_("Joypad config"), true)
, m_oTitleHBox(false, 5)
, m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END)
, m_oDefaultJoypad(_("Default joypad"))
, m_oTable(G_N_ELEMENTS(m_astKeys), 2, false)
, m_iCurrentEntry(-1)
, m_bUpdating(false)
, m_ePad(PAD_MAIN)
, m_poConfig(_poConfig)
{
// Joypad selection
#if !GTK_CHECK_VERSION(3, 0, 0)
m_oTitleCombo.append_text("1");
m_oTitleCombo.append_text("2");
m_oTitleCombo.append_text("3");
m_oTitleCombo.append_text("4");
#else
m_oTitleCombo.append("1");
m_oTitleCombo.append("2");
m_oTitleCombo.append("3");
m_oTitleCombo.append("4");
#endif
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
m_oTitleHBox.pack_start(m_oTitleCombo);
// Joypad buttons
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) {
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END));
Gtk::Entry* poEntry = Gtk::manage(new Gtk::Entry());
m_oTable.attach(*poLabel, 0, 1, i, i + 1);
m_oTable.attach(*poEntry, 1, 2, i, i + 1);
m_oEntries.push_back(poEntry);
poEntry->signal_focus_in_event().connect(sigc::bind(
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
}
// Dialog validation button
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
// Layout
m_oTitleHBox.set_border_width(5);
m_oTable.set_border_width(5);
m_oTable.set_spacings(5);
get_vbox()->set_spacing(5);
get_vbox()->pack_start(m_oTitleHBox);
get_vbox()->pack_start(m_oSeparator);
get_vbox()->pack_start(m_oDefaultJoypad);
get_vbox()->pack_start(m_oTable);
// Signals and default values
m_oConfigSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
50);
m_oDefaultJoypad.signal_toggled().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnDefaultJoypadSelect));
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnJoypadSelect));
m_oTitleCombo.set_active_text("1");
show_all_children();
}
JoypadConfigDialog::~JoypadConfigDialog()
{
m_oConfigSig.disconnect();
}
void JoypadConfigDialog::vUpdateEntries()
{
m_bUpdating = true;
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
for (guint i = 0; i < m_oEntries.size(); i++) {
std::string csName;
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
int dev = uiKeyval >> 16;
if (dev == 0) {
csName = gdk_keyval_name(uiKeyval);
} else {
int what = uiKeyval & 0xffff;
std::stringstream os;
os << _("Joy ") << dev;
if (what >= 128) {
// joystick button
int button = what - 128;
os << _(" Button ") << button;
} else if (what < 0x20) {
// joystick axis
int dir = what & 1;
what >>= 1;
os << _(" Axis ") << what << (dir ? '-' : '+');
} else if (what < 0x30) {
// joystick hat
int dir = (what & 3);
what = (what & 15);
what >>= 2;
os << _(" Hat ") << what << " ";
switch (dir) {
case 0:
os << _("Up");
break;
case 1:
os << _("Down");
break;
case 2:
os << _("Right");
break;
case 3:
os << _("Left");
break;
}
}
csName = os.str();
}
if (csName.empty()) {
m_oEntries[i]->set_text(_("<Undefined>"));
} else {
m_oEntries[i]->set_text(csName);
}
}
m_bUpdating = false;
}
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus* _pstEvent,
guint _uiEntry)
{
m_iCurrentEntry = _uiEntry;
return false;
}
bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus* _pstEvent)
{
m_iCurrentEntry = -1;
return false;
}
bool JoypadConfigDialog::on_key_press_event(GdkEventKey* _pstEvent)
{
if (m_iCurrentEntry < 0) {
return Gtk::Window::on_key_press_event(_pstEvent);
}
// Forward the keyboard event by faking a SDL event
SDL_Event event;
event.type = SDL_KEYDOWN;
//event.key.timestamp = SDL_GetTicks();
//event.key.windowID = 0;
//event.key.repeat = 0;
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
vOnInputEvent(event);
return true;
}
void JoypadConfigDialog::on_response(int response_id)
{
m_poConfig->vSetKey("active_joypad", inputGetDefaultJoypad());
}
void JoypadConfigDialog::vOnInputEvent(const SDL_Event& event)
{
if (m_iCurrentEntry < 0) {
return;
}
int code = inputGetEventCode(event);
if (!code)
return;
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
vUpdateEntries();
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) {
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
} else {
m_poOkButton->grab_focus();
}
}
bool JoypadConfigDialog::bOnConfigIdle()
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_JOYAXISMOTION:
if (abs(event.jaxis.value) < 16384)
continue;
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) {
vOnInputEvent(event);
m_oPreviousEvent = event;
}
vEmptyEventQueue();
break;
case SDL_JOYBUTTONUP:
vOnInputEvent(event);
vEmptyEventQueue();
break;
case SDL_JOYHATMOTION:
if (event.jhat.value) {
vOnInputEvent(event);
vEmptyEventQueue();
}
break;
}
}
return true;
}
void JoypadConfigDialog::vEmptyEventQueue()
{
// Empty the SDL event queue
SDL_Event event;
while (SDL_PollEvent(&event))
;
}
void JoypadConfigDialog::vOnJoypadSelect()
{
std::string oText = m_oTitleCombo.get_active_text();
if (oText == "1") {
m_ePad = PAD_1;
} else if (oText == "2") {
m_ePad = PAD_2;
} else if (oText == "3") {
m_ePad = PAD_3;
} else if (oText == "4") {
m_ePad = PAD_4;
}
vEmptyEventQueue();
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
vUpdateEntries();
}
void JoypadConfigDialog::vOnDefaultJoypadSelect()
{
if (m_bUpdating)
return;
if (m_oDefaultJoypad.get_active()) {
inputSetDefaultJoypad(m_ePad);
} else {
inputSetDefaultJoypad(PAD_MAIN);
}
}
} // namespace VBA

View File

@ -1,81 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_JOYPADCONFIG_H__
#define __VBA_JOYPADCONFIG_H__
#include <vector>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
#include <gtkmm/label.h>
#include <gtkmm/separator.h>
#include <gtkmm/table.h>
#include "../sdl/inputSDL.h"
#include "configfile.h"
namespace VBA {
class JoypadConfigDialog : public Gtk::Dialog {
public:
JoypadConfigDialog(Config::Section* _poConfig);
virtual ~JoypadConfigDialog();
protected:
bool bOnEntryFocusIn(GdkEventFocus* _pstEvent, guint _uiEntry);
bool bOnEntryFocusOut(GdkEventFocus* _pstEvent);
void vOnInputEvent(const SDL_Event& event);
bool on_key_press_event(GdkEventKey* _pstEvent);
void on_response(int response_id);
private:
struct SJoypadKey {
const EKey m_eKeyFlag;
const char* m_csKeyName;
};
Gtk::HBox m_oTitleHBox;
Gtk::Label m_oTitleLabel;
Gtk::ComboBoxText m_oTitleCombo;
Gtk::HSeparator m_oSeparator;
Gtk::CheckButton m_oDefaultJoypad;
Gtk::Table m_oTable;
Gtk::Button* m_poOkButton;
std::vector<Gtk::Entry*> m_oEntries;
gint m_iCurrentEntry;
bool m_bUpdating;
static const SJoypadKey m_astKeys[];
sigc::connection m_oConfigSig;
SDL_Event m_oPreviousEvent;
EPad m_ePad;
Config::Section* m_poConfig;
bool bOnConfigIdle();
void vOnJoypadSelect();
void vOnDefaultJoypadSelect();
void vUpdateEntries();
void vEmptyEventQueue();
};
} // namespace VBA
#endif // __VBA_JOYPADCONFIG_H__

View File

@ -1,124 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <glibmm/miscutils.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/window.h>
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
#include <gtkmm/gl/init.h>
#endif // USE_OPENGL
// this will be ifdefed soon
#include <X11/Xlib.h>
#include "intl.h"
#include "window.h"
int systemDebug = 0;
int main(int argc, char* argv[])
{
bool bShowVersion = false;
Glib::OptionGroup::vecustrings listRemaining;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain("gvbam", LOCALEDIR);
textdomain("gvbam");
#endif // ENABLE_NLS
//will be ifdefed
XInitThreads();
Glib::set_application_name(_("VBA-M"));
Gtk::Main oKit(argc, argv);
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
Gtk::GL::init(argc, argv);
#endif // USE_OPENGL
Glib::OptionContext oContext;
Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));
Glib::OptionEntry oVersion;
oVersion.set_long_name("version");
oVersion.set_short_name('v');
oVersion.set_description(_("Output version information."));
oGroup.add_entry(oVersion, bShowVersion);
Glib::OptionEntry oFileName;
oFileName.set_long_name(G_OPTION_REMAINING);
oFileName.set_description(G_OPTION_REMAINING);
oGroup.add_entry(oFileName, listRemaining);
oContext.set_main_group(oGroup);
try {
oContext.parse(argc, argv);
} catch (const Glib::Error& e) {
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
if (bShowVersion) {
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
exit(0);
}
Gtk::Window::set_default_icon_name("vbam");
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
Glib::RefPtr<Gtk::Builder> poXml;
try {
poXml = Gtk::Builder::create();
poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
poXml->add_from_file(sGtkBuilderFile, "MainWindow");
} catch (const Gtk::BuilderError& e) {
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
VBA::Window* poWindow = NULL;
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
if (listRemaining.size() == 1) {
// Display the window before loading the file
poWindow->show();
while (Gtk::Main::events_pending()) {
Gtk::Main::iteration();
}
poWindow->bLoadROM(listRemaining[0]);
}
Gtk::Main::run(*poWindow);
delete poWindow;
return 0;
}

View File

@ -1,119 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screenarea-cairo.h"
#include <cstring>
namespace VBA {
template <typename T>
T min(T x, T y) { return x < y ? x : y; }
template <typename T>
T max(T x, T y) { return x > y ? x : y; }
ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
: ScreenArea(_iWidth, _iHeight, _iScale)
{
vUpdateSize();
}
void ScreenAreaCairo::vDrawPixels(uint8_t* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
queue_draw();
}
#if !GTK_CHECK_VERSION(3, 0, 0)
bool ScreenAreaCairo::on_expose_event(GdkEventExpose* _pstEvent)
{
DrawingArea::on_expose_event(_pstEvent);
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::RefPtr<Cairo::Context> poContext;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
poContext = get_window()->create_cairo_context();
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((uint8_t*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
return true;
}
#else
bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
{
DrawingArea::on_draw(poContext);
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((uint8_t*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
return true;
}
#endif
void ScreenAreaCairo::vDrawBlackScreen()
{
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(uint32_t));
queue_draw_area(0, 0, get_width(), get_height());
}
}
void ScreenAreaCairo::vOnWidgetResize()
{
m_dScaleFactor = min<double>(get_height() / (double)m_iHeight, get_width() / (double)m_iWidth);
m_dScaleFactor /= m_iFilterScale;
m_iAreaTop = (get_height() / m_dScaleFactor - m_iHeight * m_iFilterScale) / 2;
m_iAreaLeft = (get_width() / m_dScaleFactor - m_iWidth * m_iFilterScale) / 2;
}
} // namespace VBA

View File

@ -1,48 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SCREENAREA_CAIRO_H__
#define __VBA_SCREENAREA_CAIRO_H__
#include "screenarea.h"
namespace VBA {
class ScreenAreaCairo : public ScreenArea {
public:
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(uint8_t* _puiData);
void vDrawBlackScreen();
protected:
#if !GTK_CHECK_VERSION(3, 0, 0)
bool on_expose_event(GdkEventExpose* _pstEvent);
#else
bool on_draw(const Cairo::RefPtr<Cairo::Context>& poContext);
#endif
void vOnWidgetResize();
private:
double m_dScaleFactor;
int m_iAreaTop;
int m_iAreaLeft;
};
} // namespace VBA
#endif // __VBA_SCREENAREA_CAIRO_H__

View File

@ -1,192 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screenarea-opengl.h"
#include "intl.h"
#include <cstring>
namespace VBA {
template <typename T>
T min(T x, T y) { return x < y ? x : y; }
template <typename T>
T max(T x, T y) { return x > y ? x : y; }
ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale)
: ScreenArea(_iWidth, _iHeight, _iScale)
, m_uiScreenTexture(0)
, m_iTextureSize(0)
{
Glib::RefPtr<Gdk::GL::Config> glconfig;
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DOUBLE);
if (!glconfig) {
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
throw std::exception();
}
set_gl_capability(glconfig);
vUpdateSize();
}
void ScreenAreaGl::vUpdateTexture()
{
// Calculate the new texture size as a the smallest working power of two
// TODO: Support the ARB_texture_rectangle extension
int iExpX = 0, iExpY = 0;
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX)
;
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY)
;
int iNewTextureSize = 1 << max(iExpX, iExpY);
// Notify the system if the texture size changed
if (iNewTextureSize != m_iTextureSize) {
m_iTextureSize = iNewTextureSize;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iNewTextureSize, iNewTextureSize,
0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
}
}
void ScreenAreaGl::on_realize()
{
Gtk::DrawingArea::on_realize();
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
if (glIsTexture(m_uiScreenTexture))
glDeleteTextures(1, &m_uiScreenTexture);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 1.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glGenTextures(1, &m_uiScreenTexture);
glBindTexture(GL_TEXTURE_2D, m_uiScreenTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
vUpdateTexture();
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glwindow->gl_end();
}
void ScreenAreaGl::vDrawPixels(uint8_t* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
queue_draw_area(0, 0, get_width(), get_height());
}
void ScreenAreaGl::vDrawBlackScreen()
{
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(uint32_t));
queue_draw_area(0, 0, get_width(), get_height());
}
}
void ScreenAreaGl::vOnWidgetResize()
{
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
int iWidth = get_width();
int iHeight = get_height();
float fScreenAspect = (float)m_iScaledWidth / m_iScaledHeight,
fWindowAspect = (float)iWidth / iHeight;
if (!glwindow->gl_begin(get_gl_context()))
return;
if (fWindowAspect == fScreenAspect)
glViewport(0, 0, iWidth, iHeight);
else if (fWindowAspect < fScreenAspect) {
int iAspectHeight = (int)(iWidth / fScreenAspect);
glViewport(0, (iHeight - iAspectHeight) / 2, iWidth, iAspectHeight);
} else {
int iAspectWidth = (int)(iHeight * fScreenAspect);
glViewport((iWidth - iAspectWidth) / 2, 0, iAspectWidth, iHeight);
}
glwindow->gl_end();
}
bool ScreenAreaGl::on_expose_event(GdkEventExpose* _pstEvent)
{
if (!m_bEnableRender)
return true;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return false;
glClear(GL_COLOR_BUFFER_BIT);
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_iScaledWidth + 1, m_iScaledHeight,
GL_RGBA, GL_UNSIGNED_BYTE, m_puiPixels);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f, 0.0f);
glVertex3i(0, 0, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize, 0.0f);
glVertex3i(1, 0, 0);
glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat)m_iTextureSize);
glVertex3i(0, 1, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize,
m_iScaledHeight / (GLfloat)m_iTextureSize);
glVertex3i(1, 1, 0);
glEnd();
glwindow->swap_buffers();
glwindow->gl_end();
return true;
}
void ScreenAreaGl::vOnSizeUpdated()
{
if (!get_realized())
return;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
vUpdateTexture();
glwindow->gl_end();
}
} // namespace VBA

View File

@ -1,48 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SCREENAREA_OPENGL_H__
#define __VBA_SCREENAREA_OPENGL_H__
#include "screenarea.h"
#include <gtkmm/gl/widget.h>
namespace VBA {
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(uint8_t* _puiData);
void vDrawBlackScreen();
protected:
void on_realize();
bool on_expose_event(GdkEventExpose* _pstEvent);
void vOnWidgetResize();
private:
GLuint m_uiScreenTexture;
int m_iTextureSize;
void vUpdateTexture();
void vOnSizeUpdated();
};
} // namespace VBA
#endif // __VBA_SCREENAREA_OPENGL_H__

View File

@ -1,236 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screenarea.h"
#include <cstring>
#include <glibmm/main.h>
namespace VBA {
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale)
: m_iFilterScale(1)
, m_vFilter2x(NULL)
, m_vFilterIB(NULL)
, m_puiPixels(NULL)
, m_puiDelta(NULL)
, m_iScaledWidth(_iWidth)
, m_iScaledHeight(_iHeight)
, m_bEnableRender(true)
, m_bShowCursor(true)
{
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
m_iWidth = _iWidth;
m_iHeight = _iHeight;
m_iScale = _iScale;
set_events(Gdk::EXPOSURE_MASK
| Gdk::POINTER_MOTION_MASK
| Gdk::ENTER_NOTIFY_MASK
| Gdk::LEAVE_NOTIFY_MASK);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8);
pixbuf->fill(0);
#if !GTK_CHECK_VERSION(3, 0, 0)
m_poEmptyCursor = new Gdk::Cursor(get_display(), pixbuf, 0, 0);
#else
m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
#endif
}
ScreenArea::~ScreenArea()
{
if (m_puiPixels) {
delete[] m_puiPixels;
}
if (m_puiDelta) {
delete[] m_puiDelta;
}
#if !GTK_CHECK_VERSION(3, 0, 0)
if (m_poEmptyCursor != NULL) {
delete m_poEmptyCursor;
}
#else
m_poEmptyCursor.reset();
#endif
}
void ScreenArea::vSetSize(int _iWidth, int _iHeight)
{
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
if (_iWidth != m_iWidth || _iHeight != m_iHeight) {
m_iWidth = _iWidth;
m_iHeight = _iHeight;
vUpdateSize();
}
}
void ScreenArea::vSetScale(int _iScale)
{
g_return_if_fail(_iScale >= 1);
if (_iScale == 1) {
vSetFilter(FilterNone);
}
m_iScale = _iScale;
vUpdateSize();
}
void ScreenArea::vSetFilter(EFilter _eFilter)
{
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
m_iFilterScale = 1;
if (m_vFilter2x != NULL) {
m_iFilterScale = 2;
}
vUpdateSize();
}
void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB)
{
m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
}
void ScreenArea::vStartCursorTimeout()
{
m_oCursorSig.disconnect();
m_oCursorSig = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &ScreenArea::bOnCursorTimeout),
2000);
}
void ScreenArea::vStopCursorTimeout()
{
m_oCursorSig.disconnect();
}
void ScreenArea::vHideCursor()
{
#if !GTK_CHECK_VERSION(3, 0, 0)
get_window()->set_cursor(*m_poEmptyCursor);
#else
get_window()->set_cursor(m_poEmptyCursor);
#endif
m_bShowCursor = false;
}
void ScreenArea::vShowCursor()
{
get_window()->set_cursor();
m_bShowCursor = true;
}
bool ScreenArea::on_motion_notify_event(GdkEventMotion* _pstEvent)
{
if (!m_bShowCursor) {
vShowCursor();
}
vStartCursorTimeout();
return false;
}
bool ScreenArea::on_enter_notify_event(GdkEventCrossing* _pstEvent)
{
vStartCursorTimeout();
return false;
}
bool ScreenArea::on_leave_notify_event(GdkEventCrossing* _pstEvent)
{
vStopCursorTimeout();
if (!m_bShowCursor) {
vShowCursor();
}
return false;
}
bool ScreenArea::bOnCursorTimeout()
{
vHideCursor();
return false;
}
void ScreenArea::vDrawPixels(uint8_t* _puiData)
{
const int iSrcPitch = (m_iWidth + 1) * sizeof(uint32_t);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
if (m_vFilterIB != NULL) {
m_vFilterIB(_puiData + iSrcPitch,
iSrcPitch,
m_iWidth,
m_iHeight);
}
if (m_vFilter2x != NULL) {
m_vFilter2x(_puiData + iSrcPitch,
iSrcPitch,
m_puiDelta,
(uint8_t*)m_puiPixels,
iScaledPitch,
m_iWidth,
m_iHeight);
} else {
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
}
}
void ScreenArea::vUpdateSize()
{
if (m_puiPixels) {
delete[] m_puiPixels;
}
if (m_puiDelta) {
delete[] m_puiDelta;
}
m_iScaledWidth = m_iFilterScale * m_iWidth;
m_iScaledHeight = m_iFilterScale * m_iHeight;
m_puiPixels = new uint32_t[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new uint8_t[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(uint32_t)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(uint32_t));
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(uint32_t));
vOnSizeUpdated();
set_size_request(m_iScale * m_iWidth, m_iScale * m_iHeight);
}
bool ScreenArea::on_configure_event(GdkEventConfigure* event)
{
vOnWidgetResize();
return true;
}
void ScreenArea::vSetEnableRender(bool _bEnable)
{
m_bEnableRender = _bEnable;
}
} // namespace VBA

View File

@ -1,85 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SCREENAREA_H__
#define __VBA_SCREENAREA_H__
#include <gdkmm/cursor.h>
#include <gtkmm/drawingarea.h>
#include "filters.h"
namespace VBA {
class ScreenArea : public Gtk::DrawingArea {
public:
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
virtual ~ScreenArea();
void vSetSize(int _iWidth, int _iHeight);
void vSetScale(int _iScale);
void vSetFilter(EFilter _eFilter);
void vSetFilterIB(EFilterIB _eFilterIB);
void vSetEnableRender(bool _bEnable);
virtual void vDrawPixels(uint8_t* _puiData);
virtual void vDrawBlackScreen() = 0;
protected:
virtual bool on_motion_notify_event(GdkEventMotion* _pstEvent);
virtual bool on_enter_notify_event(GdkEventCrossing* _pstEvent);
virtual bool on_leave_notify_event(GdkEventCrossing* _pstEvent);
virtual bool on_configure_event(GdkEventConfigure* event);
virtual bool bOnCursorTimeout();
virtual void vOnSizeUpdated()
{
}
int m_iWidth;
int m_iHeight;
int m_iScale;
int m_iFilterScale;
int m_iAreaWidth;
int m_iAreaHeight;
Filter m_vFilter2x;
FilterIB m_vFilterIB;
uint32_t* m_puiPixels;
uint8_t* m_puiDelta;
int m_iScaledWidth;
int m_iScaledHeight;
bool m_bEnableRender;
bool m_bShowCursor;
#if !GTK_CHECK_VERSION(3, 0, 0)
Gdk::Cursor* m_poEmptyCursor;
#else
Glib::RefPtr<Gdk::Cursor> m_poEmptyCursor;
#endif
sigc::connection m_oCursorSig;
void vUpdateSize();
virtual void vOnWidgetResize() = 0;
void vStartCursorTimeout();
void vStopCursorTimeout();
void vHideCursor();
void vShowCursor();
};
} // namespace VBA
#endif // __VBA_SCREENAREA_H__

View File

@ -1,130 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "soundconfig.h"
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA {
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
m_poVolumeComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnVolumeChanged));
m_poRateComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnRateChanged));
}
void SoundConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
bool bMute = m_poConfig->oGetKey<bool>("mute");
float fSoundVolume = m_poConfig->oGetKey<float>("volume");
if (bMute)
m_poVolumeComboBox->set_active(0);
else if (0.0f <= fSoundVolume && fSoundVolume <= 0.25f)
m_poVolumeComboBox->set_active(1);
else if (0.25f < fSoundVolume && fSoundVolume <= 0.50f)
m_poVolumeComboBox->set_active(2);
else if (1.0f < fSoundVolume && fSoundVolume <= 2.0f)
m_poVolumeComboBox->set_active(4);
else
m_poVolumeComboBox->set_active(3);
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
switch (iSoundSampleRate) {
case 11025:
m_poRateComboBox->set_active(0);
break;
case 22050:
m_poRateComboBox->set_active(1);
break;
default:
case 44100:
m_poRateComboBox->set_active(2);
break;
case 48000:
m_poRateComboBox->set_active(3);
break;
}
}
void SoundConfigDialog::vOnVolumeChanged()
{
int iVolume = m_poVolumeComboBox->get_active_row_number();
switch (iVolume) {
case 0: // Mute
m_poConfig->vSetKey("mute", true);
m_poConfig->vSetKey("volume", 1.0f);
break;
case 1: // 25 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.25f);
break;
case 2: // 50 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.50f);
break;
case 4: // 200 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 2.00f);
break;
case 3: // 100 %
default:
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 1.00f);
break;
}
m_poWindow->vApplyConfigMute();
m_poWindow->vApplyConfigVolume();
}
void SoundConfigDialog::vOnRateChanged()
{
int iRate = m_poRateComboBox->get_active_row_number();
switch (iRate) {
case 0: // 11 KHz
m_poConfig->vSetKey("sample_rate", 11025);
break;
case 1: // 22 KHz
m_poConfig->vSetKey("sample_rate", 22050);
break;
case 2: // 44 KHz
default:
m_poConfig->vSetKey("sample_rate", 44100);
break;
case 3: // 48 KHz
m_poConfig->vSetKey("sample_rate", 48000);
break;
}
m_poWindow->vApplyConfigSoundSampleRate();
}
} // namespace VBA

View File

@ -1,49 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SOUNDCONFIG_H__
#define __VBA_SOUNDCONFIG_H__
#include <gtkmm/builder.h>
#include <gtkmm/combobox.h>
#include <gtkmm/dialog.h>
#include "configfile.h"
#include "window.h"
namespace VBA {
class SoundConfigDialog : public Gtk::Dialog {
public:
SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnVolumeChanged();
void vOnRateChanged();
VBA::Window* m_poWindow;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poVolumeComboBox;
Gtk::ComboBox* m_poRateComboBox;
};
} // namespace VBA
#endif // __VBA_SOUNDCONFIG_H__

View File

@ -1,200 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "../common/SoundSDL.h"
#include "../gba/Sound.h"
#include "../sdl/inputSDL.h"
#include "intl.h"
#include "window.h"
// Required vars, used by the emulator core
//
int systemRedShift;
int systemGreenShift;
int systemBlueShift;
int systemColorDepth;
int systemVerbose;
int systemSaveUpdateCounter;
int systemFrameSkip;
uint32_t systemColorMap32[0x10000];
uint16_t systemColorMap16[0x10000];
uint16_t systemGbPalette[24];
int emulating;
int RGB_LOW_BITS_MASK;
inline VBA::Window* GUI()
{
return VBA::Window::poGetInstance();
}
void systemMessage(int _iId, const char* _csFormat, ...)
{
va_list args;
va_start(args, _csFormat);
GUI()
->vPopupErrorV(_(_csFormat), args);
va_end(args);
}
void systemDrawScreen()
{
GUI()
->vDrawScreen();
}
bool systemReadJoypads()
{
return true;
}
uint32_t systemReadJoypad(int joy)
{
return inputReadJoypad(joy);
}
void systemShowSpeed(int _iSpeed)
{
GUI()
->vShowSpeed(_iSpeed);
}
void system10Frames(int _iRate)
{
GUI()
->vComputeFrameskip(_iRate);
}
void systemFrame()
{
}
void systemSetTitle(const char* _csTitle)
{
GUI()
->set_title(_csTitle);
}
void systemScreenCapture(int _iNum)
{
GUI()
->vCaptureScreen(_iNum);
}
uint32_t systemGetClock()
{
Glib::TimeVal time;
time.assign_current_time();
return time.as_double() * 1000;
}
void systemUpdateMotionSensor()
{
}
uint8_t systemGetSensorDarkness()
{
return 0xE8;
}
int systemGetSensorX()
{
return 0;
}
int systemGetSensorY()
{
return 0;
}
int systemGetSensorZ()
{
return 0;
}
void systemCartridgeRumble(bool)
{
}
void systemGbPrint(uint8_t* _puiData,
int _iLen,
int _iPages,
int _iFeed,
int _iPalette,
int _iContrast)
{
}
void systemScreenMessage(const char* _csMsg)
{
}
bool systemCanChangeSoundQuality()
{
return true;
}
bool systemPauseOnFrame()
{
return false;
}
void systemGbBorderOn()
{
}
SoundDriver* systemSoundInit()
{
soundShutdown();
return new SoundSDL();
}
void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const uint16_t* finalWave, int length)
{
}
void debuggerMain()
{
}
void debuggerSignal(int, int)
{
}
void log(const char* defaultMsg, ...)
{
static FILE* out = NULL;
if (out == NULL) {
out = fopen("trace.log", "w");
}
va_list valist;
va_start(valist, defaultMsg);
vfprintf(out, defaultMsg, valist);
va_end(valist);
}

View File

@ -1,77 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "tools.h"
namespace VBA {
std::string sCutSuffix(const std::string& _rsString,
const std::string& _rsSep)
{
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
}
Glib::ustring sCutSuffix(const Glib::ustring& _rsString,
const Glib::ustring& _rsSep)
{
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
}
bool bHasSuffix(const Glib::ustring& _rsString,
const Glib::ustring& _rsSuffix,
bool _bCaseSensitive)
{
if (_rsSuffix.size() > _rsString.size()) {
return false;
}
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
if (_bCaseSensitive) {
if (_rsSuffix == sEnd) {
return true;
}
} else {
if (_rsSuffix.lowercase() == sEnd.lowercase()) {
return true;
}
}
return false;
}
void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens)
{
Glib::ustring delimiters = " \t\n\r";
// Skip delimiters at beginning.
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
while (Glib::ustring::npos != pos || std::string::npos != lastPos) {
// Found a token, add it to the vector.
tokens.push_back(source.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = source.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = source.find_first_of(delimiters, lastPos);
}
}
} // namespace VBA

View File

@ -1,38 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_TOOLS_H__
#define __VBA_TOOLS_H__
#include <glibmm/ustring.h>
#include <string>
#include <vector>
namespace VBA {
std::string sCutSuffix(const std::string& _rsString, const std::string& _rsSep = ".");
Glib::ustring sCutSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSep = ".");
bool bHasSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSuffix,
bool _bCaseSensitive = true);
void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens);
}
#endif // __VBA_TOOLS_H__

View File

@ -1,179 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="CheatEditDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Edit cheat</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkEntry" id="CheatDescEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">31</property>
<property name="invisible_char">●</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkComboBox" id="CheatTypeComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Type&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTextView" id="CheatInputTextView">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Codes&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="CheatApplyButton">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="CheatCancelButton">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">CheatApplyButton</action-widget>
<action-widget response="0">CheatCancelButton</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,180 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="CheatListDialog">
<property name="width_request">320</property>
<property name="height_request">260</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Cheat list</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<object class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<child>
<object class="GtkToolButton" id="CheatOpenButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Open cheat list</property>
<property name="label">gtk-open</property>
<property name="use_underline">True</property>
<property name="icon_name">document-open</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="CheatSaveButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Save cheat list</property>
<property name="label">gtk-save</property>
<property name="use_underline">True</property>
<property name="icon_name">document-save</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separator2">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="CheatAddButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Add new cheat</property>
<property name="label">gtk-add</property>
<property name="use_underline">True</property>
<property name="icon_name">list-add</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="CheatRemoveButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Delete selected cheat</property>
<property name="label">gtk-delete</property>
<property name="use_underline">True</property>
<property name="icon_name">list-remove</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="CheatRemoveAllButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Delete all cheats</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-clear</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separator1">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="CheatMarkAllButton">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Toggle all Cheats</property>
<property name="label">gtk-markall</property>
<property name="use_underline">True</property>
<property name="icon_name">edit-select-all</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTreeView" id="CheatTreeView">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,277 +0,0 @@
<?xml version="1.0"?>
<interface>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">600</property>
<property name="lower">100</property>
<property name="page_increment">10</property>
<property name="step_increment">100</property>
<property name="page_size">10</property>
<property name="value">100</property>
</object>
<object class="GtkListStore" id="IBFiltersListStore">
<columns>
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="FiltersListStore">
<columns>
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="ScalingListStore">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">1x</col>
</row>
<row>
<col id="0">2x</col>
</row>
<row>
<col id="0">3x</col>
</row>
<row>
<col id="0">4x</col>
</row>
<row>
<col id="0">5x</col>
</row>
<row>
<col id="0">6x</col>
</row>
</data>
</object>
<object class="GtkDialog" id="DisplayConfigDialog">
<property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<object class="GtkRadioButton" id="OutputOpenGL">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">OpenGL</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkRadioButton" id="OutputCairo">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Cairo</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">OutputOpenGL</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Output module&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Default scale : </property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="DefaultScaleComboBox">
<property name="visible">True</property>
<property name="model">ScalingListStore</property>
<child>
<object class="GtkCellRendererText" id="renderer3"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Zoom&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Interframe blending : </property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Fullscreen filter : </property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="IBFiltersComboBox">
<property name="visible">True</property>
<property name="model">IBFiltersListStore</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="FiltersComboBox">
<property name="visible">True</property>
<property name="model">FiltersListStore</property>
<child>
<object class="GtkCellRendererText" id="renderer2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Filters&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="1">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,205 +0,0 @@
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Fri Jan 23 14:39:58 2009 -->
<interface>
<object class="GtkListStore" id="model1">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Automatic</col>
</row>
<row>
<col id="0" translatable="yes">Game Boy Advance</col>
</row>
<row>
<col id="0" translatable="yes">Game Boy Color</col>
</row>
<row>
<col id="0" translatable="yes">Super Game Boy</col>
</row>
<row>
<col id="0" translatable="yes">Super Game Boy 2</col>
</row>
<row>
<col id="0" translatable="yes">Game Boy</col>
</row>
</data>
</object>
<object class="GtkDialog" id="GameBoyConfigDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">GameBoy settings</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Emulated system : </property>
</object>
</child>
<child>
<object class="GtkComboBox" id="SystemComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkCheckButton" id="BorderCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Display Super Game Boy borders</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="PrinterCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Emulate a Game Boy Printer</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;System and peripherals&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="BootRomCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use a Game Boy boot ROM file</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Boot ROM file : </property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="BootRomFileChooserButton">
<property name="visible">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Boot ROM&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,264 +0,0 @@
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Fri Jan 23 15:53:56 2009 -->
<interface>
<object class="GtkListStore" id="model1">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">64K</col>
</row>
<row>
<col id="0">128K</col>
</row>
</data>
</object>
<object class="GtkListStore" id="model2">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Automatic</col>
</row>
<row>
<col id="0" translatable="yes">EEPROM</col>
</row>
<row>
<col id="0" translatable="yes">SRAM</col>
</row>
<row>
<col id="0" translatable="yes">Flash</col>
</row>
<row>
<col id="0" translatable="yes">EEPROM + Sensor</col>
</row>
<row>
<col id="0" translatable="yes">None</col>
</row>
</data>
</object>
<object class="GtkDialog" id="GameBoyAdvanceConfigDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Game Boy Advance settings</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<object class="GtkComboBox" id="FlashSizeComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="SaveTypeComboBox">
<property name="visible">True</property>
<property name="model">model2</property>
<child>
<object class="GtkCellRendererText" id="renderer2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="label" translatable="yes">Flash size : </property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Save type : </property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Cartridge&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="BiosCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use a bios file</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Bios file : </property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="BiosFileChooserButton">
<property name="visible">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Bios&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="RTCCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable real-time clock</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Real-Time Clock&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,225 +0,0 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="PreferencesDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Preferences</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkCheckButton" id="PauseWhenInactiveCheckButton">
<property name="label" translatable="yes">Pause when inactive</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;General&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkCheckButton" id="FrameSkipAutomaticCheckButton">
<property name="label" translatable="yes">Enable automatic frame skipping</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Frameskip level : </property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="FrameSkipLevelSpinButton">
<property name="visible">True</property>
<property name="editable">False</property>
<property name="adjustment">FrameSkipAdjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Frameskip&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="label" translatable="yes">Speed indicator : </property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="SpeedIndicatorComboBox">
<property name="visible">True</property>
<property name="model">SpeedIndicatorListStore</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Appearance&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button2</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="SpeedIndicatorListStore">
<columns>
<!-- column-name SpeedType -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">None</col>
</row>
<row>
<col id="0" translatable="yes">Percentage</col>
</row>
<row>
<col id="0" translatable="yes">Detailed</col>
</row>
</data>
</object>
<object class="GtkAdjustment" id="FrameSkipAdjustment">
<property name="upper">9</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
</interface>

View File

@ -1,153 +0,0 @@
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Tue Dec 23 13:54:59 2008 -->
<interface>
<object class="GtkListStore" id="model1">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Mute</col>
</row>
<row>
<col id="0" translatable="yes">25 %</col>
</row>
<row>
<col id="0" translatable="yes">50 %</col>
</row>
<row>
<col id="0" translatable="yes">100 %</col>
</row>
<row>
<col id="0" translatable="yes">200 %</col>
</row>
</data>
</object>
<object class="GtkListStore" id="model2">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0">11 KHz</col>
</row>
<row>
<col id="0">22 KHz</col>
</row>
<row>
<col id="0">44.1 KHz</col>
</row>
<row>
<col id="0">48 KHz</col>
</row>
</data>
</object>
<object class="GtkDialog" id="SoundConfigDialog">
<property name="border_width">5</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">10</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<property name="row_spacing">10</property>
<child>
<object class="GtkComboBox" id="VolumeComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Volume : </property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Sample rate : </property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="RateComboBox">
<property name="visible">True</property>
<property name="model">model2</property>
<child>
<object class="GtkCellRendererText" id="renderer2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -1,596 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">VBA</property>
<accel-groups>
<group name="accelgroup1"/>
</accel-groups>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuBar" id="MenuBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="FileMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="FileMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="FileOpen">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="accel_group">accelgroup1</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="RecentMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Open rece_nt</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator4">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="FileScreenCapture">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Screen capt_ure...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator6">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="FileClose">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="accel_group">accelgroup1</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="FileExit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="accel_group">accelgroup1</property>
<accelerator key="X" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="EmulationMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Emulation</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="EmulationMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkCheckMenuItem" id="FilePause">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Pause</property>
<property name="use_underline">True</property>
<accelerator key="P" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="FileReset">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Reset</property>
<property name="use_underline">True</property>
<accelerator key="R" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="VideoFullscreen">
<property name="label">gtk-fullscreen</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="accel_group">accelgroup1</property>
<accelerator key="F11" signal="activate"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Loa_d state</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="LoadGameMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="LoadGameMostRecent">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Most recent</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="LoadGameAuto">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Auto load most recent</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator28">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot1</property>
<property name="use_underline">True</property>
<accelerator key="F1" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot2</property>
<property name="use_underline">True</property>
<accelerator key="F2" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot3</property>
<property name="use_underline">True</property>
<accelerator key="F3" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot4</property>
<property name="use_underline">True</property>
<accelerator key="F4" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot5</property>
<property name="use_underline">True</property>
<accelerator key="F5" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot6</property>
<property name="use_underline">True</property>
<accelerator key="F6" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot7</property>
<property name="use_underline">True</property>
<accelerator key="F7" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot8</property>
<property name="use_underline">True</property>
<accelerator key="F8" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot9</property>
<property name="use_underline">True</property>
<accelerator key="F9" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadGameSlot10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot10</property>
<property name="use_underline">True</property>
<accelerator key="F10" signal="activate"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="FileLoad">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">From _File ...</property>
<property name="use_underline">True</property>
<accelerator key="L" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">S_ave state</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="SaveGameMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="SaveGameOldest">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Oldest slot</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator27">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot1</property>
<property name="use_underline">True</property>
<accelerator key="F1" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot2</property>
<property name="use_underline">True</property>
<accelerator key="F2" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot3</property>
<property name="use_underline">True</property>
<accelerator key="F3" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot4</property>
<property name="use_underline">True</property>
<accelerator key="F4" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot5</property>
<property name="use_underline">True</property>
<accelerator key="F5" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot6</property>
<property name="use_underline">True</property>
<accelerator key="F6" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot7</property>
<property name="use_underline">True</property>
<accelerator key="F7" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot8</property>
<property name="use_underline">True</property>
<accelerator key="F8" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot9</property>
<property name="use_underline">True</property>
<accelerator key="F9" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SaveGameSlot10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Slot10</property>
<property name="use_underline">True</property>
<accelerator key="F10" signal="activate" modifiers="GDK_SHIFT_MASK"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator25">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="FileSave">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">To _File ...</property>
<property name="use_underline">True</property>
<accelerator key="S" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separator34">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="CheatList">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_List cheats ...</property>
<property name="use_underline">True</property>
<accelerator key="C" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="CheatDisable">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Disable cheats</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="OptionsMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Options</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="OptionsMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="GeneralConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Preferences ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="GameBoyConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Game Boy ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="GameBoyAdvanceConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Game Boy _Advance ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="DisplayConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Display ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="SoundConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Sound ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="DirectoriesConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">D_irectories ...</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="JoypadConfigure">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Joypads ...</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="HelpMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="HelpMenu_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="HelpAbout">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="accel_group">accelgroup1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="ScreenContainer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkAccelGroup" id="accelgroup1"/>
</interface>

File diff suppressed because it is too large Load Diff

View File

@ -1,277 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_WINDOW_H__
#define __VBA_WINDOW_H__
#include <gtkmm/builder.h>
#include <gtkmm/checkmenuitem.h>
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/menubar.h>
#include <gtkmm/recentchoosermenu.h>
#include <gtkmm/window.h>
#include "../System.h"
#include "../sdl/inputSDL.h"
#include "configfile.h"
#include "filters.h"
#include "screenarea.h"
namespace VBA {
class Window : public Gtk::Window {
friend class Gtk::Builder;
public:
virtual ~Window();
inline static Window* poGetInstance()
{
return m_poInstance;
}
static std::string sGetUiFilePath(const std::string& _sFileName);
enum ECartridge { CartridgeNone,
CartridgeGB,
CartridgeGBA };
enum EVideoOutput { OutputCairo,
OutputOpenGL };
enum EEmulatorType {
EmulatorAuto,
EmulatorCGB,
EmulatorSGB,
EmulatorGB,
EmulatorGBA,
EmulatorSGB2
};
enum ESaveType { SaveAuto,
SaveEEPROM,
SaveSRAM,
SaveFlash,
SaveEEPROMSensor,
SaveNone };
// GB/GBA screen sizes
const int m_iGBScreenWidth;
const int m_iGBScreenHeight;
const int m_iSGBScreenWidth;
const int m_iSGBScreenHeight;
const int m_iGBAScreenWidth;
const int m_iGBAScreenHeight;
bool bLoadROM(const std::string& _rsFile);
void vPopupError(const char* _csFormat, ...);
void vPopupErrorV(const char* _csFormat, va_list _args);
void vDrawScreen();
void vComputeFrameskip(int _iRate);
void vShowSpeed(int _iSpeed);
void vCaptureScreen(int _iNum);
void vApplyConfigFilter();
void vApplyConfigFilterIB();
void vApplyConfigScreenArea();
void vApplyConfigMute();
void vApplyConfigVolume();
void vApplyConfigSoundSampleRate();
void vApplyConfigGBSystem();
void vApplyConfigGBBorder();
void vApplyConfigGBPrinter();
void vApplyConfigGBASaveType();
void vApplyConfigGBAFlashSize();
void vApplyConfigGBARTC();
void vApplyConfigFrameskip();
void vApplyConfigShowSpeed();
void vApplyPerGameConfig();
void vUpdateScreen();
inline ECartridge eGetCartridge() const
{
return m_eCartridge;
}
protected:
Window(GtkWindow* _pstWindow, const Glib::RefPtr<Gtk::Builder>& _poXml);
enum EShowSpeed { ShowNone,
ShowPercentage,
ShowDetailed };
enum ESoundStatus { SoundOff,
SoundMute,
SoundOn };
enum EColorFormat { ColorFormatRGB,
ColorFormatBGR };
virtual void vOnMenuEnter();
virtual void vOnMenuExit();
virtual void vOnFileOpen();
virtual void vOnFileLoad();
virtual void vOnFileSave();
virtual void vOnLoadGameMostRecent();
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem* _poCMI);
void vOnLoadGame(int _iSlot);
virtual void vOnSaveGameOldest();
void vOnSaveGame(int _iSlot);
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI);
virtual void vOnFileReset();
virtual void vOnRecentFile();
virtual void vOnFileScreenCapture();
virtual void vOnFileClose();
virtual void vOnFileExit();
virtual void vOnVideoFullscreen();
virtual void vOnDirectories();
virtual void vOnGeneralConfigure();
virtual void vOnJoypadConfigure();
virtual void vOnDisplayConfigure();
virtual void vOnSoundConfigure();
virtual void vOnGameBoyConfigure();
virtual void vOnGameBoyAdvanceConfigure();
virtual void vOnCheatList();
virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem* _poCMI);
virtual void vOnHelpAbout();
virtual bool bOnEmuIdle();
virtual bool bOnEmuSaveStateRewind();
virtual bool bOnEmuRewind();
virtual bool on_focus_in_event(GdkEventFocus* _pstEvent);
virtual bool on_focus_out_event(GdkEventFocus* _pstEvent);
virtual bool on_key_press_event(GdkEventKey* _pstEvent);
virtual bool on_key_release_event(GdkEventKey* _pstEvent);
virtual bool on_window_state_event(GdkEventWindowState* _pstEvent);
private:
// Config limits
const int m_iFrameskipMin;
const int m_iFrameskipMax;
const int m_iScaleMin;
const int m_iScaleMax;
const int m_iShowSpeedMin;
const int m_iShowSpeedMax;
const int m_iSaveTypeMin;
const int m_iSaveTypeMax;
const int m_iSoundSampleRateMin;
const int m_iSoundSampleRateMax;
const float m_fSoundVolumeMin;
const float m_fSoundVolumeMax;
const int m_iEmulatorTypeMin;
const int m_iEmulatorTypeMax;
const int m_iFilter2xMin;
const int m_iFilter2xMax;
const int m_iFilterIBMin;
const int m_iFilterIBMax;
const EPad m_iJoypadMin;
const EPad m_iJoypadMax;
const int m_iVideoOutputMin;
const int m_iVideoOutputMax;
static Window* m_poInstance;
Glib::RefPtr<Gtk::Builder> m_poXml;
std::string m_sUserDataDir;
std::string m_sConfigFile;
Config::File m_oConfig;
Config::Section* m_poDirConfig;
Config::Section* m_poCoreConfig;
Config::Section* m_poDisplayConfig;
Config::Section* m_poSoundConfig;
Config::Section* m_poInputConfig;
Gtk::FileChooserDialog* m_poFileOpenDialog;
ScreenArea* m_poScreenArea;
Gtk::CheckMenuItem* m_poFilePauseItem;
Gtk::MenuBar* m_poMenuBar;
struct SGameSlot {
bool m_bEmpty;
std::string m_sFile;
time_t m_uiTime;
};
struct SJoypadKey {
const char* m_csKey;
const EKey m_eKeyFlag;
};
static const SJoypadKey m_astJoypad[];
Gtk::MenuItem* m_apoLoadGameItem[10];
Gtk::MenuItem* m_apoSaveGameItem[10];
SGameSlot m_astGameSlot[10];
Glib::RefPtr<Gtk::RecentManager> m_poRecentManager;
Gtk::MenuItem* m_poRecentMenu;
Gtk::RecentChooserMenu* m_poRecentChooserMenu;
std::list<Gtk::Widget*> m_listSensitiveWhenPlaying;
sigc::connection m_oEmuSig, m_oEmuRewindSig;
int m_bFullscreen;
int m_iScreenWidth;
int m_iScreenHeight;
int m_iFrameCount;
std::string m_sRomFile;
ECartridge m_eCartridge;
EmulatedSystem m_stEmulator;
bool m_bPaused;
bool m_bWasEmulating;
bool m_bAutoFrameskip;
EShowSpeed m_eShowSpeed;
/* State saving into memory & rewind to saved state */
uint16_t m_state_count_max;
uint16_t m_rewind_interval;
static const uint32_t SZSTATE = 1024 * 512;
std::deque<char*> m_rewind_load_q;
char* m_psavestate;
void vInitSystem();
void vUnInitSystem();
void vInitSDL();
void vInitConfig();
void vCheckConfig();
void vInitColors(EColorFormat _eColorFormat);
void vLoadConfig(const std::string& _rsFile);
void vSaveConfig(const std::string& _rsFile);
void vHistoryAdd(const std::string& _rsFile);
void vApplyConfigJoypads();
void vSaveJoypadsToConfig();
void vDrawDefaultScreen();
void vSetDefaultTitle();
void vCreateFileOpenDialog();
void vLoadBattery();
void vLoadCheats();
void vSaveBattery();
void vSaveCheats();
void vStartEmu();
void vStopEmu();
void vUpdateGameSlots();
void vToggleFullscreen();
void vSDLPollEvents();
};
} // namespace VBA
#endif // __VBA_WINDOW_H__

View File

@ -1,669 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "window.h"
#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
#include <glibmm/main.h>
#include <glibmm/miscutils.h>
#include <deque>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/builder.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/stock.h>
#include "SDL.h"
#include "../Util.h"
#include "../common/ConfigManager.h"
#include "../gb/gb.h"
#include "../gb/gbGlobals.h"
#include "../gba/GBA.h"
#include "../gba/Sound.h"
#include "../sdl/inputSDL.h"
#include "directoriesconfig.h"
#include "displayconfig.h"
#include "gameboyadvancecheatlist.h"
#include "gameboyadvanceconfig.h"
#include "gameboycheatlist.h"
#include "gameboyconfig.h"
#include "generalconfig.h"
#include "intl.h"
#include "joypadconfig.h"
#include "soundconfig.h"
#include "tools.h"
namespace VBA {
void Window::vOnMenuEnter()
{
if (emulating && !m_bPaused) {
vStopEmu();
soundPause();
}
}
void Window::vOnMenuExit()
{
if (emulating && !m_bPaused) {
vStartEmu();
soundResume();
}
}
void Window::vOnFileOpen()
{
while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) {
if (bLoadROM(m_poFileOpenDialog->get_filename())) {
break;
}
}
m_poFileOpenDialog->hide();
}
void Window::vOnFileLoad()
{
std::string sSaveDir = m_poDirConfig->sGetKey("saves");
Gtk::FileChooserDialog oDialog(*this, _("Load game"));
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
if (sSaveDir == "") {
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} else {
oDialog.set_current_folder(sSaveDir);
oDialog.add_shortcut_folder(sSaveDir);
}
#if !GTK_CHECK_VERSION(3, 0, 0)
Gtk::FileFilter oSaveFilter;
oSaveFilter.set_name(_("VisualBoyAdvance save game"));
oSaveFilter.add_pattern("*.[sS][gG][mM]");
#else
const Glib::RefPtr<Gtk::FileFilter> oSaveFilter = Gtk::FileFilter::create();
oSaveFilter->set_name(_("VisualBoyAdvance save game"));
oSaveFilter->add_pattern("*.[sS][gG][mM]");
#endif
oDialog.add_filter(oSaveFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) {
if (m_stEmulator.emuReadState(oDialog.get_filename().c_str())) {
break;
}
}
}
void Window::vOnFileSave()
{
Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves");
Gtk::FileChooserDialog oDialog(*this, _("Save game"),
Gtk::FILE_CHOOSER_ACTION_SAVE);
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
if (sSaveDir == "") {
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} else {
oDialog.set_current_folder(sSaveDir);
oDialog.add_shortcut_folder(sSaveDir);
}
oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
#if !GTK_CHECK_VERSION(3, 0, 0)
Gtk::FileFilter oSaveFilter;
oSaveFilter.set_name(_("VisualBoyAdvance save game"));
oSaveFilter.add_pattern("*.[sS][gG][mM]");
#else
const Glib::RefPtr<Gtk::FileFilter> oSaveFilter = Gtk::FileFilter::create();
oSaveFilter->set_name(_("VisualBoyAdvance save game"));
oSaveFilter->add_pattern("*.[sS][gG][mM]");
#endif
oDialog.add_filter(oSaveFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) {
Glib::ustring sFile = oDialog.get_filename();
if (!bHasSuffix(sFile, ".sgm", false)) {
sFile += ".sgm";
}
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
Gtk::MessageDialog oConfirmDialog(*this,
_("File already exists. Overwrite it?"),
false,
Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_YES_NO);
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
continue;
}
}
if (m_stEmulator.emuWriteState(sFile.c_str())) {
break;
}
}
}
void Window::vOnLoadGameMostRecent()
{
int iMostRecent = -1;
time_t uiTimeMax = 0;
for (int i = 0; i < 10; i++) {
if (!m_astGameSlot[i].m_bEmpty
&& (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax)) {
iMostRecent = i;
uiTimeMax = m_astGameSlot[i].m_uiTime;
}
}
if (iMostRecent >= 0) {
vOnLoadGame(iMostRecent + 1);
}
}
void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem* _poCMI)
{
m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active());
}
void Window::vOnLoadGame(int _iSlot)
{
int i = _iSlot - 1;
if (!m_astGameSlot[i].m_bEmpty) {
m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
m_poFilePauseItem->set_active(false);
}
}
void Window::vOnSaveGameOldest()
{
int iOldest = -1;
time_t uiTimeMin = 0;
for (int i = 0; i < 10; i++) {
if (!m_astGameSlot[i].m_bEmpty
&& (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)) {
iOldest = i;
uiTimeMin = m_astGameSlot[i].m_uiTime;
}
}
if (iOldest >= 0) {
vOnSaveGame(iOldest + 1);
} else {
vOnSaveGame(1);
}
}
void Window::vOnSaveGame(int _iSlot)
{
int i = _iSlot - 1;
m_stEmulator.emuWriteState(m_astGameSlot[i].m_sFile.c_str());
vUpdateGameSlots();
}
void Window::vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI)
{
m_bPaused = _poCMI->get_active();
if (emulating) {
if (m_bPaused) {
vStopEmu();
soundPause();
} else {
vStartEmu();
soundResume();
}
}
}
void Window::vOnFileReset()
{
if (emulating) {
m_stEmulator.emuReset();
m_poFilePauseItem->set_active(false);
}
}
void Window::vOnRecentFile()
{
Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri();
if (!sURI.empty()) {
std::string sFileName = Glib::filename_from_uri(sURI);
bLoadROM(sFileName);
}
}
void Window::vOnFileScreenCapture()
{
std::string sCaptureDir = m_poDirConfig->sGetKey("captures");
Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"),
Gtk::FILE_CHOOSER_ACTION_SAVE);
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
if (sCaptureDir == "") {
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} else {
oDialog.set_current_folder(sCaptureDir);
oDialog.add_shortcut_folder(sCaptureDir);
}
oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)));
#if !GTK_CHECK_VERSION(3, 0, 0)
Gtk::FileFilter oPngFilter;
oPngFilter.set_name(_("PNG image"));
oPngFilter.add_pattern("*.[pP][nN][gG]");
#else
const Glib::RefPtr<Gtk::FileFilter> oPngFilter = Gtk::FileFilter::create();
oPngFilter->set_name(_("PNG image"));
oPngFilter->add_pattern("*.[pP][nN][gG]");
#endif
oDialog.add_filter(oPngFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) {
Glib::ustring sFile = oDialog.get_filename();
Glib::ustring sExt = ".png";
if (!bHasSuffix(sFile, sExt, false)) {
sFile += sExt;
}
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
Gtk::MessageDialog oConfirmDialog(*this,
_("File already exists. Overwrite it?"),
false,
Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_YES_NO);
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
continue;
}
}
if (m_stEmulator.emuWritePNG(sFile.c_str())) {
break;
}
}
}
void Window::vOnFileClose()
{
if (m_eCartridge != CartridgeNone) {
soundPause();
vStopEmu();
vSetDefaultTitle();
vDrawDefaultScreen();
vSaveBattery();
vSaveCheats();
m_stEmulator.emuCleanUp();
m_eCartridge = CartridgeNone;
emulating = 0;
while (!m_rewind_load_q.empty()) {
delete[] m_rewind_load_q.front();
m_rewind_load_q.pop_front();
}
delete[] m_psavestate;
m_psavestate = NULL;
vUpdateGameSlots();
for (std::list<Gtk::Widget*>::iterator it = m_listSensitiveWhenPlaying.begin();
it != m_listSensitiveWhenPlaying.end();
it++) {
(*it)->set_sensitive(false);
}
m_poFilePauseItem->set_active(false);
}
}
void Window::vOnFileExit()
{
hide();
}
void Window::vOnVideoFullscreen()
{
vToggleFullscreen();
}
void Window::vOnDirectories()
{
DirectoriesConfigDialog oDialog(m_poDirConfig);
oDialog.set_transient_for(*this);
oDialog.run();
// Needed if saves dir changed
vUpdateGameSlots();
}
void Window::vOnJoypadConfigure()
{
JoypadConfigDialog oDialog(m_poInputConfig);
oDialog.set_transient_for(*this);
oDialog.run();
}
void Window::vOnDisplayConfigure()
{
std::string sUiFile = sGetUiFilePath("display.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
DisplayConfigDialog* poDialog = 0;
poBuilder->get_widget_derived("DisplayConfigDialog", poDialog);
poDialog->vSetConfig(m_poDisplayConfig, this);
poDialog->set_transient_for(*this);
poDialog->run();
poDialog->hide();
}
void Window::vOnSoundConfigure()
{
std::string sUiFile = sGetUiFilePath("sound.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
SoundConfigDialog* poDialog = 0;
poBuilder->get_widget_derived("SoundConfigDialog", poDialog);
poDialog->vSetConfig(m_poSoundConfig, this);
poDialog->set_transient_for(*this);
poDialog->run();
poDialog->hide();
}
void Window::vOnGameBoyConfigure()
{
std::string sUiFile = sGetUiFilePath("gameboy.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
GameBoyConfigDialog* poDialog = 0;
poBuilder->get_widget_derived("GameBoyConfigDialog", poDialog);
poDialog->vSetConfig(m_poCoreConfig, this);
poDialog->set_transient_for(*this);
poDialog->run();
poDialog->hide();
}
void Window::vOnGameBoyAdvanceConfigure()
{
std::string sUiFile = sGetUiFilePath("gameboyadvance.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
GameBoyAdvanceConfigDialog* poDialog = 0;
poBuilder->get_widget_derived("GameBoyAdvanceConfigDialog", poDialog);
poDialog->vSetConfig(m_poCoreConfig, this);
poDialog->set_transient_for(*this);
poDialog->run();
poDialog->hide();
}
void Window::vOnGeneralConfigure()
{
std::string sUiFile = sGetUiFilePath("preferences.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
PreferencesDialog* poDialog = 0;
poBuilder->get_widget_derived("PreferencesDialog", poDialog);
poDialog->vSetConfig(m_poCoreConfig, this);
poDialog->set_transient_for(*this);
poDialog->run();
poDialog->hide();
}
void Window::vOnCheatList()
{
if (m_eCartridge == CartridgeGBA) {
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
GameBoyAdvanceCheatListDialog* poDialog = 0;
poBuilder->get_widget_derived("CheatListDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(this);
poDialog->run();
poDialog->hide();
} else if (m_eCartridge == CartridgeGB) {
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
GameBoyCheatListDialog* poDialog = 0;
poBuilder->get_widget_derived("CheatListDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(this);
poDialog->run();
poDialog->hide();
}
}
void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem* _poCMI)
{
if (m_eCartridge == CartridgeGB) {
cheatsEnabled = !cheatsEnabled;
} else if (m_eCartridge == CartridgeGBA) {
cheatsEnabled = !cheatsEnabled;
}
_poCMI->set_active(!cheatsEnabled);
}
void Window::vOnHelpAbout()
{
Gtk::AboutDialog oAboutDialog;
const char csGPLHeader[] = "This program is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 2 of the License, or\n"
"(at your option) any later version.\n\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>.";
const char csCopyright[] = "Copyright (C) 1999-2003 Forgotten\n"
"Copyright (C) 2004-2006 VBA development team\n"
"Copyright (C) 2007-2015 VBA-M development team";
oAboutDialog.set_transient_for(*this);
oAboutDialog.set_name(_("VBA-M"));
oAboutDialog.set_version(VERSION);
oAboutDialog.set_comments(_("Nintendo GameBoy Advance emulator."));
oAboutDialog.set_license(csGPLHeader);
oAboutDialog.set_copyright(csCopyright);
oAboutDialog.set_logo_icon_name("vbam");
oAboutDialog.set_website("http://www.vba-m.com/");
std::vector<Glib::ustring> list_authors;
list_authors.push_back("Forgotten");
list_authors.push_back("kxu");
list_authors.push_back("Pokemonhacker");
list_authors.push_back("Spacy51");
list_authors.push_back("mudlord");
list_authors.push_back("Nach");
list_authors.push_back("jbo_85");
list_authors.push_back("bgK");
oAboutDialog.set_authors(list_authors);
std::vector<Glib::ustring> list_artists;
list_artists.push_back("Matteo Drera");
list_artists.push_back("Jakub Steiner");
list_artists.push_back("Jones Lee");
oAboutDialog.set_artists(list_artists);
oAboutDialog.run();
}
bool Window::bOnEmuRewind()
{
if (!m_rewind_load_q.empty()) {
// load a rewind save state
char* psavestate = m_rewind_load_q.front();
//memset(m_psavestate, 0x0, SZSTATE);
long szstate = *((long*)psavestate); // first there is size
//memmove(m_psavestate, psavestate+sizeof(szstate), szstate-sizeof(szstate));
if (m_stEmulator.emuReadMemState(psavestate + sizeof(szstate), szstate)) {
// the save state is now used so delete it and we have more space
m_rewind_load_q.pop_front();
delete[] psavestate;
//printf ("Restored %p! (%li bytes)\n", psavestate, szstate);
}
return true;
} else {
// no more save states; either disabled, too early, or rewinded all the way to start
return false;
}
}
bool Window::bOnEmuSaveStateRewind()
{
// check if we're disabled
char* psavestate;
if (m_state_count_max == 0u) {
return false;
} else if (m_rewind_load_q.size() >= m_state_count_max) { // check if we can reserve more memory for save states
// if we can't reserve more memory let's take away used save states starting from oldest
psavestate = m_rewind_load_q.back();
m_rewind_load_q.pop_back();
delete[] psavestate;
} // otherwise we can reserve more memory
// Do the actual saving
long resize;
if (m_stEmulator.emuWriteMemState(m_psavestate, SZSTATE, resize)) {
/*resize*=2; // if tell does not return correct size this leverage factor is needed
if (resize > SZSTATE) resize = SZSTATE;*/
g_assert(resize <= (int)SZSTATE);
resize += (sizeof(resize) * 8); // some leverage
psavestate = new char[resize];
memmove(psavestate, &resize, sizeof(resize)); // pack size first
memmove(psavestate + sizeof(resize), m_psavestate, resize - sizeof(resize)); // then actual save data
//printf("Wrote %p (%li bytes %i %i)\n", psavestate, resize, *((long*)psavestate), sizeof(resize));
m_rewind_load_q.push_front(psavestate);
return true;
} else {
return false;
}
}
bool Window::bOnEmuIdle()
{
vSDLPollEvents();
m_stEmulator.emuMain(m_stEmulator.emuCount);
return true;
}
bool Window::on_focus_in_event(GdkEventFocus* _pstEvent)
{
if (emulating && !m_bPaused) {
vStartEmu();
soundResume();
}
return false;
}
bool Window::on_focus_out_event(GdkEventFocus* _pstEvent)
{
if (emulating
&& !m_bPaused
&& m_poCoreConfig->oGetKey<bool>("pause_when_inactive")) {
vStopEmu();
soundPause();
}
return false;
}
bool Window::on_key_press_event(GdkEventKey* _pstEvent)
{
// The menu accelerators are disabled when it is hidden
if (_pstEvent->keyval == GDK_KEY_F11 && !m_poMenuBar->is_visible()) {
vToggleFullscreen();
return true;
}
// Rewind key CTRL+B
if (m_state_count_max > 0u && (_pstEvent->state & GDK_CONTROL_MASK) && _pstEvent->keyval == GDK_KEY_b) {
// disable saves first and then connect new handler
if (m_oEmuRewindSig.connected())
m_oEmuRewindSig.disconnect();
m_state_count_max = 0u;
//return this->bOnEmuRewind();
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuRewind),
65u);
return true;
}
// Forward the keyboard event to the input module by faking a SDL event
SDL_Event event;
event.type = SDL_KEYDOWN;
//event.key.timestamp = SDL_GetTicks();
//event.key.windowID = 0;
//event.key.repeat = 0;
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
inputProcessSDLEvent(event);
return Gtk::Window::on_key_press_event(_pstEvent);
}
bool Window::on_key_release_event(GdkEventKey* _pstEvent)
{
// Rewind key CTRL+B
if (_pstEvent->keyval == GDK_KEY_b /*&& !(_pstEvent->state & GDK_CONTROL_MASK)*/) {
// connect save handler back
if (m_oEmuRewindSig.connected())
m_oEmuRewindSig.disconnect();
m_state_count_max = m_poCoreConfig->oGetKey<unsigned short>("rewind_count_max");
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuSaveStateRewind), m_rewind_interval);
return true;
}
// Forward the keyboard event to the input module by faking a SDL event
SDL_Event event;
event.type = SDL_KEYUP;
//event.key.timestamp = SDL_GetTicks();
//event.key.windowID = 0;
//event.key.repeat = 0;
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
inputProcessSDLEvent(event);
return Gtk::Window::on_key_release_event(_pstEvent);
}
bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
{
if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
}
return true;
}
} // namespace VBA

View File

@ -1,269 +0,0 @@
#include "stdafx.h"
#include "AVIWrite.h"
#pragma comment(lib, "Vfw32")
AVIWrite::AVIWrite()
{
m_failed = false;
m_file = NULL;
m_videoStream = NULL;
m_audioStream = NULL;
ZeroMemory(&m_videoCompSettings, sizeof(m_videoCompSettings));
ZeroMemory(&m_audioCompSettings, sizeof(m_audioCompSettings));
m_videoCompressed = NULL;
m_audioCompressed = NULL;
m_frameRate = 0;
m_frameCounter = 0;
m_sampleCounter = 0;
m_videoFrameSize = 0;
m_audioFrameSize = 0;
m_audioBlockAlign = 0;
AVIFileInit();
}
AVIWrite::~AVIWrite()
{
if (m_audioCompressed) {
AVIStreamRelease(m_audioCompressed);
}
if (m_audioStream) {
AVIStreamRelease(m_audioStream);
}
if (m_videoCompressed) {
AVIStreamRelease(m_videoCompressed);
}
if (m_videoStream) {
AVIStreamRelease(m_videoStream);
}
if (m_file) {
AVIFileRelease(m_file);
}
AVIFileExit();
}
bool AVIWrite::CreateAVIFile(LPCTSTR filename)
{
if (m_file || m_failed)
return false;
HRESULT err = 0;
// -- create the AVI file --
err = AVIFileOpen(
&m_file,
filename,
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
NULL);
if (FAILED(err)) {
m_failed = true;
return false;
}
return true;
}
// colorBits: 16, 24 or 32
bool AVIWrite::CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd)
{
if (m_videoStream || m_failed)
return false;
HRESULT err = 0;
AVISTREAMINFO videoInfo;
BITMAPINFOHEADER bitmapInfo;
AVICOMPRESSOPTIONS* settings[1];
ZeroMemory(&videoInfo, sizeof(videoInfo));
ZeroMemory(&bitmapInfo, sizeof(bitmapInfo));
settings[0] = &m_videoCompSettings;
// -- initialize the video stream information --
videoInfo.fccType = streamtypeVIDEO;
videoInfo.fccHandler = 0;
videoInfo.dwScale = 1;
videoInfo.dwRate = framesPerSecond;
videoInfo.dwSuggestedBufferSize = imageWidth * imageHeight * (colorBits >> 3);
// -- create the video stream --
err = AVIFileCreateStream(
m_file,
&m_videoStream,
&videoInfo);
if (FAILED(err)) {
m_failed = true;
return false;
}
// -- ask for compression settings --
if (AVISaveOptions(
parentWnd,
0,
1,
&m_videoStream,
settings)) {
err = AVIMakeCompressedStream(
&m_videoCompressed,
m_videoStream,
settings[0],
NULL);
AVISaveOptionsFree(1, settings);
if (FAILED(err)) {
m_failed = true;
return false;
}
} else {
AVISaveOptionsFree(1, settings);
m_failed = true;
return false;
}
// -- initialize the video stream format --
bitmapInfo.biSize = sizeof(bitmapInfo);
bitmapInfo.biWidth = imageWidth;
bitmapInfo.biHeight = imageHeight;
bitmapInfo.biBitCount = colorBits;
bitmapInfo.biPlanes = 1;
bitmapInfo.biCompression = BI_RGB;
bitmapInfo.biSizeImage = imageWidth * imageHeight * (colorBits >> 3);
// -- set the video stream format --
err = AVIStreamSetFormat(
m_videoCompressed,
0,
&bitmapInfo,
bitmapInfo.biSize + (bitmapInfo.biClrUsed * sizeof(RGBQUAD)));
if (FAILED(err)) {
m_failed = true;
return false;
}
m_frameRate = framesPerSecond;
m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3);
return true;
}
// call AddVideoStream() first
// channelCount: max. 2
// sampleBits: max. 16
bool AVIWrite::CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd)
{
if (m_audioStream || m_failed)
return false;
HRESULT err = 0;
AVISTREAMINFO audioInfo;
WAVEFORMATEX waveInfo;
ZeroMemory(&audioInfo, sizeof(audioInfo));
ZeroMemory(&waveInfo, sizeof(waveInfo));
// -- initialize the audio stream information --
audioInfo.fccType = streamtypeAUDIO;
audioInfo.dwQuality = (DWORD)-1;
audioInfo.dwScale = channelCount * (sampleBits >> 3);
audioInfo.dwRate = channelCount * (sampleBits >> 3) * sampleRate;
audioInfo.dwInitialFrames = 1;
audioInfo.dwSampleSize = channelCount * (sampleBits >> 3);
audioInfo.dwSuggestedBufferSize = 0;
// -- create the audio stream --
err = AVIFileCreateStream(
m_file,
&m_audioStream,
&audioInfo);
if (FAILED(err)) {
m_failed = true;
return false;
}
// -- initialize the audio stream format --
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
waveInfo.nChannels = channelCount;
waveInfo.nSamplesPerSec = sampleRate;
waveInfo.nAvgBytesPerSec = channelCount * (sampleBits >> 3) * sampleRate;
waveInfo.nBlockAlign = channelCount * (sampleBits >> 3);
waveInfo.wBitsPerSample = sampleBits;
waveInfo.cbSize = 0;
// -- set the audio stream format --
err = AVIStreamSetFormat(
m_audioStream,
0,
&waveInfo,
sizeof(waveInfo));
if (FAILED(err)) {
m_failed = true;
return false;
}
m_audioBlockAlign = channelCount * (sampleBits >> 3);
m_audioFrameSize = channelCount * (sampleBits >> 3) * (sampleRate / m_frameRate);
return true;
}
bool AVIWrite::AddVideoFrame(LPVOID imageData)
{
if (!m_videoStream || m_failed)
return false;
HRESULT err = 0;
err = AVIStreamWrite(
m_videoCompressed,
m_frameCounter,
1,
imageData,
m_videoFrameSize,
AVIIF_KEYFRAME,
NULL,
NULL);
if (FAILED(err)) {
m_failed = true;
return false;
}
m_frameCounter++;
return true;
}
bool AVIWrite::AddAudioFrame(LPVOID soundData)
{
if (!m_audioStream || m_failed)
return false;
HRESULT err = 0;
err = AVIStreamWrite(
m_audioStream,
m_sampleCounter,
m_audioFrameSize / m_audioBlockAlign,
soundData,
m_audioFrameSize,
0,
NULL,
NULL);
if (FAILED(err)) {
m_failed = true;
return false;
}
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
return true;
}

View File

@ -1,32 +0,0 @@
#include <vfw.h>
// info: recreate the whole AVIWrite object if any method fails
class AVIWrite {
public:
AVIWrite();
virtual ~AVIWrite();
bool CreateAVIFile(LPCTSTR filename);
bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits,
DWORD framesPerSecond, HWND parentWnd);
bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits,
HWND parentWnd);
bool AddVideoFrame(LPVOID imageData);
bool AddAudioFrame(LPVOID soundData);
private:
bool m_failed;
PAVIFILE m_file;
PAVISTREAM m_videoStream;
PAVISTREAM m_audioStream;
AVICOMPRESSOPTIONS m_videoCompSettings;
AVICOMPRESSOPTIONS m_audioCompSettings;
PAVISTREAM m_videoCompressed;
PAVISTREAM m_audioCompressed;
DWORD m_frameRate;
LONG m_frameCounter;
LONG m_sampleCounter;
LONG m_videoFrameSize;
LONG m_audioFrameSize;
WORD m_audioBlockAlign;
};

View File

@ -1,52 +0,0 @@
#include "AboutDialog.h"
#include "../AutoBuild.h"
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AboutDialog dialog
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(AboutDialog::IDD, pParent)
{
m_version = _T(VBA_VERSION_STRING);
m_date = _T(__DATE__);
}
void AboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AboutDialog)
DDX_Text(pDX, IDC_VERSION, m_version);
DDX_Control(pDX, IDC_URL, m_link);
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_DATE, m_date);
}
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
//{{AFX_MSG_MAP(AboutDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AboutDialog message handlers
BOOL AboutDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* p = GetDlgItem(IDC_TRANSLATOR_URL);
if (p) {
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
}
m_link.SetWindowText("http://vba-m.com");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,22 +0,0 @@
#pragma once
#include "Hyperlink.h"
#include "resource.h"
#include "stdafx.h"
class AboutDialog : public CDialog {
public:
AboutDialog(CWnd* pParent = NULL);
enum { IDD = IDD_ABOUT };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
private:
Hyperlink m_link;
Hyperlink m_translator;
CString m_version;
CString m_date;
};

View File

@ -1,265 +0,0 @@
#include "AccelEditor.h"
#include "CmdAccelOb.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
: ResizeDlg(AccelEditor::IDD, pParent)
{
//{{AFX_DATA_INIT(AccelEditor)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
mgr = theApp.winAccelMgr;
}
void AccelEditor::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AccelEditor)
DDX_Control(pDX, IDC_CURRENTS, m_currents);
DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
DDX_Control(pDX, IDC_COMMANDS, m_commands);
DDX_Control(pDX, IDC_EDIT_KEY, m_key);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
//{{AFX_MSG_MAP(AccelEditor)
ON_BN_CLICKED(ID_OK, OnOk)
ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands)
ON_BN_CLICKED(IDC_RESET, OnReset)
ON_BN_CLICKED(IDC_ASSIGN, OnAssign)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AccelEditor message handlers
BOOL AccelEditor::OnInitDialog()
{
CDialog::OnInitDialog();
DIALOG_SIZER_START(sz)
DIALOG_SIZER_ENTRY(IDC_STATIC1, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_STATIC2, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_STATIC3, DS_MoveX | DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_ALREADY_AFFECTED, DS_MoveY)
DIALOG_SIZER_ENTRY(ID_OK, DS_MoveX)
DIALOG_SIZER_ENTRY(ID_CANCEL, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_ASSIGN, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_REMOVE, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_RESET, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_COMMANDS, DS_SizeX | DS_SizeY)
DIALOG_SIZER_ENTRY(IDC_CURRENTS, DS_MoveX | DS_SizeY)
DIALOG_SIZER_ENTRY(IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
DIALOG_SIZER_END()
SetData(sz,
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
NULL);
InitCommands();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AccelEditor::InitCommands()
{
m_commands.ResetContent();
m_alreadyAffected.SetWindowText("");
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
while (pos != NULL) {
CString command;
WORD wID;
mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
int index = m_commands.AddString(command);
m_commands.SetItemData(index, wID);
}
// Update the currents accels associated with the selected command
if (m_commands.SetCurSel(0) != LB_ERR)
OnSelchangeCommands();
}
void AccelEditor::OnCancel()
{
EndDialog(FALSE);
}
void AccelEditor::OnOk()
{
EndDialog(TRUE);
}
void AccelEditor::OnSelchangeCommands()
{
// Check if some commands exist.
int index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
WORD wIDCommand = LOWORD(m_commands.GetItemData(index));
m_currents.ResetContent();
CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
CAccelsOb* pAccel;
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
// Add the keys to the 'currents keys' listbox.
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
// and a pointer to the accel object.
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
}
}
// Init the key editor
// m_pKey->ResetKey();
}
void AccelEditor::OnReset()
{
mgr.Default();
InitCommands(); // update the listboxes.
}
void AccelEditor::OnAssign()
{
// Control if it's not already affected
CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel;
WORD wIDCommand;
POSITION pos;
WORD wKey;
bool bCtrl, bAlt, bShift;
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
return; // no valid key, abort
int count = m_commands.GetCount();
int index;
for (index = 0; index < count; index++) {
wIDCommand = LOWORD(m_commands.GetItemData(index));
mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) {
// the key is already affected (in the same or other command)
m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
m_key.SetSel(0, -1);
return; // abort
}
}
}
// OK, we can add the accel key in the currently selected group
index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
// Get the object who manage the accels list, associated to the command.
wIDCommand = LOWORD(m_commands.GetItemData(index));
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
return;
BYTE cVirt = 0;
if (bCtrl)
cVirt |= FCONTROL;
if (bAlt)
cVirt |= FALT;
if (bShift)
cVirt |= FSHIFT;
cVirt |= FVIRTKEY;
// Create the new key...
pAccel = new CAccelsOb(cVirt, wKey, false);
ASSERT(pAccel != NULL);
// ...and add in the list.
pCmdAccel->m_Accels.AddTail(pAccel);
// Update the listbox.
CString szBuffer;
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
// Reset the key editor.
m_key.ResetKey();
}
void AccelEditor::OnRemove()
{
// Some controls
int indexCurrent = m_currents.GetCurSel();
if (indexCurrent == LB_ERR)
return;
// 2nd part.
int indexCmd = m_commands.GetCurSel();
if (indexCmd == LB_ERR)
return;
// Ref to the ID command
WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd));
// Run through the accels,and control if it can be deleted.
CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
CAccelsOb* pAccel;
CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent));
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
POSITION PrevPos;
while (pos != NULL) {
PrevPos = pos;
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel == pAccelCurrent) {
if (!pAccel->m_bLocked) {
// not locked, so we delete the key
pCmdAccel->m_Accels.RemoveAt(PrevPos);
delete pAccel;
// and update the listboxes/key editor/static text
m_currents.DeleteString(indexCurrent);
m_key.ResetKey();
m_alreadyAffected.SetWindowText("");
return;
} else {
systemMessage(0, "Unable to remove this\naccelerator (Locked)");
return;
}
}
}
systemMessage(0, "internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
return;
}
systemMessage(0, "internal error (CAccelDlgHelper::Remove : Lookup failed)");
}

View File

@ -1,57 +0,0 @@
#if !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_)
#define AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AccelEditor.h : header file
//
#include "AcceleratorManager.h"
#include "KeyboardEdit.h"
#include "ResizeDlg.h"
/////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog
class AccelEditor : public ResizeDlg {
// Construction
public:
CAcceleratorManager mgr;
void InitCommands();
AccelEditor(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(AccelEditor)
enum { IDD = IDD_ACCEL_EDITOR };
CListBox m_currents;
CStatic m_alreadyAffected;
CListBox m_commands;
CKeyboardEdit m_key;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(AccelEditor)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(AccelEditor)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnSelchangeCommands();
afx_msg void OnReset();
afx_msg void OnAssign();
afx_msg void OnRemove();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_)

View File

@ -1,759 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Thierry Maurel
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// tmaurel@caramail.com (or tmaurel@hol.fr)
//
////////////////////////////////////////////////////////////////////////////////
// File : AcceleratorManager.cpp
// Project : AccelsEditor
////////////////////////////////////////////////////////////////////////////////
// Version : 1.0 * Author : T.Maurel
// Date : 17.08.98
//
// Remarks : implementation of the CAcceleratorManager class.
//
////////////////////////////////////////////////////////////////////////////////
#include "VBA.h"
#include "stdafx.h"
#include "AcceleratorManager.h"
#include "Reg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//////////////////////////////////////////////////////////////////////
//
//
CAcceleratorManager::CAcceleratorManager()
{
m_hRegKey = HKEY_CURRENT_USER;
m_szRegKey = "";
m_bAutoSave = FALSE;
m_pWndConnected = NULL;
m_bDefaultTable = false;
}
//////////////////////////////////////////////////////////////////////
//
//
CAcceleratorManager::~CAcceleratorManager()
{
if ((m_bAutoSave == true) && (m_szRegKey.IsEmpty() != FALSE)) {
// bool bRet = Write();
// if (!bRet)
// systemMessage(0, "CAcceleratorManager::~CAcceleratorManager\nError in CAcceleratorManager::Write...");
}
Reset();
}
//////////////////////////////////////////////////////////////////////
// Internal fcts
//////////////////////////////////////////////////////////////////////
//
//
void CAcceleratorManager::Reset()
{
CCmdAccelOb* pCmdAccel;
WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
delete pCmdAccel;
}
m_mapAccelTable.RemoveAll();
m_mapAccelString.RemoveAll();
pos = m_mapAccelTableSaved.GetStartPosition();
while (pos != NULL) {
m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
delete pCmdAccel;
}
m_mapAccelTableSaved.RemoveAll();
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
{
ASSERT(szCommand != NULL);
WORD wIDCmd;
if (m_mapAccelString.Lookup(szCommand, wIDCmd) == TRUE) {
if (wIDCmd != wIDCommand)
return false;
}
CCmdAccelOb* pCmdAccel = NULL;
if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
if (pCmdAccel->m_szCommand != szCommand) {
return false;
}
CAccelsOb* pAccel;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey)
return FALSE;
}
// Adding the accelerator
pCmdAccel->Add(cVirt, wKey, bLocked);
} else {
pCmdAccel = new CCmdAccelOb(cVirt, wIDCommand, wKey, szCommand, bLocked);
ASSERT(pCmdAccel != NULL);
m_mapAccelTable.SetAt(wIDCommand, pCmdAccel);
}
// 2nd table
m_mapAccelString.SetAt(szCommand, wIDCommand);
return true;
}
//////////////////////////////////////////////////////////////////////
// Debug fcts
//////////////////////////////////////////////////////////////////////
//
//
#ifdef _DEBUG
void CAcceleratorManager::AssertValid() const
{
}
//////////////////////////////////////////////////////////////////////
//
//
void CAcceleratorManager::Dump(CDumpContext& dc) const
{
CCmdAccelOb* pCmdAccel;
WORD wKey;
dc << "CAcceleratorManager::Dump :\n";
dc << "m_mapAccelTable :\n";
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
dc << "a CCmdAccelOb at 0x" << (void*)pCmdAccel << " = {\n";
dc << pCmdAccel;
dc << "}\n";
}
dc << "\nm_mapAccelTableSaved\n";
pos = m_mapAccelTableSaved.GetStartPosition();
while (pos != NULL) {
m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
dc << "a CCmdAccelOb at 0x" << (void*)pCmdAccel << " = {\n";
dc << pCmdAccel;
dc << "}\n";
}
}
#endif
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
//
//
void CAcceleratorManager::Connect(CWnd* pWnd, bool bAutoSave)
{
ASSERT(m_pWndConnected == NULL);
m_pWndConnected = pWnd;
m_bAutoSave = bAutoSave;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::GetRegKey(HKEY& hRegKey, CString& szRegKey)
{
if (m_szRegKey.IsEmpty())
return false;
hRegKey = m_hRegKey;
szRegKey = m_szRegKey;
return true;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::SetRegKey(HKEY hRegKey, LPCTSTR szRegKey)
{
ASSERT(hRegKey != NULL);
ASSERT(szRegKey != NULL);
m_szRegKey = szRegKey;
m_hRegKey = hRegKey;
return true;
}
//////////////////////////////////////////////////////////////////////
// Update the application's ACCELs table
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::UpdateWndTable()
{
int iLoop = 0;
CTypedPtrArray<CPtrArray, LPACCEL> arrayACCEL;
CCmdAccelOb* pCmdAccel;
WORD wKey;
LPACCEL pACCEL;
CAccelsOb* pAccelOb;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccelOb = pCmdAccel->m_Accels.GetNext(pos);
pACCEL = new ACCEL;
ASSERT(pACCEL != NULL);
pACCEL->fVirt = pAccelOb->m_cVirt;
pACCEL->key = pAccelOb->m_wKey;
pACCEL->cmd = pCmdAccel->m_wIDCommand;
arrayACCEL.Add(pACCEL);
}
}
INT_PTR nAccel = arrayACCEL.GetSize();
LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
if (!lpAccel) {
for (iLoop = 0; iLoop < nAccel; iLoop++)
delete arrayACCEL.GetAt(iLoop);
arrayACCEL.RemoveAll();
return false;
}
for (iLoop = 0; iLoop < nAccel; iLoop++) {
pACCEL = arrayACCEL.GetAt(iLoop);
lpAccel[iLoop].fVirt = pACCEL->fVirt;
lpAccel[iLoop].key = pACCEL->key;
lpAccel[iLoop].cmd = pACCEL->cmd;
delete pACCEL;
}
arrayACCEL.RemoveAll();
HACCEL hNewTable = CreateAcceleratorTable(lpAccel, (int)nAccel);
if (!hNewTable) {
::LocalFree(lpAccel);
return false;
}
HACCEL hOldTable = theApp.hAccel;
if (!::DestroyAcceleratorTable(hOldTable)) {
::LocalFree(lpAccel);
return false;
}
theApp.hAccel = hNewTable;
::LocalFree(lpAccel);
UpdateMenu(GetMenu(*AfxGetApp()->m_pMainWnd));
return true;
}
//////////////////////////////////////////////////////////////////////
// Create/Destroy accelerators
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wKey)
{
CCmdAccelOb* pCmdAccel = NULL;
if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
POSITION PrevPos;
CAccelsOb* pAccel = NULL;
while (pos != NULL) {
PrevPos = pos;
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->m_bLocked == true)
return false;
if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey) {
pCmdAccel->m_Accels.RemoveAt(PrevPos);
delete pAccel;
return true;
}
}
}
return false;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::DeleteEntry(WORD wIDCommand)
{
CCmdAccelOb* pCmdAccel = NULL;
VERIFY(m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE);
CAccelsOb* pAccel;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->m_bLocked == true)
return false;
}
m_mapAccelString.RemoveKey(pCmdAccel->m_szCommand);
m_mapAccelTable.RemoveKey(wIDCommand);
delete pCmdAccel;
return true;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand)
{
ASSERT(szCommand != NULL);
WORD wIDCommand;
if (m_mapAccelString.Lookup(szCommand, wIDCommand) == TRUE) {
return DeleteEntry(wIDCommand);
}
return true;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::SetAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
{
ASSERT(szCommand != NULL);
return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked);
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked)
{
ASSERT(szCommand != NULL);
ASSERT(m_pWndConnected != NULL);
HACCEL hOriginalTable = theApp.hAccel;
int nAccel = ::CopyAcceleratorTable(hOriginalTable, NULL, 0);
LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, (nAccel) * sizeof(ACCEL));
if (!lpAccel)
return false;
::CopyAcceleratorTable(hOriginalTable, lpAccel, nAccel);
bool bRet = false;
for (int i = 0; i < nAccel; i++) {
if (lpAccel[i].cmd == wIDCommand)
bRet = AddAccel(lpAccel[i].fVirt, wIDCommand, lpAccel[i].key, szCommand, bLocked);
}
::LocalFree(lpAccel);
return bRet;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
{
ASSERT(szCommand != NULL);
WORD wIDDummy;
if (m_mapAccelString.Lookup(szCommand, wIDDummy) == TRUE)
return false;
CCmdAccelOb* pCmdAccel = new CCmdAccelOb(wIDCommand, szCommand);
ASSERT(pCmdAccel != NULL);
m_mapAccelTable.SetAt(wIDCommand, pCmdAccel);
m_mapAccelString.SetAt(szCommand, wIDCommand);
return false;
}
//////////////////////////////////////////////////////////////////////
// Get a string from the ACCEL definition
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel)
{
ASSERT(pACCEL != NULL);
CAccelsOb accel(pACCEL);
accel.GetString(szAccel);
if (szAccel.IsEmpty())
return false;
else
return true;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel)
{
CAccelsOb accel(cVirt, nCode);
accel.GetString(szAccel);
if (szAccel.IsEmpty())
return false;
else
return true;
}
//////////////////////////////////////////////////////////////////////
// Copy function
//
CAcceleratorManager& CAcceleratorManager::operator=(const CAcceleratorManager& accelmgr)
{
Reset();
CCmdAccelOb* pCmdAccel;
CCmdAccelOb* pNewCmdAccel;
WORD wKey;
// Copy the 2 tables : normal accel table...
POSITION pos = accelmgr.m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
accelmgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
pNewCmdAccel = new CCmdAccelOb;
ASSERT(pNewCmdAccel != NULL);
*pNewCmdAccel = *pCmdAccel;
m_mapAccelTable.SetAt(wKey, pNewCmdAccel);
}
// ... and saved accel table.
pos = accelmgr.m_mapAccelTableSaved.GetStartPosition();
while (pos != NULL) {
accelmgr.m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel);
pNewCmdAccel = new CCmdAccelOb;
ASSERT(pNewCmdAccel != NULL);
*pNewCmdAccel = *pCmdAccel;
m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
}
// The Strings-ID table
CString szKey;
pos = accelmgr.m_mapAccelString.GetStartPosition();
while (pos != NULL) {
accelmgr.m_mapAccelString.GetNextAssoc(pos, szKey, wKey);
m_mapAccelString.SetAt(szKey, wKey);
}
m_bDefaultTable = accelmgr.m_bDefaultTable;
return *this;
}
void CAcceleratorManager::UpdateMenu(HMENU menu)
{
int count = GetMenuItemCount(menu);
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info);
GetVersionEx(&info);
if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
MENUITEMINFO info;
char ss[128];
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info) - sizeof(HBITMAP);
info.fMask = MIIM_ID | MIIM_SUBMENU;
for (int i = 0; i < count; i++) {
GetMenuItemInfo(menu, i, TRUE, &info);
if (info.hSubMenu != NULL) {
UpdateMenu(info.hSubMenu);
} else {
if (info.wID != (UINT)-1) {
MENUITEMINFO info2;
ZeroMemory(&info2, sizeof(info2));
info2.cbSize = sizeof(info2) - sizeof(HBITMAP);
info2.fMask = MIIM_STRING;
info2.dwTypeData = ss;
info2.cch = 128;
GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2);
CString str = ss;
int index = str.Find('\t');
if (index != -1)
str = str.Left(index);
WORD command = info.wID;
CCmdAccelOb* o;
if (m_mapAccelTable.Lookup(command, o)) {
if (o->m_Accels.GetCount()) {
POSITION pos = o->m_Accels.GetHeadPosition();
CAccelsOb* accel = o->m_Accels.GetNext(pos);
CString s;
accel->GetString(s);
str += "\t";
str += s;
}
}
if (str != ss)
ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
}
}
}
} else {
MENUITEMINFO info;
wchar_t ss[128];
wchar_t str[512];
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = MIIM_ID | MIIM_SUBMENU;
for (int i = 0; i < count; i++) {
GetMenuItemInfo(menu, i, TRUE, &info);
if (info.hSubMenu != NULL) {
UpdateMenu(info.hSubMenu);
} else {
if (info.wID != (WORD)-1) {
MENUITEMINFOW info2;
ZeroMemory(&info2, sizeof(info2));
info2.cbSize = sizeof(info2);
info2.fMask = MIIM_STRING;
info2.dwTypeData = ss;
info2.cch = 128;
GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2);
wcscpy(str, ss);
wchar_t* p = wcschr(str, '\t');
if (p)
*p = 0;
CCmdAccelOb* o;
WORD command = info.wID;
if (m_mapAccelTable.Lookup(command, o)) {
if (o->m_Accels.GetCount()) {
POSITION pos = o->m_Accels.GetHeadPosition();
CAccelsOb* accel = o->m_Accels.GetNext(pos);
CString s;
accel->GetString(s);
wchar_t temp[128];
temp[0] = '\t';
temp[1] = 0;
wcscat(str, temp);
p = temp;
for (const char* sp = s; *sp; sp++)
*p++ = *sp;
*p = 0;
wcscat(str, temp);
}
}
if (wcscmp(str, ss))
ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
}
}
}
}
}
//////////////////////////////////////////////////////////////////////
// In/Out to the registry
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
{
ASSERT(szRegKey != NULL);
m_hRegKey = hRegKey;
m_szRegKey = szRegKey;
DWORD data[2048 / sizeof(DWORD)];
DWORD len = sizeof(data);
if (regQueryBinaryValue("keyboard", (char*)data, len)) {
int count = len / sizeof(DWORD);
CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel;
DWORD dwIDAccelData, dwAccelData;
BOOL bExistID;
int iIndex = 0;
if (count) {
WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
pCmdAccel->DeleteUserAccels();
}
while (iIndex < count) {
dwIDAccelData = data[iIndex++];
WORD wIDCommand = LOWORD(dwIDAccelData);
bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
if (bExistID) {
pCmdAccel->DeleteUserAccels();
}
for (int j = 0; j < HIWORD(dwIDAccelData) && iIndex < count; j++) {
dwAccelData = data[iIndex++];
if (bExistID) {
pAccel = new CAccelsOb;
ASSERT(pAccel != NULL);
pAccel->SetData(dwAccelData);
pCmdAccel->Add(pAccel);
}
}
}
}
UpdateWndTable();
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::Load()
{
BOOL bRet = FALSE;
if (!m_szRegKey.IsEmpty())
bRet = Load(m_hRegKey, m_szRegKey);
if (bRet == TRUE)
return true;
else
return false;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::Write()
{
CDWordArray AccelsDatasArray;
CDWordArray CmdDatasArray;
int iCount = 0;
CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel;
DWORD dwAccelData;
WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
CmdDatasArray.RemoveAll();
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
// if (!pAccel->m_bLocked) {
dwAccelData = pAccel->GetData();
CmdDatasArray.Add(dwAccelData);
// }
}
if (CmdDatasArray.GetSize() > 0) {
CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));
AccelsDatasArray.Append(CmdDatasArray);
iCount++;
}
}
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
INT_PTR count = AccelsDatasArray.GetSize();
DWORD* data = (DWORD*)malloc(count * sizeof(DWORD));
ASSERT(data != NULL);
for (int index = 0; index < count; index++)
data[index] = AccelsDatasArray[index];
regSetBinaryValue("keyboard", (char*)data, (int)(count * sizeof(DWORD)));
AccelsDatasArray.RemoveAll();
CmdDatasArray.RemoveAll();
free(data);
return true;
}
//////////////////////////////////////////////////////////////////////
// Defaults values management.
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::CreateDefaultTable()
{
if (m_bDefaultTable)
return false;
CCmdAccelOb* pCmdAccel;
CCmdAccelOb* pNewCmdAccel;
CAccelsOb* pAccel;
CAccelsOb* pNewAccel;
WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) {
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
pNewCmdAccel = new CCmdAccelOb;
ASSERT(pNewCmdAccel != NULL);
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (!pAccel->m_bLocked) {
pNewAccel = new CAccelsOb;
ASSERT(pNewAccel != NULL);
*pNewAccel = *pAccel;
pNewCmdAccel->m_Accels.AddTail(pNewAccel);
}
}
if (pNewCmdAccel->m_Accels.GetCount() != 0) {
pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand;
pNewCmdAccel->m_szCommand = pCmdAccel->m_szCommand;
m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
} else
delete pNewCmdAccel;
}
m_bDefaultTable = true;
return true;
}
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::Default()
{
return true;
}

View File

@ -1,147 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Thierry Maurel
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// tmaurel@caramail.com (or tmaurel@hol.fr)
//
////////////////////////////////////////////////////////////////////////////////
// File : AcceleratorManager.h
// Project : AccelsEditor
////////////////////////////////////////////////////////////////////////////////
// Version : 1.0 * Author : T.Maurel
// Date : 17.08.98
//
// Remarks : interface for the CAcceleratorManager class.
//
////////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
#define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "CmdAccelOb.h"
// Helper map
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
#endif
#ifndef CMapWordToCCmdAccelOb
typedef CMap<WORD, WORD&, CCmdAccelOb*, CCmdAccelOb*&> CMapWordToCCmdAccelOb;
#endif
//////////////////////////////////////////////////////////////////////
//
//
class CAcceleratorManager : public CObject {
friend class AccelEditor;
public:
CAcceleratorManager();
virtual ~CAcceleratorManager();
// Operations
public:
void UpdateMenu(HMENU menu);
void UpdateMenu();
// Connection to the main application wnd
void Connect(CWnd* pWnd, bool bAutoSave = true);
// In/Out with the registry
bool Load(HKEY hRegKey, LPCTSTR szRegKey);
bool Load();
bool Write();
// Get the initials accels, not the user's
bool Default();
// Save a copy in the 2 maps called xxxSaved, which are used in case
// of Default(), to reload the defaults accels.
bool CreateDefaultTable();
bool IsDefaultTableAvailable()
{
return m_bDefaultTable;
}
bool IsMapStringCommandsEmpty()
{
if (m_mapAccelString.IsEmpty())
return true;
else
return false;
}
// Registry access configuration
bool GetRegKey(HKEY& hRegKey, CString& szRegKey);
bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey);
bool IsAutoSave()
{
return m_bAutoSave;
}
void SetAutoSave(bool bAutoSave)
{
m_bAutoSave = bAutoSave;
}
// Helper fct, used for new menus strings
bool GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel);
bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
// Update the ACCELS table in the application, from the specified
// datas in the manager.
bool UpdateWndTable();
// Modification helper fcts
bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand,
bool bLocked = false);
bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
bool DeleteEntry(LPCTSTR szCommand);
bool DeleteEntry(WORD wIDCommand);
bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
// Affectation operator
CAcceleratorManager& operator=(const CAcceleratorManager& accelmgr);
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Erase all the datas
void Reset();
// Internal affect fct.
bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked);
// Attributes
protected:
CWnd* m_pWndConnected;
// User datas
CMapStringToWord m_mapAccelString;
CMapWordToCCmdAccelOb m_mapAccelTable;
// Default datas
CMapWordToCCmdAccelOb m_mapAccelTableSaved;
bool m_bDefaultTable;
// Where the users datas will be saved in the registry
HKEY m_hRegKey;
CString m_szRegKey;
// if true, there is an auto-save in the registry, when the destructor is called
bool m_bAutoSave;
};
#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)

View File

@ -1,109 +0,0 @@
#include "Associate.h"
#include "Reg.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Associate dialog
Associate::Associate(CWnd* pParent /*=NULL*/)
: CDialog(Associate::IDD, pParent)
{
//{{AFX_DATA_INIT(Associate)
m_agb = FALSE;
m_bin = FALSE;
m_cgb = FALSE;
m_dmg = FALSE;
m_gb = FALSE;
m_gba = FALSE;
m_gbc = FALSE;
m_sgb = FALSE;
//}}AFX_DATA_INIT
}
void Associate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Associate)
DDX_Check(pDX, IDC_AGB, m_agb);
DDX_Check(pDX, IDC_BIN, m_bin);
DDX_Check(pDX, IDC_CGB, m_cgb);
DDX_Check(pDX, IDC_DMG, m_dmg);
DDX_Check(pDX, IDC_GB, m_gb);
DDX_Check(pDX, IDC_GBA, m_gba);
DDX_Check(pDX, IDC_GBC, m_gbc);
DDX_Check(pDX, IDC_SGB, m_sgb);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Associate, CDialog)
//{{AFX_MSG_MAP(Associate)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Associate message handlers
BOOL Associate::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Associate::OnCancel()
{
EndDialog(FALSE);
}
void Associate::OnOk()
{
UpdateData();
int mask = 0;
if (m_gb)
mask |= 1;
if (m_dmg)
mask |= 2;
if (m_sgb)
mask |= 4;
if (m_cgb)
mask |= 8;
if (m_gbc)
mask |= 16;
if (m_gba)
mask |= 32;
if (m_agb)
mask |= 64;
if (m_bin)
mask |= 128;
if (mask) {
char applicationPath[2048];
CString commandPath;
LPCTSTR types[] = { "*.dmg", ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
GetModuleFileName(NULL, applicationPath, 2048);
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
regAssociateType("VisualBoyAdvance.Binary",
"Binary",
commandPath,
"%SystemRoot%\\system32\\SHELL32.dll,-13");
for (int i = 0; i < 8; i++) {
if (mask & (1 << i)) {
regCreateFileType(types[i], "VisualBoyAdvance.Binary");
}
}
}
EndDialog(TRUE);
}

View File

@ -1,52 +0,0 @@
#if !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_)
#define AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Associate.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// Associate dialog
class Associate : public CDialog {
// Construction
public:
Associate(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Associate)
enum { IDD = IDD_ASSOCIATIONS };
BOOL m_agb;
BOOL m_bin;
BOOL m_cgb;
BOOL m_dmg;
BOOL m_gb;
BOOL m_gba;
BOOL m_gbc;
BOOL m_sgb;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Associate)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Associate)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_)

View File

@ -1,188 +0,0 @@
#include "VBA.h"
#include "stdafx.h"
#include "AudioCoreSettingsDlg.h"
#define MIN_VOLUME 0.0f
#define MAX_VOLUME 4.0f
// AudioCoreSettingsDlg dialog
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
, m_enabled(false)
, m_surround(false)
, m_declicking(false)
, m_sound_interpolation(false)
, m_echo(0.0f)
, m_stereo(0.0f)
, m_volume(0.0f)
, m_sound_filtering(0.0f)
, m_sample_rate(0)
, toolTip(NULL)
{
}
AudioCoreSettingsDlg::~AudioCoreSettingsDlg()
{
delete toolTip;
}
void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
DDX_Control(pDX, IDC_SURROUND, surround);
DDX_Control(pDX, IDC_ECHO, echo);
DDX_Control(pDX, IDC_STEREO, stereo);
DDX_Control(pDX, IDC_VOLUME, volume);
DDX_Control(pDX, IDC_DECLICKING, declicking);
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
if (pDX->m_bSaveAndValidate == TRUE) {
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
m_surround = BST_CHECKED == surround.GetCheck();
m_declicking = BST_CHECKED == declicking.GetCheck();
m_sound_interpolation = BST_CHECKED == sound_interpolation.GetCheck();
m_echo = (float)echo.GetPos() / 100.0f;
m_stereo = (float)stereo.GetPos() / 100.0f;
m_volume = (float)volume.GetPos() / 100.0f;
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
m_sample_rate = (unsigned int)sample_rate.GetItemData(sample_rate.GetCurSel());
}
}
BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
TOOLTIPTEXT* t3 = (TOOLTIPTEXT*)pNMHDR; // dirty Windows API
BOOL i_provided_tooltip_with_text = TRUE;
if (!(t3->uFlags & TTF_IDISHWND)) {
return FALSE;
}
// even dirtier Windows API:
// t3->hdr.idFrom is actually a HWND, holy cow, why?
// The other case does not even occur.
int controlID = ::GetDlgCtrlID((HWND)t3->hdr.idFrom);
CString res;
TCHAR buf[0x400]; // Use own string buffer because szText has an 80 char limit.
// We can't use a dynamic buffer size because Windows does some shady things with
// t3->lpszText at the end of this function, so we have no chance to free the buffer
// before the end of this function.
switch (controlID) {
case IDC_VOLUME:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), volume.GetPos());
break;
case IDC_ECHO:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), echo.GetPos());
break;
case IDC_STEREO:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), stereo.GetPos());
break;
case IDC_SOUND_FILTERING:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), sound_filtering.GetPos());
break;
case IDC_DEFAULT_VOLUME:
res.LoadString(IDS_TOOLTIP_DEFAULT_VOLUME);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_ENHANCE_SOUND:
res.LoadString(IDS_TOOLTIP_ENHANCE_SOUND);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_SURROUND:
res.LoadString(IDS_TOOLTIP_SURROUND);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_DECLICKING:
res.LoadString(IDS_TOOLTIP_DECLICKING);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
default:
i_provided_tooltip_with_text = FALSE;
break;
}
return i_provided_tooltip_with_text;
}
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
END_MESSAGE_MAP()
// AudioCoreSettingsDlg message handlers
BOOL AudioCoreSettingsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set up tooltip control
toolTip = new CToolTipCtrl;
toolTip->Create(this);
toolTip->AddTool(GetDlgItem(IDC_DEFAULT_VOLUME));
toolTip->AddTool(GetDlgItem(IDC_ENHANCE_SOUND));
toolTip->AddTool(GetDlgItem(IDC_SURROUND));
toolTip->AddTool(GetDlgItem(IDC_DECLICKING));
toolTip->Activate(TRUE);
enhance_sound.SetCheck(m_enabled ? BST_CHECKED : BST_UNCHECKED);
surround.SetCheck(m_surround ? BST_CHECKED : BST_UNCHECKED);
declicking.SetCheck(m_declicking ? BST_CHECKED : BST_UNCHECKED);
sound_interpolation.SetCheck(m_sound_interpolation ? BST_CHECKED : BST_UNCHECKED);
echo.SetRange(0, 100);
echo.SetPos((int)(m_echo * 100.0f));
stereo.SetRange(0, 100);
stereo.SetPos((int)(m_stereo * 100.0f));
sound_filtering.SetRange(0, 100);
sound_filtering.SetPos((int)(m_sound_filtering * 100.0f));
volume.SetRange((int)(MIN_VOLUME * 100.0f), (int)(MAX_VOLUME * 100.0f));
volume.SetPos((int)(m_volume * 100.0f));
unsigned int rate = 44100;
CString temp;
for (int i = 0; i <= 2; i++) {
temp.Format(_T("%u Hz"), rate);
int id = sample_rate.AddString(temp.GetString());
sample_rate.SetItemData(id, rate);
if (rate == m_sample_rate) {
sample_rate.SetCurSel(id);
}
rate /= 2;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
{
// Required for enabling ToolTips in a modal dialog box.
if (NULL != toolTip) {
toolTip->RelayEvent(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
}
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
{
volume.SetPos(100);
}

View File

@ -1,47 +0,0 @@
#pragma once
// AudioCoreSettingsDlg dialog
class AudioCoreSettingsDlg : public CDialog {
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
public:
bool m_enabled;
bool m_surround;
bool m_declicking;
bool m_sound_interpolation;
float m_echo;
float m_stereo;
float m_volume;
float m_sound_filtering;
unsigned int m_sample_rate;
AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AudioCoreSettingsDlg();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedDefaultVolume();
// Dialog Data
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult); // Retrieve text for
// ToolTip
DECLARE_MESSAGE_MAP()
private:
CButton enhance_sound;
CButton surround;
CButton declicking;
CButton sound_interpolation;
CSliderCtrl echo;
CSliderCtrl stereo;
CSliderCtrl volume;
CSliderCtrl sound_filtering;
CToolTipCtrl* toolTip;
CComboBox sample_rate;
};

View File

@ -1,135 +0,0 @@
#include "VBA.h"
#include "stdafx.h"
#include "BIOSDialog.h"
// BIOSDialog dialog
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
: CDialog(BIOSDialog::IDD, pParent)
, m_enableBIOS_GB(FALSE)
, m_enableBIOS_GBA(FALSE)
, m_skipLogo(FALSE)
, m_pathGB(_T(""))
, m_pathGBA(_T(""))
{
}
BIOSDialog::~BIOSDialog()
{
}
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
DDX_Check(pDX, IDC_ENABLE_GBC_BIOS, m_enableBIOS_GBC);
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
DDX_Text(pDX, IDC_GBC_BIOS_PATH, m_pathGBC);
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
DDX_Control(pDX, IDC_GBC_BIOS_PATH, m_editGBC);
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
if (pDX->m_bSaveAndValidate == TRUE) {
// disable BIOS usage when it does not exist
if (!fileExists(m_pathGBA)) {
m_enableBIOS_GBA = FALSE;
}
if (!fileExists(m_pathGBC)) {
m_enableBIOS_GBC = FALSE;
}
if (!fileExists(m_pathGB)) {
m_enableBIOS_GB = FALSE;
}
}
}
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
ON_BN_CLICKED(IDC_SELECT_GBC_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbcBiosPath)
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
END_MESSAGE_MAP()
// BIOSDialog message handlers
void BIOSDialog::OnBnClickedSelectGbBiosPath()
{
CString current;
m_editGB.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if (IDOK == dlg.DoModal()) {
m_editGB.SetWindowText(dlg.GetPathName());
}
}
void BIOSDialog::OnBnClickedSelectGbcBiosPath()
{
CString current;
m_editGBC.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if (IDOK == dlg.DoModal()) {
m_editGBC.SetWindowText(dlg.GetPathName());
}
}
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
{
CString current;
m_editGBA.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if (IDOK == dlg.DoModal()) {
m_editGBA.SetWindowText(dlg.GetPathName());
}
}
bool BIOSDialog::fileExists(CString& file)
{
CFileStatus stat;
BOOL retVal = CFile::GetStatus(file, stat);
bool noFile = false;
if (retVal == TRUE) {
noFile |= (stat.m_attribute & CFile::directory) != 0;
}
return (retVal == TRUE) && !noFile;
}

View File

@ -1,36 +0,0 @@
#pragma once
// BIOSDialog dialog
class BIOSDialog : public CDialog {
DECLARE_DYNAMIC(BIOSDialog)
public:
BIOSDialog(CWnd* pParent = NULL); // standard constructor
virtual ~BIOSDialog();
// Dialog Data
enum { IDD = IDD_BIOS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
private:
CEdit m_editGB;
CEdit m_editGBC;
CEdit m_editGBA;
bool fileExists(CString& file);
afx_msg void OnBnClickedSelectGbBiosPath();
afx_msg void OnBnClickedSelectGbcBiosPath();
afx_msg void OnBnClickedSelectGbaBiosPath();
public:
BOOL m_enableBIOS_GB;
BOOL m_enableBIOS_GBC;
BOOL m_enableBIOS_GBA;
BOOL m_skipLogo;
CString m_pathGB;
CString m_pathGBC;
CString m_pathGBA;
};

View File

@ -1,274 +0,0 @@
#include "BitmapControl.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
bool BitmapControl::isRegistered = false;
/////////////////////////////////////////////////////////////////////////////
// BitmapControl
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
BitmapControl::BitmapControl()
{
w = 0;
h = 0;
data = NULL;
bmpInfo = NULL;
stretch = false;
registerClass();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 0;
SetScrollSizes(MM_TEXT, sizeTotal);
}
BitmapControl::~BitmapControl()
{
}
BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
//{{AFX_MSG_MAP(BitmapControl)
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// BitmapControl drawing
void BitmapControl::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void BitmapControl::OnDraw(CDC* dc)
{
RECT r;
GetClientRect(&r);
int w1 = r.right - r.left;
int h1 = r.bottom - r.top;
CDC memDC;
memDC.CreateCompatibleDC(dc);
if (!stretch) {
if (w > w1)
w1 = w;
if (h > h1)
h1 = h;
}
CBitmap bitmap, *pOldBitmap;
bitmap.CreateCompatibleBitmap(dc, w1, h1);
pOldBitmap = memDC.SelectObject(&bitmap);
if (stretch) {
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
StretchDIBits(memDC.GetSafeHdc(),
0,
0,
w1,
h1,
0,
0,
w,
h,
data,
bmpInfo,
DIB_RGB_COLORS,
SRCCOPY);
} else {
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
SetDIBitsToDevice(memDC.GetSafeHdc(),
0,
0,
w,
h,
0,
0,
0,
h,
data,
bmpInfo,
DIB_RGB_COLORS);
}
dc->BitBlt(0, 0, w1, h1,
&memDC, 0, 0, SRCCOPY);
if (boxreigon.right != 0 && boxreigon.bottom != 0) {
CBrush br = CBrush(RGB(255, 0, 0));
dc->FrameRect(&boxreigon, &br);
}
memDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
memDC.DeleteDC();
}
/////////////////////////////////////////////////////////////////////////////
// BitmapControl diagnostics
#ifdef _DEBUG
void BitmapControl::AssertValid() const
{
CScrollView::AssertValid();
}
void BitmapControl::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// BitmapControl message handlers
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
void BitmapControl::OnSize(UINT nType, int cx, int cy)
{
if (!stretch)
CScrollView::OnSize(nType, cx, cy);
}
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
{
GetParent()->SendMessage(WM_BITMAPCLICK,
GetDlgCtrlID(),
0);
if (!data)
return;
int x = pt.x;
int y = pt.y;
WPARAM point;
if (stretch) {
RECT rect;
GetClientRect(&rect);
int height = rect.bottom - rect.top;
int width = rect.right - rect.left;
int xx = (x * w) / width;
int yy = (y * h) / height;
point = xx | (yy << 16);
int xxx = xx / 8;
int yyy = yy / 8;
for (int i = 0; i < 8; i++) {
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
}
} else {
POINT p;
p.x = GetScrollPos(SB_HORZ);
p.y = GetScrollPos(SB_VERT);
p.x += x;
p.y += y;
if (p.x >= w || p.y >= h)
return;
point = p.x | (p.y << 16);
int xxx = p.x / 8;
int yyy = p.y / 8;
for (int i = 0; i < 8; i++) {
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
}
}
GetParent()->SendMessage(WM_MAPINFO,
point,
(LPARAM)colors);
}
void BitmapControl::setBmpInfo(BITMAPINFO* info)
{
bmpInfo = info;
}
void BitmapControl::setData(uint8_t* d)
{
data = d;
}
void BitmapControl::setSize(int w1, int h1)
{
if (w != w1 || h != h1) {
w = w1;
h = h1;
SIZE s;
s.cx = w;
s.cy = h;
SetScrollSizes(MM_TEXT, s);
}
}
void BitmapControl::setSelectedRectangle(int x, int y, int width, int height)
{
boxreigon.left = x;
boxreigon.right = x + width;
boxreigon.top = y;
boxreigon.bottom = y + height;
}
void BitmapControl::refresh()
{
Invalidate();
}
void BitmapControl::registerClass()
{
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaBitmapControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
}
void BitmapControl::setStretch(bool b)
{
if (b != stretch) {
stretch = b;
Invalidate();
}
}
bool BitmapControl::getStretch()
{
return stretch;
}
void BitmapControl::PostNcDestroy()
{
}

View File

@ -1,80 +0,0 @@
#if !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_)
#define AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BitmapControl.h : header file
//
#ifndef WM_MAPINFO
#define WM_MAPINFO WM_APP + 101
#endif
#ifndef WM_BITMAPCLICK
#define WM_BITMAPCLICK WM_APP + 102
#endif
/////////////////////////////////////////////////////////////////////////////
// BitmapControl view
class BitmapControl : public CScrollView {
public:
BitmapControl(); // protected constructor used by dynamic creation
protected:
DECLARE_DYNCREATE(BitmapControl)
// Attributes
public:
// Operations
public:
void setStretch(bool b);
void refresh();
void setSize(int w1, int h1);
void setSelectedRectangle(int x, int y, int width, int height);
void setData(uint8_t* d);
void setBmpInfo(BITMAPINFO* info);
static bool isRegistered;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BitmapControl)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual void OnInitialUpdate(); // first time after construct
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
public:
bool getStretch();
virtual ~BitmapControl();
protected:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(BitmapControl)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
bool stretch;
uint8_t colors[3 * 64];
BITMAPINFO* bmpInfo;
uint8_t* data;
int h;
int w;
RECT boxreigon;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_)

View File

@ -1,241 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// BugReport.cpp : implementation file
//
#include "BugReport.h"
#include "stdafx.h"
#include "vba.h"
#include "../AutoBuild.h"
#include "../Globals.h"
#include "../Port.h"
#include "../RTC.h"
#include "../Sound.h"
#include "../agb/GBA.h"
#include "../agb/agbprint.h"
#include "../dmg/gbCheats.h"
#include "../dmg/gbGlobals.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// BugReport dialog
BugReport::BugReport(CWnd* pParent /*=NULL*/)
: CDialog(BugReport::IDD, pParent)
{
//{{AFX_DATA_INIT(BugReport)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void BugReport::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(BugReport)
DDX_Control(pDX, IDC_BUG_REPORT, m_report);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(BugReport, CDialog)
//{{AFX_MSG_MAP(BugReport)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// BugReport message handlers
void BugReport::OnCopy()
{
OpenClipboard();
EmptyClipboard();
CString report;
m_report.GetWindowText(report);
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
(report.GetLength() + 1) * sizeof(CHAR));
if (hglbCopy == NULL) {
CloseClipboard();
return;
}
// Lock the handle and copy the text to the buffer.
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, (const char*)report,
report.GetLength() * sizeof(CHAR));
lptstrCopy[report.GetLength()] = (TCHAR)0; // null character
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard();
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
}
void BugReport::OnOk()
{
EndDialog(TRUE);
}
BOOL BugReport::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
CString report = createReport();
m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
m_report.SetWindowText(report);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
static void AppendFormat(CString& report, const char* format, ...)
{
CString buffer;
va_list valist;
va_start(valist, format);
buffer.FormatV(format, valist);
va_end(valist);
report += buffer;
}
CString BugReport::createReport()
{
theApp.winCheckFullscreen();
CString report = "";
AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
AppendFormat(report, "Emu Type : %s\r\n",
#ifdef DEBUG
"Debug Version"
#else
"Release Version"
#endif
);
if (emulating) {
AppendFormat(report, "File : %s\r\n", theApp.szFile);
char buffer[20];
if (theApp.cartridgeType == 0) {
uint32_t check = 0;
for (int i = 0; i < 0x4000; i += 4) {
check += *((uint32_t*)&bios[i]);
}
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
strncpy(buffer, (const char*)&rom[0xa0], 12);
buffer[12] = 0;
AppendFormat(report, "Internal name: %s\r\n", buffer);
strncpy(buffer, (const char*)&rom[0xac], 4);
buffer[4] = 0;
AppendFormat(report, "Game code : %s\r\n", buffer);
CString res = "";
uint32_t* p = (uint32_t*)rom;
uint32_t* end = (uint32_t*)((char*)rom + theApp.romSize);
while (p < end) {
uint32_t d = READ32LE(p);
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (d == 0x4D415253) {
if (memcmp(p, "SRAM_", 5) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (d == 0x53414C46) {
if (memcmp(p, "FLASH1M_", 8) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (memcmp(p, "FLASH", 5) == 0) {
res += (const char*)p;
res += ' ';
} else if (d == 0x52494953) {
if (memcmp(p, "SIIRTC_V", 8) == 0) {
res += (const char*)p;
res += ' ';
}
}
p++;
}
if (res.GetLength() > 0)
AppendFormat(report, "Cart Save : %s\r\n", res);
} else if (theApp.cartridgeType == 1) {
strncpy(buffer, (const char*)&gbRom[0x134], 15);
buffer[15] = 0;
AppendFormat(report, "Game title : %s\r\n", buffer);
}
}
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
AppendFormat(report, "Save type : %d (%d)\r\n",
theApp.winSaveType, cpuSaveType);
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
theApp.winFlashSize, flashSize);
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
rtcIsEnabled());
AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle);
AppendFormat(report, "Synchronize : %d\r\n", synchronize);
AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f);
AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
return report;
}

View File

@ -1,66 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#if !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_)
#define AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BugReport.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// BugReport dialog
class BugReport : public CDialog {
// Construction
public:
BugReport(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(BugReport)
enum { IDD = IDD_BUG_REPORT };
CEdit m_report;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BugReport)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CString createReport();
// Generated message map functions
//{{AFX_MSG(BugReport)
afx_msg void OnCopy();
afx_msg void OnOk();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_)

View File

@ -1,503 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Thierry Maurel
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// tmaurel@caramail.com (or tmaurel@hol.fr)
//
////////////////////////////////////////////////////////////////////////////////
// File : CmdAccelOb.cpp
// Project : AccelsEditor
////////////////////////////////////////////////////////////////////////////////
// Version : 1.0 * Author : T.Maurel
// Date : 17.08.98
//
// Remarks :
//
////////////////////////////////////////////////////////////////////////////////
#include "CmdAccelOb.h"
#include "stdafx.h"
////////////////////////////////////////////////////////////////////////
//
//
MAPVIRTKEYS mapVirtKeys[] = {
{ VK_LBUTTON, "VK_LBUTTON" },
{ VK_RBUTTON, "VK_RBUTTON" },
{ VK_CANCEL, "VK_CANCEL" },
{ VK_MBUTTON, "VK_MBUTTON" },
{ VK_BACK, "BACK" },
{ VK_TAB, "TAB" },
{ VK_CLEAR, "VK_CLEAR" },
{ VK_RETURN, "RETURN" },
{ VK_SHIFT, "SHIFT" },
{ VK_CONTROL, "CONTROL" },
{ VK_MENU, "MENU" },
{ VK_PAUSE, "PAUSE" },
{ VK_CAPITAL, "CAPITAL" },
{ VK_ESCAPE, "ESCAPE" },
{ VK_SPACE, "SPACE" },
{ VK_PRIOR, "PRIOR" },
{ VK_NEXT, "NEXT" },
{ VK_END, "END" },
{ VK_HOME, "HOME" },
{ VK_LEFT, "LEFT" },
{ VK_UP, "UP" },
{ VK_RIGHT, "RIGHT" },
{ VK_DOWN, "DOWN" },
{ VK_SELECT, "VK_SELECT" },
{ VK_PRINT, "PRINT" },
{ VK_EXECUTE, "EXECUTE" },
{ VK_SNAPSHOT, "SNAPSHOT" },
{ VK_INSERT, "INSERT" },
{ VK_DELETE, "DELETE" },
{ VK_HELP, "VK_HELP" },
{ WORD('0'), "0" },
{ WORD('1'), "1" },
{ WORD('2'), "2" },
{ WORD('3'), "3" },
{ WORD('4'), "4" },
{ WORD('5'), "5" },
{ WORD('6'), "6" },
{ WORD('7'), "7" },
{ WORD('8'), "8" },
{ WORD('9'), "9" },
{ WORD('A'), "A" },
{ WORD('B'), "B" },
{ WORD('C'), "C" },
{ WORD('D'), "D" },
{ WORD('E'), "E" },
{ WORD('F'), "F" },
{ WORD('G'), "G" },
{ WORD('H'), "H" },
{ WORD('I'), "I" },
{ WORD('J'), "J" },
{ WORD('K'), "K" },
{ WORD('L'), "L" },
{ WORD('M'), "M" },
{ WORD('N'), "N" },
{ WORD('O'), "O" },
{ WORD('P'), "P" },
{ WORD('Q'), "Q" },
{ WORD('R'), "R" },
{ WORD('S'), "S" },
{ WORD('T'), "T" },
{ WORD('U'), "U" },
{ WORD('V'), "V" },
{ WORD('W'), "W" },
{ WORD('X'), "X" },
{ WORD('Y'), "Y" },
{ WORD('Z'), "Z" },
{ VK_LWIN, "VK_LWIN" },
{ VK_RWIN, "VK_RWIN" },
{ VK_APPS, "VK_APPS" },
{ VK_NUMPAD0, "NUMPAD0" },
{ VK_NUMPAD1, "NUMPAD1" },
{ VK_NUMPAD2, "NUMPAD2" },
{ VK_NUMPAD3, "NUMPAD3" },
{ VK_NUMPAD4, "NUMPAD4" },
{ VK_NUMPAD5, "NUMPAD5" },
{ VK_NUMPAD6, "NUMPAD6" },
{ VK_NUMPAD7, "NUMPAD7" },
{ VK_NUMPAD8, "NUMPAD8" },
{ VK_NUMPAD9, "NUMPAD9" },
{ VK_MULTIPLY, "MULTIPLY" },
{ VK_ADD, "ADD" },
{ VK_SEPARATOR, "SEPARATOR" },
{ VK_SUBTRACT, "SUBTRACT" },
{ VK_DECIMAL, "DECIMAL" },
{ VK_DIVIDE, "DIVIDE" },
{ VK_F1, "F1" },
{ VK_F2, "F2" },
{ VK_F3, "F3" },
{ VK_F4, "F4" },
{ VK_F5, "F5" },
{ VK_F6, "F6" },
{ VK_F7, "F7" },
{ VK_F8, "F8" },
{ VK_F9, "F9" },
{ VK_F10, "F10" },
{ VK_F11, "F11" },
{ VK_F12, "F12" },
{ VK_F13, "F13" },
{ VK_F14, "F14" },
{ VK_F15, "F15" },
{ VK_F16, "F16" },
{ VK_F17, "F17" },
{ VK_F18, "F18" },
{ VK_F19, "F19" },
{ VK_F20, "F20" },
{ VK_F21, "F21" },
{ VK_F22, "F22" },
{ VK_F23, "F23" },
{ VK_F24, "F24" },
{ VK_NUMLOCK, "NUMLOCK" },
{ VK_SCROLL, "VK_SCROLL" },
{ VK_ATTN, "VK_ATTN" },
{ VK_CRSEL, "VK_CRSEL" },
{ VK_EXSEL, "VK_EXSEL" },
{ VK_EREOF, "VK_EREOF" },
{ VK_PLAY, "VK_PLAY" },
{ VK_ZOOM, "VK_ZOOM" },
{ VK_NONAME, "VK_NONAME" },
{ VK_PA1, "VK_PA1" },
{ VK_OEM_CLEAR, "VK_OEM_CLEAR" },
};
////////////////////////////////////////////////////////////////////////
//
//
MAPVIRTKEYS mapVirtSysKeys[] = {
{ FCONTROL, "Ctrl" },
{ FALT, "Alt" },
{ FSHIFT, "Shift" },
};
////////////////////////////////////////////////////////////////////////
// helper fct for external access
////////////////////////////////////////////////////////////////////////
//
//
TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
{
for (int index = 0; index < sizeof(mapVirtKeys) / sizeof(mapVirtKeys[0]); index++) {
if (mapVirtKeys[index].wKey == wKey)
return mapVirtKeys[index].szKey;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////
//
#define DEFAULT_ACCEL 0x01
#define USER_ACCEL 0x02
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb()
{
m_cVirt = 0;
m_wKey = 0;
m_bLocked = false;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
{
ASSERT(pFrom != NULL);
m_cVirt = pFrom->m_cVirt;
m_wKey = pFrom->m_wKey;
m_bLocked = pFrom->m_bLocked;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
{
m_cVirt = cVirt;
m_wKey = wKey;
m_bLocked = bLocked;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(LPACCEL pACCEL)
{
ASSERT(pACCEL != NULL);
m_cVirt = pACCEL->fVirt;
m_wKey = pACCEL->key;
m_bLocked = false;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
{
m_cVirt = from.m_cVirt;
m_wKey = from.m_wKey;
m_bLocked = from.m_bLocked;
return *this;
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
//
//
void CAccelsOb::GetString(CString& szBuffer)
{
szBuffer = "";
// in case of the object is not assigned, we avoid error messages
if (m_wKey == 0)
return;
// modifiers part
int i;
for (i = 0; i < sizetable(mapVirtSysKeys); i++) {
if (m_cVirt & mapVirtSysKeys[i].wKey) {
szBuffer += mapVirtSysKeys[i].szKey;
szBuffer += "+";
}
}
// and virtual key part
for (i = 0; i < sizetable(mapVirtKeys); i++) {
if (m_wKey == mapVirtKeys[i].wKey) {
szBuffer += mapVirtKeys[i].szKey;
return;
}
}
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
}
////////////////////////////////////////////////////////////////////////
//
//
bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
{
// CString szTemp;
// GetString(szTemp);
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
bool bRet = (bCtrl == m_bCtrl);
bool m_bAlt = (m_cVirt & FALT) ? true : false;
bRet &= (bAlt == m_bAlt);
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
bRet &= (bShift == m_bShift);
bRet &= static_cast<bool>(m_wKey == wKey);
return bRet;
}
////////////////////////////////////////////////////////////////////////
//
//
DWORD CAccelsOb::GetData()
{
BYTE cLocalCodes = 0;
if (m_bLocked)
cLocalCodes = DEFAULT_ACCEL;
else
cLocalCodes = USER_ACCEL;
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
return MAKELONG(m_wKey, bCodes);
}
////////////////////////////////////////////////////////////////////////
//
//
bool CAccelsOb::SetData(DWORD dwDatas)
{
m_wKey = LOWORD(dwDatas);
WORD bCodes = HIWORD(dwDatas);
m_cVirt = LOBYTE(bCodes);
BYTE cLocalCodes = HIBYTE(bCodes);
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
return true;
}
////////////////////////////////////////////////////////////////////////
//
#ifdef _DEBUG
////////////////////////////////////////////////////////////////////////
//
//
void CAccelsOb::AssertValid() const
{
CObject::AssertValid();
}
////////////////////////////////////////////////////////////////////////
//
//
void CAccelsOb::Dump(CDumpContext& dc) const
{
dc << "\t\t";
CObject::Dump(dc);
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
}
#endif
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::CCmdAccelOb()
{
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
{
ASSERT(szCommand != NULL);
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
{
ASSERT(szCommand != NULL);
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::~CCmdAccelOb()
{
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL)
delete m_Accels.GetNext(pos);
m_Accels.RemoveAll();
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
{
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Add(CAccelsOb* pAccel)
{
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
{
Reset();
m_wIDCommand = from.m_wIDCommand;
m_szCommand = from.m_szCommand;
CAccelsOb* pAccel;
POSITION pos = from.m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos));
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
return *this;
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::DeleteUserAccels()
{
CAccelsOb* pAccel;
POSITION prevPos;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
prevPos = pos;
pAccel = m_Accels.GetNext(pos);
if (!pAccel->m_bLocked) {
delete pAccel;
m_Accels.RemoveAt(prevPos);
}
}
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Reset()
{
m_wIDCommand = 0;
m_szCommand = "Empty command";
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
delete pAccel;
}
}
////////////////////////////////////////////////////////////////////////
//
#ifdef _DEBUG
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::AssertValid() const
{
// call base class function first
CObject::AssertValid();
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Dump(CDumpContext& dc) const
{
// call base class function first
dc << "\t";
CObject::Dump(dc);
// now do the stuff for our specific class
dc << "\tIDCommand = " << m_wIDCommand;
dc << "\n\tszCommand = " << m_szCommand;
dc << "\n\tAccelerators = {\n";
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
dc << pAccel;
}
dc << "\t}\n";
}
#endif

View File

@ -1,109 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by Thierry Maurel
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// tmaurel@caramail.com (or tmaurel@hol.fr)
//
////////////////////////////////////////////////////////////////////////////////
// File : CmdAccelOb.h
// Project : AccelsEditor
////////////////////////////////////////////////////////////////////////////////
// Version : 1.0 * Author : T.Maurel
// Date : 17.08.98
//
// Remarks :
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __CMDACCEL_OB_INCLUDE
#define __CMDACCEL_OB_INCLUDE
#include <afxtempl.h> // MFC Templates extension
////////////////////////////////////////////////////////////////////////
//
//
typedef struct tagMAPVIRTKEYS {
WORD wKey;
TCHAR szKey[15];
} MAPVIRTKEYS, *PMAPVIRTKEYS;
////////////////////////////////////////////////////////////////////////
//
//
#define sizetable(table) (sizeof(table) / sizeof(table[0]))
////////////////////////////////////////////////////////////////////////
//
//
class CAccelsOb : public CObject {
public:
CAccelsOb();
CAccelsOb(CAccelsOb* pFrom);
CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
CAccelsOb(LPACCEL pACCEL);
public:
CAccelsOb& operator=(const CAccelsOb& from);
void GetString(CString& szBuffer);
bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
DWORD GetData();
bool SetData(DWORD dwDatas);
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
public:
BYTE m_cVirt;
WORD m_wKey;
bool m_bLocked;
};
//////////////////////////////////////////////////////////////////////
//
//
class CCmdAccelOb : public CObject {
public:
CCmdAccelOb();
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand,
bool bLocked = false);
~CCmdAccelOb();
public:
void Add(CAccelsOb* pAccel);
void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
void Reset();
void DeleteUserAccels();
CCmdAccelOb& operator=(const CCmdAccelOb& from);
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
public:
WORD m_wIDCommand;
CString m_szCommand;
CList<CAccelsOb*, CAccelsOb*&> m_Accels;
};
////////////////////////////////////////////////////////////////////////
#endif // __CMDACCEL_OB_INCLUDE

View File

@ -1,97 +0,0 @@
#include "ColorButton.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
bool ColorButton::isRegistered = false;
/////////////////////////////////////////////////////////////////////////////
// ColorButton
ColorButton::ColorButton()
{
color = 0;
registerClass();
}
ColorButton::~ColorButton()
{
}
BEGIN_MESSAGE_MAP(ColorButton, CButton)
//{{AFX_MSG_MAP(ColorButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ColorButton message handlers
void ColorButton::PreSubclassWindow()
{
SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
CWnd::PreSubclassWindow();
}
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(lpDrawItemStruct);
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
HDC dc = lpDrawItemStruct->hDC;
UINT state = lpDrawItemStruct->itemState;
RECT rect = lpDrawItemStruct->rcItem;
SIZE margins;
margins.cx = ::GetSystemMetrics(SM_CXEDGE);
margins.cy = ::GetSystemMetrics(SM_CYEDGE);
if (GetState() & BST_PUSHED)
DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
else
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
InflateRect(&rect, -margins.cx, -margins.cy);
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? ::GetSysColor(COLOR_3DFACE) : RGB(r, g, b));
FillRect(dc, &rect, br);
if (state & ODS_FOCUS) {
InflateRect(&rect, -1, -1);
DrawFocusRect(dc, &rect);
}
DeleteObject(br);
}
void ColorButton::setColor(uint16_t c)
{
color = c;
Invalidate();
}
void ColorButton::registerClass()
{
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorButton";
AfxRegisterClass(&wc);
isRegistered = true;
}
}

View File

@ -1,55 +0,0 @@
#if !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_)
#define AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ColorButton.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// ColorButton window
class ColorButton : public CButton {
// Construction
public:
ColorButton();
// Attributes
public:
// Operations
static bool isRegistered;
public:
void PreSubclassWindow();
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorButton)
//}}AFX_VIRTUAL
// Implementation
public:
void setColor(uint16_t c);
uint16_t color;
virtual ~ColorButton();
void registerClass();
// Generated message map functions
protected:
//{{AFX_MSG(ColorButton)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_)

View File

@ -1,80 +0,0 @@
#include "ColorControl.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
bool ColorControl::isRegistered = false;
/////////////////////////////////////////////////////////////////////////////
// ColorControl
ColorControl::ColorControl()
{
color = 0;
registerClass();
}
ColorControl::~ColorControl()
{
}
BEGIN_MESSAGE_MAP(ColorControl, CWnd)
//{{AFX_MSG_MAP(ColorControl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ColorControl message handlers
void ColorControl::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
{
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
CBrush br;
br.CreateSolidBrush(RGB(r, g, b));
RECT rect;
GetClientRect(&rect);
pDC->FillRect(&rect, &br);
pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
br.DeleteObject();
return TRUE;
}
void ColorControl::setColor(uint16_t c)
{
color = c;
Invalidate();
}
void ColorControl::registerClass()
{
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
}

View File

@ -1,53 +0,0 @@
#if !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_)
#define AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ColorControl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// ColorControl window
class ColorControl : public CWnd {
// Construction
public:
ColorControl();
// Attributes
public:
// Operations
static bool isRegistered;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorControl)
//}}AFX_VIRTUAL
// Implementation
public:
void setColor(uint16_t c);
uint16_t color;
virtual ~ColorControl();
// Generated message map functions
protected:
//{{AFX_MSG(ColorControl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_)

View File

@ -1,231 +0,0 @@
#include "AcceleratorManager.h"
#include "resource.h"
#include "stdafx.h"
#include <afxres.h>
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
#endif
static CMapStringToWord winAccelStrings;
static bool initialized = false;
struct {
const char* command;
WORD id;
} winAccelCommands[] = {
{ "FileOpenGBA", ID_FILE_OPEN_GBA },
{ "FileOpenGBC", ID_FILE_OPEN_GBC },
{ "FileOpenGB", ID_FILE_OPEN_GB },
{ "FileLoadDotCode", ID_FILE_LOAD_DOTCODE },
{ "FileSaveDotCode", ID_FILE_SAVE_DOTCODE },
{ "FileLoad", ID_FILE_LOAD },
{ "FileSave", ID_FILE_SAVE },
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
{ "FileRecentReset", ID_FILE_RECENT_RESET },
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
{ "FileRecent01", ID_FILE_MRU_FILE1 },
{ "FileRecent02", ID_FILE_MRU_FILE2 },
{ "FileRecent03", ID_FILE_MRU_FILE3 },
{ "FileRecent04", ID_FILE_MRU_FILE4 },
{ "FileRecent05", ID_FILE_MRU_FILE5 },
{ "FileRecent06", ID_FILE_MRU_FILE6 },
{ "FileRecent07", ID_FILE_MRU_FILE7 },
{ "FileRecent08", ID_FILE_MRU_FILE8 },
{ "FileRecent09", ID_FILE_MRU_FILE9 },
{ "FileRecent10", ID_FILE_MRU_FILE10 },
{ "FilePause", ID_FILE_PAUSE },
{ "FileReset", ID_FILE_RESET },
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
{ "FileImportGamesharkActionReplaySnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
{ "FileToggleFullscreen", ID_FILE_TOGGLEMENU },
{ "FileClose", ID_FILE_CLOSE },
{ "FileExit", ID_FILE_EXIT },
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
{ "OptionsVideoX5", ID_OPTIONS_VIDEO_X5 },
{ "OptionsVideoX6", ID_OPTIONS_VIDEO_X6 },
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
{ "OptionsVideoLayersBG0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
{ "OptionsVideoLayersBG1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
{ "OptionsVideoLayersBG2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
{ "OptionsVideoLayersBG3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
{ "OptionsVideoLayersReset", ID_OPTIONS_VIDEO_LAYERS_RESET },
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
{ "OptionsFilterxBRZ2x", ID_OPTIONS_FILTER_XBRZ2X },
{ "OptionsFilterxBRZ3x", ID_OPTIONS_FILTER_XBRZ3X },
{ "OptionsFilterxBRZ4x", ID_OPTIONS_FILTER_XBRZ4X },
{ "OptionsFilterxBRZ5x", ID_OPTIONS_FILTER_XBRZ5X },
{ "OptionsFilterxBRZ6x", ID_OPTIONS_FILTER_XBRZ6X },
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
{ "CheatsList", ID_CHEATS_CHEATLIST },
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
{ "ToolsDebugGDBConfigurePort", ID_TOOLS_DEBUG_CONFIGUREPORT },
{ "ToolsDebugGDBBreakOnLoad", ID_TOOLS_DEBUG_BREAKONLOAD },
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
{ "ToolsLogging", ID_TOOLS_LOGGING },
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
{ "ToolsRewind", ID_TOOLS_REWIND },
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
{ "HelpBugReport", ID_HELP_BUGREPORT },
{ "HelpFAQ", ID_HELP_FAQ },
{ "HelpAbout", ID_HELP_ABOUT },
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
};
bool winAccelGetID(const char* command, WORD& id)
{
if (!initialized) {
int count = sizeof(winAccelCommands) / sizeof(winAccelCommands[0]);
for (int i = 0; i < count; i++) {
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
}
initialized = true;
}
return winAccelStrings.Lookup(command, id) ? true : false;
}
void winAccelAddCommands(CAcceleratorManager& mgr)
{
int count = sizeof(winAccelCommands) / sizeof(winAccelCommands[0]);
for (int i = 0; i < count; i++) {
if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
}
}

View File

@ -1,928 +0,0 @@
#ifndef NO_D3D
#pragma comment(lib, "d3d9")
#pragma comment(lib, "d3dx9")
#pragma comment(lib, "DxErr")
#include "stdafx.h"
#include "Display.h"
#include "FullscreenSettings.h"
#include "MainWnd.h"
#include "../System.h"
#include "../Util.h"
#include "../gb/gbGlobals.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include <cassert>
#include <memory.h>
// Direct3D
#ifdef _DEBUG
#define D3D_DEBUG_INFO
#endif
#define DIRECT3D_VERSION 0x0900
#include <D3dx9core.h> // required for font rendering
#include <Dxerr.h> // contains debug functions
#include <d3d9.h> // main include file
extern int Init_2xSaI(uint32_t); // initializes all pixel filters
extern int systemSpeed;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
extern void log(const char*, ...);
#endif
#ifdef MMX
extern "C" bool cpu_mmx;
extern bool detectMMX();
#endif
struct PFTHREAD_DATA {
void (*filterFunction)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
uint8_t* sourcePointer;
uint32_t sourcePitch;
uint8_t* deltaPointer;
uint8_t* destPointer;
uint32_t destPitch;
int width;
int height;
};
DWORD WINAPI pfthread_func(LPVOID lpParameter)
{
PFTHREAD_DATA* data = (PFTHREAD_DATA*)lpParameter;
data->filterFunction(
data->sourcePointer,
data->sourcePitch,
data->deltaPointer,
data->destPointer,
data->destPitch,
data->width,
data->height);
return 0;
}
class Direct3DDisplay : public IDisplay {
private:
bool initialized;
LPDIRECT3D9 pD3D;
LPDIRECT3DDEVICE9 pDevice;
D3DDISPLAYMODE mode;
D3DPRESENT_PARAMETERS dpp;
D3DFORMAT screenFormat;
LPDIRECT3DTEXTURE9 tempImage;
LPDIRECT3DTEXTURE9 emulatedImage[2];
unsigned char mbCurrentTexture; // current texture for motion blur
bool mbTextureEmpty;
unsigned int width, height;
unsigned int textureSize;
RECT destRect;
bool failed;
ID3DXFont* pFont;
bool rectangleFillsScreen;
PFTHREAD_DATA* pfthread_data;
HANDLE* hThreads;
unsigned int nThreads;
struct VERTEX {
FLOAT x, y, z, rhw; // screen coordinates
FLOAT tx, ty; // texture coordinates
} Vertices[4];
// Vertices order:
// 1 3
// 0 2
struct TRANSP_VERTEX {
FLOAT x, y, z, rhw;
D3DCOLOR color;
FLOAT tx, ty;
} transpVertices[4];
void createFont();
void destroyFont();
bool clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight);
void createTexture(unsigned int textureWidth, unsigned int textureHeight);
void destroyTexture();
void calculateDestRect();
bool resetDevice();
void prepareDisplayMode();
public:
Direct3DDisplay();
virtual ~Direct3DDisplay();
virtual DISPLAY_TYPE getType() { return DIRECT_3D; };
virtual bool initialize();
virtual void cleanup();
virtual void clear();
virtual void render();
virtual bool changeRenderSize(int w, int h);
virtual void resize(int w, int h);
virtual void setOption(const char* option, int value);
virtual bool selectFullScreenMode(VIDEO_MODE& mode);
};
Direct3DDisplay::Direct3DDisplay()
{
initialized = false;
pD3D = NULL;
pDevice = NULL;
screenFormat = D3DFMT_X8R8G8B8;
width = 0;
height = 0;
textureSize = 0;
failed = false;
pFont = NULL;
tempImage = NULL;
emulatedImage[0] = NULL;
emulatedImage[1] = NULL;
mbCurrentTexture = 0;
mbTextureEmpty = true;
rectangleFillsScreen = false;
pfthread_data = NULL;
hThreads = NULL;
nThreads = theApp.maxCpuCores;
if (nThreads > 8)
nThreads = 8;
}
Direct3DDisplay::~Direct3DDisplay()
{
cleanup();
}
void Direct3DDisplay::prepareDisplayMode()
{
// Change display mode
memset(&dpp, 0, sizeof(dpp));
dpp.Windowed = !(videoOption >= VIDEO_320x240);
if (!dpp.Windowed) {
dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
} else {
dpp.BackBufferFormat = mode.Format;
}
dpp.BackBufferCount = tripleBuffering ? 2 : 1;
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
dpp.FullScreen_RefreshRateInHz = (dpp.Windowed == TRUE) ? 0 : fsFrequency;
dpp.Flags = 0;
dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
// D3DPRESENT_INTERVAL_ONE means VSync ON
#ifdef _DEBUG
// make debugging full screen easier
if (dpp.Windowed == FALSE) {
dpp.Windowed = TRUE;
dpp.BackBufferFormat = D3DFMT_UNKNOWN;
dpp.BackBufferCount = 0;
dpp.FullScreen_RefreshRateInHz = 0;
dpp.Flags = 0;
}
TRACE(_T("prepareDisplayMode:\n"));
TRACE(_T("%i x %i @ %iHz:\n"), dpp.BackBufferWidth, dpp.BackBufferHeight, dpp.FullScreen_RefreshRateInHz);
TRACE(_T("Buffer Count: %i\n"), dpp.BackBufferCount + 1);
TRACE(_T("VSync: %i\n"), dpp.PresentationInterval == D3DPRESENT_INTERVAL_ONE);
TRACE(_T("LOCKABLE_BACKBUFFER: %i\n\n"), dpp.Flags == D3DPRESENTFLAG_LOCKABLE_BACKBUFFER);
#endif
}
void Direct3DDisplay::cleanup()
{
if (hThreads) {
free(hThreads);
hThreads = NULL;
}
if (pfthread_data) {
free(pfthread_data);
pfthread_data = NULL;
}
destroyFont();
destroyTexture();
if (pDevice) {
pDevice->Release();
pDevice = NULL;
}
if (pD3D) {
pD3D->Release();
pD3D = NULL;
}
}
bool Direct3DDisplay::initialize()
{
#ifdef _DEBUG
TRACE(_T("Initializing Direct3D renderer {\n"));
#endif
// load Direct3D v9
pD3D = Direct3DCreate9(D3D_SDK_VERSION);
if (pD3D == NULL) {
DXTRACE_ERR_MSGBOX(_T("Error creating Direct3D object"), 0);
return false;
}
pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
screenFormat = mode.Format;
switch (mode.Format) {
case D3DFMT_X8R8G8B8:
systemColorDepth = 32;
systemRedShift = 19;
systemGreenShift = 11;
systemBlueShift = 3;
Init_2xSaI(32);
break;
case D3DFMT_R5G6B5:
systemColorDepth = 16;
systemRedShift = 11;
systemGreenShift = 6;
systemBlueShift = 0;
Init_2xSaI(565);
break;
case D3DFMT_X1R5G5B5:
systemColorDepth = 16;
systemRedShift = 10;
systemGreenShift = 5;
systemBlueShift = 0;
Init_2xSaI(555);
break;
default:
DXTRACE_ERR_MSGBOX(_T("Unsupport D3D format"), 0);
return false;
}
fsColorDepth = systemColorDepth;
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
#ifdef MMX
if (!disableMMX) {
cpu_mmx = theApp.detectMMX();
} else {
cpu_mmx = 0;
}
#endif
theApp.updateFilter();
theApp.updateIFB();
// create device
// Direct3D will use the selected full screen adapter for windowed mode as well
prepareDisplayMode();
HRESULT hret = pD3D->CreateDevice(
fsAdapter,
D3DDEVTYPE_HAL,
theApp.m_pMainWnd->GetSafeHwnd(),
D3DCREATE_FPU_PRESERVE | D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&dpp,
&pDevice);
if (FAILED(hret)) {
DXTRACE_ERR_MSGBOX(_T("Error creating Direct3D device"), hret);
return false;
}
createFont();
// width and height will be set from a prior call to changeRenderSize() before initialize()
createTexture(width, height);
calculateDestRect();
setOption(_T("d3dFilter"), theApp.d3dFilter);
setOption(_T("motionBlur"), theApp.d3dMotionBlur);
// create pfthread_data
pfthread_data = (PFTHREAD_DATA*)malloc(sizeof(PFTHREAD_DATA) * nThreads);
if (!pfthread_data) {
failed = true;
}
// create thread handles
hThreads = (HANDLE*)malloc(sizeof(HANDLE) * nThreads);
if (!hThreads) {
failed = true;
}
if (failed)
return false;
initialized = true;
#ifdef _DEBUG
TRACE(_T("} Finished Direct3D renderer initialization\n\n"));
#endif
return TRUE;
}
void Direct3DDisplay::clear()
{
if (pDevice) {
#ifdef _DEBUG
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0xFF, 0x00, 0xFF), 0.0f, 0);
#else
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0x00, 0x00, 0x00), 0.0f, 0);
#endif
}
}
void Direct3DDisplay::render()
{
if (failed)
return;
if (!pDevice)
return;
// Multi-Tasking fix
HRESULT hr = pDevice->TestCooperativeLevel();
if (FAILED(hr)) {
switch (hr) {
case D3DERR_DEVICELOST:
// The device has been lost but cannot be reset at this time.
// Therefore, rendering is not possible.
return;
case D3DERR_DEVICENOTRESET:
// The device has been lost but can be reset at this time.
resetDevice();
return;
default:
DXTRACE_ERR(_T("ERROR: D3D device has serious problems"), hr);
return;
}
}
if (!rectangleFillsScreen) {
// performance: clear only when you must
clear();
}
pDevice->BeginScene();
// copy pix to tempImage and apply pixel filter if selected
D3DLOCKED_RECT lr;
const RECT target = { 0, 0, width, height };
if (FAILED(hr = tempImage->LockRect(0, &lr, &target, 0))) {
DXTRACE_ERR_MSGBOX(_T("Can not lock texture"), hr);
return;
} else {
uint32_t pitch = sizeX * (systemColorDepth >> 3) + 4;
if (theApp.filterFunction) {
if (filterMT) {
uint8_t* start = pix + pitch;
int src_height_per_thread = sizeY / nThreads;
int src_height_remaining = sizeY - ((sizeY / nThreads) * nThreads);
uint32_t src_bytes_per_thread = pitch * src_height_per_thread;
int dst_height_per_thread = src_height_per_thread * filterMagnification;
uint32_t dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
unsigned int i = nThreads - 1;
// Use Multi Threading
do {
// create last thread first because it could have more work than the others (for eg. if nThreads = 3)
// (last thread has to process the remaining lines if (height / nThreads) is not an integer)
// configure thread
pfthread_data[i].filterFunction = theApp.filterFunction;
pfthread_data[i].sourcePointer = start + (i * src_bytes_per_thread);
pfthread_data[i].sourcePitch = pitch;
pfthread_data[i].deltaPointer = (uint8_t*)theApp.delta; // TODO: check if thread-safe
pfthread_data[i].destPointer = ((uint8_t*)lr.pBits) + (i * dst_bytes_per_thread);
pfthread_data[i].destPitch = lr.Pitch;
pfthread_data[i].width = sizeX;
if (i == (nThreads - 1)) {
// last thread
pfthread_data[i].height = src_height_per_thread + src_height_remaining;
} else {
// other thread
pfthread_data[i].height = src_height_per_thread;
}
// create thread
hThreads[i] = CreateThread(
NULL,
0,
pfthread_func,
&pfthread_data[i],
0,
NULL);
assert(hThreads[i] != NULL);
} while (i--);
// Wait until every thread has finished.
WaitForMultipleObjects(
nThreads,
hThreads,
TRUE,
INFINITE);
// Close all thread handles.
for (i = 0; i < nThreads; i++) {
CloseHandle(hThreads[i]);
}
} else {
// multi-threading disabled
theApp.filterFunction(
pix + pitch,
pitch,
(uint8_t*)theApp.delta,
(uint8_t*)lr.pBits,
lr.Pitch,
sizeX,
sizeY);
}
} else {
// pixel filter disabled
switch (systemColorDepth) {
case 32:
cpyImg32(
(unsigned char*)lr.pBits,
lr.Pitch,
pix + pitch,
pitch,
sizeX,
sizeY);
break;
case 16:
cpyImg16(
(unsigned char*)lr.pBits,
lr.Pitch,
pix + pitch,
pitch,
sizeX,
sizeY);
break;
}
}
tempImage->UnlockRect(0);
pDevice->UpdateTexture(tempImage, emulatedImage[mbCurrentTexture]);
}
if (!theApp.d3dMotionBlur) {
// draw the current frame to the screen
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
} else {
// Motion Blur enabled
if (!mbTextureEmpty) {
// draw previous frame to the screen
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture ^ 1]);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
// draw the current frame with transparency to the screen
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, transpVertices, sizeof(TRANSP_VERTEX));
} else {
mbTextureEmpty = false;
// draw the current frame to the screen
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
}
mbCurrentTexture ^= 1; // switch current texture
}
// render speed and status messages
D3DCOLOR color;
RECT r;
r.left = 0;
r.top = 0;
r.right = dpp.BackBufferWidth - 1;
r.bottom = dpp.BackBufferHeight - 1;
if (showSpeed && (videoOption > VIDEO_6X)) {
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
char buffer[30];
if (showSpeed == 1) {
sprintf(buffer, "%3d%%", systemSpeed);
} else {
sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames);
}
pFont->DrawText(NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color);
}
if (screenMessage) {
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
if (((GetTickCount() - theApp.screenMessageTime) < 3000) && !disableStatusMessages && pFont) {
pFont->DrawText(NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color);
} else {
screenMessage = false;
}
}
pDevice->EndScene();
pDevice->Present(NULL, NULL, NULL, NULL);
return;
}
bool Direct3DDisplay::changeRenderSize(int w, int h)
{
if ((w != width) || (h != height)) {
width = (unsigned int)w;
height = (unsigned int)h;
if (pDevice) {
destroyTexture();
createTexture(width, height);
calculateDestRect();
}
}
return true;
}
void Direct3DDisplay::resize(int w, int h)
{
if (!initialized) {
return;
}
if ((w != dpp.BackBufferWidth) || (h != dpp.BackBufferHeight) || (videoOption > VIDEO_6X)) {
resetDevice();
calculateDestRect();
}
}
bool Direct3DDisplay::selectFullScreenMode(VIDEO_MODE& mode)
{
FullscreenSettings dlg;
dlg.setAPI(this->getType());
INT_PTR ret = dlg.DoModal();
if (ret == IDOK) {
mode.adapter = dlg.m_device;
switch (dlg.m_colorDepth) {
case 30:
// TODO: support
return false;
break;
case 24:
mode.bitDepth = 32;
break;
case 16:
case 15:
mode.bitDepth = 16;
break;
}
mode.width = dlg.m_width;
mode.height = dlg.m_height;
mode.frequency = dlg.m_refreshRate;
return true;
} else {
return false;
}
}
void Direct3DDisplay::createFont()
{
if (!pFont) {
HRESULT hr = D3DXCreateFont(
pDevice,
dpp.BackBufferHeight / 20, // dynamic font size
0,
FW_BOLD,
1,
FALSE,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH || FF_DONTCARE,
_T("Arial"),
&pFont);
if (FAILED(hr)) {
DXTRACE_ERR_MSGBOX(_T("createFont failed"), hr);
}
}
}
void Direct3DDisplay::destroyFont()
{
if (pFont) {
pFont->Release();
pFont = NULL;
}
}
// fill texture completely with black
bool Direct3DDisplay::clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight)
{
D3DLOCKED_RECT lr;
HRESULT hr;
if (FAILED(hr = texture->LockRect(0, &lr, NULL, 0))) {
DXTRACE_ERR_MSGBOX(_T("Can not lock texture"), hr);
return false;
} else {
memset(lr.pBits, 0x00, lr.Pitch * textureHeight);
texture->UnlockRect(0);
return true;
}
}
// when either textureWidth or textureHeight is 0, last texture size will be used
void Direct3DDisplay::createTexture(unsigned int textureWidth, unsigned int textureHeight)
{
if ((textureWidth != 0) && (textureHeight != 0)) {
// calculate next possible square texture size
textureSize = 1;
unsigned int reqSizeMin = (textureWidth > textureHeight) ? textureWidth : textureHeight;
while (textureSize < reqSizeMin) {
textureSize <<= 1; // multiply by 2
}
} else {
// do not recalculate texture size
if (textureSize == 0) {
DXTRACE_MSG(_T("Error: createTexture: textureSize == 0"));
return;
}
}
if (!tempImage) {
HRESULT hr = pDevice->CreateTexture(
textureSize, textureSize,
1, // 1 level, no mipmaps
0, // dynamic textures can be locked
dpp.BackBufferFormat,
D3DPOOL_SYSTEMMEM,
&tempImage,
NULL);
if (FAILED(hr)) {
DXTRACE_ERR_MSGBOX(_T("createTexture(temp) failed"), hr);
return;
}
// initialize whole texture with black since we might see
// the initial noise when using bilinear texture filtering
clearTexture(tempImage, textureSize);
}
if (!emulatedImage[0]) {
HRESULT hr = pDevice->CreateTexture(
textureSize, textureSize,
1, // 1 level, no mipmaps
0,
dpp.BackBufferFormat,
D3DPOOL_DEFAULT,
&emulatedImage[0],
NULL);
if (FAILED(hr)) {
DXTRACE_ERR_MSGBOX(_T("createTexture(0) failed"), hr);
return;
}
}
if (!emulatedImage[1] && theApp.d3dMotionBlur) {
HRESULT hr = pDevice->CreateTexture(
textureSize, textureSize,
1,
0,
dpp.BackBufferFormat,
D3DPOOL_DEFAULT,
&emulatedImage[1],
NULL);
if (FAILED(hr)) {
DXTRACE_ERR_MSGBOX(_T("createTexture(1) failed"), hr);
return;
}
mbTextureEmpty = true;
}
}
void Direct3DDisplay::destroyTexture()
{
if (tempImage) {
tempImage->Release();
tempImage = NULL;
}
if (emulatedImage[0]) {
emulatedImage[0]->Release();
emulatedImage[0] = NULL;
}
if (emulatedImage[1]) {
emulatedImage[1]->Release();
emulatedImage[1] = NULL;
}
}
void Direct3DDisplay::calculateDestRect()
{
if (fullScreenStretch) {
rectangleFillsScreen = true; // no clear() necessary
destRect.left = 0;
destRect.top = 0;
destRect.right = dpp.BackBufferWidth; // for some reason there will be a black
destRect.bottom = dpp.BackBufferHeight; // border line when using -1 at the end
} else {
// use aspect ratio
float scaleX = (float)dpp.BackBufferWidth / (float)width;
float scaleY = (float)dpp.BackBufferHeight / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY;
if (maxScale && (min > maxScale)) {
min = (float)maxScale;
}
destRect.left = 0;
destRect.top = 0;
destRect.right = (LONG)(width * min);
destRect.bottom = (LONG)(height * min);
if (destRect.right != dpp.BackBufferWidth) {
LONG diff = (dpp.BackBufferWidth - destRect.right) / 2;
destRect.left += diff;
destRect.right += diff;
}
if (destRect.bottom != dpp.BackBufferHeight) {
LONG diff = (dpp.BackBufferHeight - destRect.bottom) / 2;
destRect.top += diff;
destRect.bottom += diff;
}
if ((destRect.left == 0) && (destRect.top == 0) && (destRect.right == dpp.BackBufferWidth) && (destRect.bottom == dpp.BackBufferHeight)) {
rectangleFillsScreen = true;
} else {
rectangleFillsScreen = false;
}
}
FLOAT textureX = (FLOAT)width / (FLOAT)textureSize;
FLOAT textureY = (FLOAT)height / (FLOAT)textureSize;
// configure triangles
Vertices[0].x = (FLOAT)destRect.left - 0.5f;
// -0.5f is necessary in order to match texture alignment to display pixels
Vertices[0].y = (FLOAT)destRect.bottom - 0.5f;
Vertices[0].z = 0.0f;
Vertices[0].rhw = 1.0f;
Vertices[0].tx = 0.0f;
Vertices[0].ty = textureY;
Vertices[1].x = (FLOAT)destRect.left - 0.5f;
Vertices[1].y = (FLOAT)destRect.top - 0.5f;
Vertices[1].z = 0.0f;
Vertices[1].rhw = 1.0f;
Vertices[1].tx = 0.0f;
Vertices[1].ty = 0.0f;
Vertices[2].x = (FLOAT)destRect.right - 0.5f;
Vertices[2].y = (FLOAT)destRect.bottom - 0.5f;
Vertices[2].z = 0.0f;
Vertices[2].rhw = 1.0f;
Vertices[2].tx = textureX;
Vertices[2].ty = textureY;
Vertices[3].x = (FLOAT)destRect.right - 0.5f;
Vertices[3].y = (FLOAT)destRect.top - 0.5f;
Vertices[3].z = 0.0f;
Vertices[3].rhw = 1.0f;
Vertices[3].tx = textureX;
Vertices[3].ty = 0.0f;
if (theApp.d3dMotionBlur) {
// configure semi-transparent triangles
D3DCOLOR semiTrans = D3DCOLOR_ARGB(0x7F, 0xFF, 0xFF, 0xFF);
transpVertices[0].x = Vertices[0].x;
transpVertices[0].y = Vertices[0].y;
transpVertices[0].z = Vertices[0].z;
transpVertices[0].rhw = Vertices[0].rhw;
transpVertices[0].color = semiTrans;
transpVertices[0].tx = Vertices[0].tx;
transpVertices[0].ty = Vertices[0].ty;
transpVertices[1].x = Vertices[1].x;
transpVertices[1].y = Vertices[1].y;
transpVertices[1].z = Vertices[1].z;
transpVertices[1].rhw = Vertices[1].rhw;
transpVertices[1].color = semiTrans;
transpVertices[1].tx = Vertices[1].tx;
transpVertices[1].ty = Vertices[1].ty;
transpVertices[2].x = Vertices[2].x;
transpVertices[2].y = Vertices[2].y;
transpVertices[2].z = Vertices[2].z;
transpVertices[2].rhw = Vertices[2].rhw;
transpVertices[2].color = semiTrans;
transpVertices[2].tx = Vertices[2].tx;
transpVertices[2].ty = Vertices[2].ty;
transpVertices[3].x = Vertices[3].x;
transpVertices[3].y = Vertices[3].y;
transpVertices[3].z = Vertices[3].z;
transpVertices[3].rhw = Vertices[3].rhw;
transpVertices[3].color = semiTrans;
transpVertices[3].tx = Vertices[3].tx;
transpVertices[3].ty = Vertices[3].ty;
}
}
void Direct3DDisplay::setOption(const char* option, int value)
{
if (!_tcscmp(option, _T("vsync"))) {
// value of theApp.vsync has already been changed by the menu handler
// 'value' has the same value as theApp.vsync
resetDevice();
}
if (!_tcscmp(option, _T("tripleBuffering"))) {
// value of theApp.tripleBuffering has already been changed by the menu handler
// 'value' has the same value as theApp.tripleBuffering
resetDevice();
}
if (!_tcscmp(option, _T("d3dFilter"))) {
switch (value) {
case 0: //point
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
break;
case 1: //linear
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
break;
}
}
if (!_tcscmp(option, _T("maxScale"))) {
calculateDestRect();
}
if (!_tcscmp(option, _T("fullScreenStretch"))) {
calculateDestRect();
}
if (!_tcscmp(option, _T("motionBlur"))) {
switch (value) {
case 0:
mbCurrentTexture = 0;
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
break;
case 1:
// enable vertex alpha blending
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
// apply vertex alpha values to texture
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
calculateDestRect();
createTexture(0, 0); // create the second texture
break;
}
}
}
bool Direct3DDisplay::resetDevice()
{
if (!pDevice)
return false;
HRESULT hr;
if (pFont) {
// prepares font for reset
pFont->OnLostDevice();
}
destroyTexture();
prepareDisplayMode();
if (FAILED(hr = pDevice->Reset(&dpp))) {
DXTRACE_ERR(_T("pDevice->Reset failed\n"), hr);
failed = true;
return false;
}
if (pFont) {
// re-aquires font resources
pFont->OnResetDevice();
}
createTexture(0, 0);
setOption(_T("d3dFilter"), theApp.d3dFilter);
setOption(_T("motionBlur"), theApp.d3dMotionBlur);
failed = false;
return true;
}
IDisplay* newDirect3DDisplay()
{
return new Direct3DDisplay();
}
#endif

View File

@ -1,804 +0,0 @@
#include "Input.h"
#include "Reg.h"
#include "VBA.h"
#include "WinResUtil.h"
#include "stdafx.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#pragma comment(lib, "dinput8")
#pragma comment(lib, "dxguid")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern void directXMessage(const char*);
extern void winlog(const char* msg, ...);
#define POV_UP 1
#define POV_DOWN 2
#define POV_RIGHT 4
#define POV_LEFT 8
class DirectInput : public Input {
public:
virtual void checkDevices();
DirectInput();
virtual ~DirectInput();
virtual bool initialize();
virtual bool readDevices();
virtual uint32_t readDevice(int which);
virtual CString getKeyName(LONG_PTR key);
virtual void checkKeys();
virtual void checkMotionKeys();
virtual void activate();
virtual void loadSettings();
virtual void saveSettings();
};
struct deviceInfo {
LPDIRECTINPUTDEVICE8 device;
BOOL isPolled;
int nButtons;
int nAxes;
int nPovs;
BOOL first;
struct {
DWORD offset;
LONG center;
LONG negative;
LONG positive;
} axis[8];
int needed;
union {
UCHAR data[256];
DIJOYSTATE state;
};
};
static deviceInfo* currentDevice = NULL;
static int numDevices = 1;
static deviceInfo* pDevices = NULL;
static LPDIRECTINPUT8 pDirectInput = NULL;
static int axisNumber = 0;
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] = {
DIK_LEFT, DIK_RIGHT,
DIK_UP, DIK_DOWN,
DIK_X, DIK_Z,
DIK_RETURN, DIK_BACK,
DIK_A, DIK_S,
DIK_SPACE, DIK_F12,
DIK_C,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
};
void winReadKey(const char* name, KeyList& Keys)
{
CString TxtKeyList = regQueryStringValue(name, "");
int curPos = 0;
CString resToken = TxtKeyList.Tokenize(",", curPos);
while (resToken != "") {
Keys.AddTail(atoi(resToken));
resToken = TxtKeyList.Tokenize(",", curPos);
};
}
void winReadKey(const char* name, int num, KeyList& Keys)
{
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
winReadKey(buffer, Keys);
}
void winReadKeys()
{
for (int i = 0; i < JOYPADS; i++) {
winReadKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
winReadKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
winReadKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
winReadKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
winReadKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
winReadKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
winReadKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
winReadKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
winReadKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
winReadKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
winReadKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
winReadKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
winReadKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
}
winReadKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winReadKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winReadKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]);
winReadKey("Motion_Down", theApp.input->joypaddata[MOTION(KEY_DOWN)]);
}
void winSaveKey(char* name, KeyList& value)
{
CString txtKeys;
POSITION p = value.GetHeadPosition();
while (p != NULL) {
CString tmp;
tmp.Format("%d", value.GetNext(p));
txtKeys += tmp;
if (p != NULL)
txtKeys += ",";
}
regSetStringValue(name, txtKeys);
}
static void winSaveKey(char* name, int num, KeyList& value)
{
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
winSaveKey(buffer, value);
}
void winSaveKeys()
{
for (int i = 0; i < JOYPADS; i++) {
winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
}
regSetDwordValue("joyVersion", 1);
winSaveKey("Motion_Left",
theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winSaveKey("Motion_Right",
theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winSaveKey("Motion_Up",
theApp.input->joypaddata[MOTION(KEY_UP)]);
winSaveKey("Motion_Down",
theApp.input->joypaddata[MOTION(KEY_DOWN)]);
}
static BOOL CALLBACK EnumPovsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext)
{
return DIENUM_CONTINUE;
}
static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
LPVOID lpvContext)
{
ZeroMemory(&pDevices[numDevices], sizeof(deviceInfo));
HRESULT hRet = pDirectInput->CreateDevice(pInst->guidInstance,
&pDevices[numDevices].device,
NULL);
if (hRet != DI_OK)
return DIENUM_STOP;
DIDEVCAPS caps;
caps.dwSize = sizeof(DIDEVCAPS);
hRet = pDevices[numDevices].device->GetCapabilities(&caps);
if (hRet == DI_OK) {
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT || caps.dwFlags & DIDC_POLLEDDEVICE)
pDevices[numDevices].isPolled = TRUE;
pDevices[numDevices].nButtons = caps.dwButtons;
pDevices[numDevices].nAxes = caps.dwAxes;
pDevices[numDevices].nPovs = caps.dwPOVs;
for (int i = 0; i < 6; i++) {
pDevices[numDevices].axis[i].center = 0x8000;
pDevices[numDevices].axis[i].negative = 0x4000;
pDevices[numDevices].axis[i].positive = 0xc000;
}
}
numDevices++;
return DIENUM_CONTINUE;
}
BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst,
LPVOID lpvContext)
{
numDevices++;
return DIENUM_CONTINUE;
}
static int getPovState(DWORD value)
{
int state = 0;
if (LOWORD(value) != 0xFFFF) {
if (value < 9000 || value > 27000)
state |= POV_UP;
if (value > 0 && value < 18000)
state |= POV_RIGHT;
if (value > 9000 && value < 27000)
state |= POV_DOWN;
if (value > 18000)
state |= POV_LEFT;
}
return state;
}
static void checkKeys()
{
LONG_PTR dev = 0;
int i;
for (i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) {
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
theApp.input->joypaddata[i].AddTail(defvalues[i]);
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
while (p != NULL) {
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
if (k > 0 && DEVICEOF(k) < numDevices)
pDevices[DEVICEOF(k)].needed = true;
}
}
}
#define KEYDOWN(buffer, key) (buffer[key] & 0x80)
static bool readKeyboard()
{
if (pDevices[0].needed) {
HRESULT hret = pDevices[0].device->GetDeviceState(256,
(LPVOID)pDevices[0].data);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
hret = pDevices[0].device->Acquire();
if (hret != DI_OK)
return false;
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
}
return hret == DI_OK;
}
return true;
}
static bool readJoystick(int joy)
{
if (pDevices[joy].needed) {
if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
HRESULT hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
hret = pDevices[joy].device->Acquire();
if (hret == DI_OK) {
if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
}
}
return hret == DI_OK;
}
return true;
}
static void checkKeyboard()
{
// mham fix. Patch #1378104
UCHAR keystate[256];
HRESULT hret = pDevices[0].device->Acquire();
if (pDevices[0].first) {
pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
pDevices[0].first = FALSE;
return;
}
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)keystate);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
return;
}
if (hret == DI_OK) {
for (int i = 0; i < 256; i++) {
if (keystate[i] == pDevices[0].data[i])
continue;
if (KEYDOWN(keystate, i)) {
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i);
break;
}
}
}
memcpy(pDevices[0].data, keystate, sizeof(UCHAR) * 256);
}
static void checkJoypads()
{
DIDEVICEOBJECTINSTANCE di;
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
int i = 0;
DIJOYSTATE joystick;
for (i = 1; i < numDevices; i++) {
HRESULT hret = pDevices[i].device->Acquire();
if (pDevices[i].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
hret = pDevices[i].device->GetDeviceState(sizeof(joystick), &joystick);
int j;
if (pDevices[i].first) {
memcpy(&pDevices[i].state, &joystick, sizeof(joystick));
pDevices[i].first = FALSE;
continue;
}
for (j = 0; j < pDevices[i].nButtons; j++) {
if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
& joystick.rgbButtons[j])
& 0x80) {
HWND focus = GetFocus();
SendMessage(focus, JOYCONFIG_MESSAGE, i, j + 128);
}
}
for (j = 0; j < pDevices[i].nAxes && j < 8; j++) {
LONG value = pDevices[i].axis[j].center;
LONG old = 0;
const DWORD offset = pDevices[i].axis[j].offset;
value = *(LONG*)(((char*)&joystick.lX) + offset);
old = *(LONG*)(((char*)&pDevices[i].state.lX) + offset);
if (value != old) {
if (value < pDevices[i].axis[j].negative)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 1));
else if (value > pDevices[i].axis[j].positive)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 1) + 1);
}
}
for (j = 0; j < 4 && j < pDevices[i].nPovs; j++) {
if (LOWORD(pDevices[i].state.rgdwPOV[j]) != LOWORD(joystick.rgdwPOV[j])) {
int state = getPovState(joystick.rgdwPOV[j]);
if (state & POV_UP)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x20);
else if (state & POV_DOWN)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x21);
else if (state & POV_RIGHT)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x22);
else if (state & POV_LEFT)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x23);
}
}
memcpy(&pDevices[i].state, &joystick, sizeof(joystick));
}
}
BOOL checkKey(LONG_PTR key)
{
LONG_PTR dev = (key >> 8);
LONG_PTR k = (key & 255);
if (dev == 0) {
return KEYDOWN(pDevices[0].data, k);
} else if (dev >= numDevices) {
return FALSE;
} else {
if (k < 16) {
LONG_PTR axis = k >> 1;
LONG value = pDevices[dev].axis[axis].center;
value = *(LONG*)(((char*)&pDevices[dev].state.lX) + pDevices[dev].axis[axis].offset);
if (k & 1)
return value > pDevices[dev].axis[axis].positive;
return value < pDevices[dev].axis[axis].negative;
} else if (k < 48) {
LONG_PTR hat = (k >> 2) & 3;
int state = getPovState(pDevices[dev].state.rgdwPOV[hat]);
BOOL res = FALSE;
res = state & (1 << (k & 3));
return res;
} else if (k >= 128) {
return pDevices[dev].state.rgbButtons[k - 128] & 0x80;
}
}
return FALSE;
}
BOOL checkKey(KeyList& k)
{
POSITION p = k.GetHeadPosition();
while (p != NULL) {
if (checkKey(k.GetNext(p)))
return TRUE;
}
return FALSE;
}
DirectInput::DirectInput()
{
}
DirectInput::~DirectInput()
{
saveSettings();
if (pDirectInput != NULL) {
if (pDevices) {
for (int i = 0; i < numDevices; i++) {
if (pDevices[i].device) {
pDevices[i].device->Unacquire();
pDevices[i].device->Release();
pDevices[i].device = NULL;
}
}
free(pDevices);
pDevices = NULL;
}
pDirectInput->Release();
pDirectInput = NULL;
}
}
bool DirectInput::initialize()
{
HRESULT hr;
hr = DirectInput8Create(
GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(LPVOID*)&pDirectInput,
NULL);
ASSERT(hr == DI_OK);
if (hr != DI_OK)
return false;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback2,
NULL,
DIEDFL_ATTACHEDONLY);
pDevices = (deviceInfo*)calloc(numDevices, sizeof(deviceInfo));
hr = pDirectInput->CreateDevice(GUID_SysKeyboard, &pDevices[0].device, NULL);
pDevices[0].isPolled = false;
pDevices[0].needed = true;
pDevices[0].first = true;
if (hr != DI_OK) {
return false;
}
numDevices = 1;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback,
NULL,
DIEDFL_ATTACHEDONLY);
if (hr != DI_OK) {
return false;
}
hr = pDevices[0].device->SetDataFormat(&c_dfDIKeyboard);
if (hr != DI_OK) {
return false;
}
int i;
for (i = 1; i < numDevices; i++) {
pDevices[i].device->SetDataFormat(&c_dfDIJoystick);
pDevices[i].needed = false;
pDevices[i].first = true;
currentDevice = &pDevices[i];
axisNumber = 0;
// get up to 6 axes and 2 sliders
DIPROPRANGE range;
range.diph.dwSize = sizeof(range);
range.diph.dwHeaderSize = sizeof(range.diph);
range.diph.dwHow = DIPH_BYOFFSET;
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
// this should be more foolproof, less code, and probably faster
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) {
range.diph.dwObj = offset;
// try to set some nice power of 2 values (8192)
range.lMin = -(1 << 13);
range.lMax = (1 << 13);
pDevices[i].device->SetProperty(DIPROP_RANGE, &range.diph);
// but i guess not all devices support setting range
// so i getproperty right afterward incase it didn't set :P
// this also checks that the axis is present
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) {
const LONG center = (range.lMin + range.lMax) / 2;
const LONG threshold = (range.lMax - center) / 2;
currentDevice->axis[axisNumber].center = center;
currentDevice->axis[axisNumber].negative = center - threshold;
currentDevice->axis[axisNumber].positive = center + threshold;
currentDevice->axis[axisNumber].offset = offset;
++axisNumber;
}
}
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
currentDevice = NULL;
}
for (i = 0; i < numDevices; i++)
pDevices[i].device->Acquire();
return true;
}
bool DirectInput::readDevices()
{
bool ok = true;
for (int i = 0; i < numDevices; i++) {
if (pDevices[i].needed) {
if (i) {
ok = readJoystick(i);
} else
ok = readKeyboard();
}
}
return ok;
}
uint32_t DirectInput::readDevice(int which)
{
uint32_t res = 0;
int i = joypadDefault;
if (which >= 0 && which <= 3)
i = which;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]))
res |= 1;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]))
res |= 2;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]))
res |= 4;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]))
res |= 8;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]))
res |= 16;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]))
res |= 32;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_UP)]))
res |= 64;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]))
res |= 128;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]))
res |= 256;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]))
res |= 512;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]))
res |= 4096;
if (autoFire) {
res &= (~autoFire);
if (autoFireToggle)
res |= autoFire;
autoFireToggle = !autoFireToggle;
}
// disallow L+R or U+D of being pressed at the same time
if ((res & 48) == 48)
res &= ~16;
if ((res & 192) == 192)
res &= ~128;
if (movieRecording) {
if (i == joypadDefault) {
if (res != movieLastJoypad) {
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
fwrite(&res, 1, sizeof(res), theApp.movieFile);
movieLastJoypad = res;
}
}
}
if (moviePlaying) {
if (movieFrame == moviePlayFrame) {
movieLastJoypad = movieNextJoypad;
theApp.movieReadNext();
}
res = movieLastJoypad;
}
// we don't record speed up or screen capture buttons
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]) || speedupToggle)
res |= 1024;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]))
res |= 2048;
return res;
}
CString DirectInput::getKeyName(LONG_PTR key)
{
LONG_PTR d = (key >> 8);
LONG_PTR k = key & 255;
DIDEVICEOBJECTINSTANCE di;
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
CString winBuffer = winResLoadString(IDS_ERROR);
if (d == 0) {
pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET);
winBuffer = di.tszName;
} else if (d < numDevices) {
if (k < 16) {
pDevices[d].device->GetObjectInfo(&di,
pDevices[d].axis[k >> 1].offset,
DIPH_BYOFFSET);
if (k & 1)
winBuffer.Format("Joy %d %s +", d, di.tszName);
else
winBuffer.Format("Joy %d %s -", d, di.tszName);
} else if (k < 48) {
LONG_PTR hat = (k >> 2) & 3;
pDevices[d].device->GetObjectInfo(&di,
(DWORD)DIJOFS_POV(hat),
DIPH_BYOFFSET);
char* dir = "up";
LONG_PTR dd = k & 3;
if (dd == 1)
dir = "down";
else if (dd == 2)
dir = "right";
else if (dd == 3)
dir = "left";
winBuffer.Format("Joy %d %s %s", d, di.tszName, dir);
} else {
pDevices[d].device->GetObjectInfo(&di,
(DWORD)DIJOFS_BUTTON(k - 128),
DIPH_BYOFFSET);
winBuffer.Format(winResLoadString(IDS_JOY_BUTTON), d, di.tszName);
}
} else {
// Joystick isn't plugged in. We can't decipher k, so just show its value.
winBuffer.Format("Joy %d (%d)", d, k);
}
return winBuffer;
}
void DirectInput::checkKeys()
{
::checkKeys();
}
void DirectInput::checkMotionKeys()
{
if (checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
sunBars--;
if (sunBars < 1)
sunBars = 1;
sensorX += 3;
if (sensorX > 2197)
sensorX = 2197;
if (sensorX < 2047)
sensorX = 2057;
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
sunBars++;
if (sunBars > 100)
sunBars = 100;
sensorX -= 3;
if (sensorX < 1897)
sensorX = 1897;
if (sensorX > 2047)
sensorX = 2037;
} else if (sensorX > 2047) {
sensorX -= 2;
if (sensorX < 2047)
sensorX = 2047;
} else {
sensorX += 2;
if (sensorX > 2047)
sensorX = 2047;
}
if (checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
sensorY += 3;
if (sensorY > 2197)
sensorY = 2197;
if (sensorY < 2047)
sensorY = 2057;
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
sensorY -= 3;
if (sensorY < 1897)
sensorY = 1897;
if (sensorY > 2047)
sensorY = 2037;
} else if (sensorY > 2047) {
sensorY -= 2;
if (sensorY < 2047)
sensorY = 2047;
} else {
sensorY += 2;
if (sensorY > 2047)
sensorY = 2047;
}
}
Input* newDirectInput()
{
return new DirectInput;
}
void DirectInput::checkDevices()
{
checkJoypads();
checkKeyboard();
}
void DirectInput::activate()
{
for (int i = 0; i < numDevices; i++) {
if (pDevices != NULL && pDevices[i].device != NULL)
pDevices[i].device->Acquire();
}
}
void DirectInput::loadSettings()
{
winReadKeys();
}
void DirectInput::saveSettings()
{
winSaveKeys();
}

View File

@ -1,304 +0,0 @@
// MFC
#include "stdafx.h"
// Application
#include "VBA.h"
// Tools
#include "AVIWrite.h"
#include "WavWriter.h"
// Internals
#include "../System.h"
#include "../common/SoundDriver.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../gba/Sound.h"
// DirectSound8
#define DIRECTSOUND_VERSION 0x0800
#include <dsound.h>
extern bool soundBufferLow;
class DirectSound : public SoundDriver {
private:
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
LPDIRECTSOUNDNOTIFY8 dsbNotify;
HANDLE dsbEvent;
WAVEFORMATEX wfx; // Primary buffer wave format
int soundBufferLen;
int soundBufferTotalLen;
unsigned int soundNextPosition;
public:
DirectSound();
virtual ~DirectSound();
bool init(long sampleRate); // initialize the primary and secondary sound buffer
void pause(); // pause the secondary sound buffer
void reset(); // stop and reset the secondary sound buffer
void resume(); // resume the secondary sound buffer
void write(uint16_t* finalWave, int length); // write the emulated sound to the secondary sound buffer
};
DirectSound::DirectSound()
{
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
dsbNotify = NULL;
dsbEvent = NULL;
soundBufferTotalLen = 14700;
soundNextPosition = 0;
}
DirectSound::~DirectSound()
{
if (dsbNotify) {
dsbNotify->Release();
dsbNotify = NULL;
}
if (dsbEvent) {
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
if (pDirectSound) {
if (dsbPrimary) {
dsbPrimary->Release();
dsbPrimary = NULL;
}
if (dsbSecondary) {
dsbSecondary->Release();
dsbSecondary = NULL;
}
pDirectSound->Release();
pDirectSound = NULL;
}
}
bool DirectSound::init(long sampleRate)
{
HRESULT hr;
DWORD freq;
DSBUFFERDESC dsbdesc;
int i;
hr = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID*)&pDirectSound);
if (hr != S_OK) {
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
return false;
}
pDirectSound->Initialize(&DSDEVID_DefaultPlayback);
if (hr != DS_OK) {
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
return false;
}
if (FAILED(hr = pDirectSound->SetCooperativeLevel(theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE))) {
systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr);
return false;
}
// Create primary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if (dsoundDisableHardwareAcceleration) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL))) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
return false;
}
freq = sampleRate;
// calculate the number of samples per frame first
// then multiply it with the size of a sample frame (16 bit * stereo)
soundBufferLen = (freq / 60) * 4;
soundBufferTotalLen = soundBufferLen * 10;
soundNextPosition = 0;
ZeroMemory(&wfx, sizeof(WAVEFORMATEX));
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = freq;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if (FAILED(hr = dsbPrimary->SetFormat(&wfx))) {
systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr);
return false;
}
// Create secondary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
if (dsoundDisableHardwareAcceleration) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
dsbdesc.lpwfxFormat = &wfx;
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr);
return false;
}
if (FAILED(hr = dsbSecondary->SetCurrentPosition(0))) {
systemMessage(0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr);
return false;
}
if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) {
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
DSBPOSITIONNOTIFY notify[10];
for (i = 0; i < 10; i++) {
notify[i].dwOffset = i * soundBufferLen;
notify[i].hEventNotify = dsbEvent;
}
if (FAILED(dsbNotify->SetNotificationPositions(10, notify))) {
dsbNotify->Release();
dsbNotify = NULL;
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
}
// Play primary buffer
if (FAILED(hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING))) {
systemMessage(IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr);
return false;
}
return true;
}
void DirectSound::pause()
{
if (dsbSecondary == NULL)
return;
DWORD status;
dsbSecondary->GetStatus(&status);
if (status & DSBSTATUS_PLAYING)
dsbSecondary->Stop();
}
void DirectSound::reset()
{
if (dsbSecondary == NULL)
return;
dsbSecondary->Stop();
dsbSecondary->SetCurrentPosition(0);
soundNextPosition = 0;
}
void DirectSound::resume()
{
if (dsbSecondary == NULL)
return;
dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
}
void DirectSound::write(uint16_t* finalWave, int length)
{
if (!pDirectSound)
return;
HRESULT hr;
DWORD status = 0;
DWORD play = 0;
LPVOID lpvPtr1;
DWORD dwBytes1 = 0;
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if (!speedup && throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if (status & DSBSTATUS_PLAYING) {
if (!soundPaused) {
while (true) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ? play - soundNextPosition : soundBufferTotalLen - soundNextPosition + play);
if (BufferLeft > soundBufferLen) {
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if (dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
} /* else {
// TODO: remove?
setsoundPaused(true);
}*/
}
// Obtain memory address of write block.
// This will be in two parts if the block wraps around.
if (DSERR_BUFFERLOST == (hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0))) {
// If DSERR_BUFFERLOST is returned, restore and retry lock.
dsbSecondary->Restore();
hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0);
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if (SUCCEEDED(hr)) {
// Write to pointers.
CopyMemory(lpvPtr1, finalWave, dwBytes1);
if (lpvPtr2) {
CopyMemory(lpvPtr2, finalWave + dwBytes1, dwBytes2);
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
} else {
systemMessage(0, _T("dsbSecondary->Lock() failed: %08x"), hr);
return;
}
}
SoundDriver* newDirectSound()
{
return new DirectSound();
}

View File

@ -1,281 +0,0 @@
#include "Directories.h"
#include "Reg.h"
#include "WinResUtil.h"
#include "stdafx.h"
#include "vba.h"
#include <shlobj.h>
#include <shlwapi.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Directories dialog
static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg,
LPARAM l, LPARAM data)
{
char* buffer = (char*)data;
switch (msg) {
case BFFM_INITIALIZED:
if (buffer[0])
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer);
break;
default:
break;
}
return 0;
}
Directories::Directories(CWnd* pParent /*=NULL*/)
: CDialog(Directories::IDD, pParent)
{
}
void Directories::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SAVE_PATH, m_savePath);
DDX_Control(pDX, IDC_ROM_PATH, m_romPath);
DDX_Control(pDX, IDC_GBCROM_PATH, m_gbcromPath);
DDX_Control(pDX, IDC_GBROM_PATH, m_gbromPath);
DDX_Control(pDX, IDC_CAPTURE_PATH, m_capturePath);
DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
}
BEGIN_MESSAGE_MAP(Directories, CDialog)
ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
ON_BN_CLICKED(IDC_GBROM_DIR, OnGbromDir)
ON_BN_CLICKED(IDC_ROM_DIR, OnRomDir)
ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir)
ON_BN_CLICKED(IDC_GBCROM_DIR, OnGbcromDir)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Directories message handlers
BOOL Directories::OnInitDialog()
{
CDialog::OnInitDialog();
CString p;
p = regQueryStringValue("romdir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_ROM_PATH)->SetWindowText(p);
p = regQueryStringValue("gbcromdir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_GBCROM_PATH)->SetWindowText(p);
p = regQueryStringValue("gbromdir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_GBROM_PATH)->SetWindowText(p);
p = regQueryStringValue("batteryDir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_BATTERY_PATH)->SetWindowText(p);
p = regQueryStringValue("saveDir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p);
p = regQueryStringValue("captureDir", NULL);
if (!p.IsEmpty())
GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p);
return TRUE;
// return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Directories::OnBatteryDir()
{
m_batteryPath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR));
if (!p.IsEmpty())
m_batteryPath.SetWindowText(p);
}
void Directories::OnCaptureDir()
{
m_capturePath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR));
if (!p.IsEmpty())
m_capturePath.SetWindowText(p);
}
void Directories::OnGbromDir()
{
m_gbromPath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
if (!p.IsEmpty())
m_gbromPath.SetWindowText(p);
}
void Directories::OnGbcromDir()
{
m_gbcromPath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
if (!p.IsEmpty())
m_gbcromPath.SetWindowText(p);
}
void Directories::OnRomDir()
{
m_romPath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
if (!p.IsEmpty())
m_romPath.SetWindowText(p);
}
void Directories::OnSaveDir()
{
m_savePath.GetWindowText(initialFolderDir);
CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR));
if (!p.IsEmpty())
m_savePath.SetWindowText(p);
}
void Directories::OnCancel()
{
EndDialog(FALSE);
}
void Directories::OnOK()
{
CDialog::OnOK();
char baseDir[MAX_PATH + 1];
char temp[MAX_PATH + 1];
GetModuleFileName(NULL, baseDir, MAX_PATH);
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec(baseDir); // removes the trailing file name and backslash
CString buffer;
m_romPath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("romdir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
m_gbcromPath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("gbcromdir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
m_gbromPath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("gbromdir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
m_batteryPath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("batteryDir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
m_savePath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("saveDir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
m_capturePath.GetWindowText(buffer);
if (!buffer.IsEmpty())
regSetStringValue("captureDir", buffer);
if (buffer[0] == '.') {
strcpy(temp, baseDir);
strcat(temp, "\\");
strcat(temp, buffer);
buffer = temp;
}
if (!directoryDoesExist(buffer))
SHCreateDirectoryEx(NULL, buffer, NULL);
EndDialog(TRUE);
}
CString Directories::browseForDir(CString title)
{
static char buffer[1024];
LPMALLOC pMalloc;
LPITEMIDLIST pidl;
CString res;
if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = m_hWnd;
bi.lpszTitle = title;
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
bi.lpfn = browseCallbackProc;
bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir;
pidl = SHBrowseForFolder(&bi);
if (pidl) {
if (SHGetPathFromIDList(pidl, buffer)) {
res = buffer;
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}
return res;
}
// returns true if the directory does exist
bool Directories::directoryDoesExist(const char* directory)
{
HANDLE hDir;
hDir = CreateFile(
directory,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
bool retval = (hDir == INVALID_HANDLE_VALUE) ? false : true;
CloseHandle(hDir);
return retval;
}

View File

@ -1,32 +0,0 @@
#pragma once
class Directories : public CDialog {
public:
Directories(CWnd* pParent = NULL);
enum { IDD = IDD_DIRECTORIES };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
afx_msg void OnBatteryDir();
afx_msg void OnCaptureDir();
afx_msg void OnGbromDir();
afx_msg void OnGbcromDir();
afx_msg void OnRomDir();
afx_msg void OnSaveDir();
virtual void OnCancel();
virtual void OnOK();
DECLARE_MESSAGE_MAP()
private:
CEdit m_savePath;
CEdit m_romPath;
CEdit m_gbcromPath;
CEdit m_gbromPath;
CEdit m_capturePath;
CEdit m_batteryPath;
CString initialFolderDir;
CString browseForDir(CString title);
bool directoryDoesExist(const char* directory);
};

View File

@ -1,333 +0,0 @@
#include "Disassemble.h"
#include "stdafx.h"
#include "vba.h"
#include "../System.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../gba/armdis.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int emulating;
extern void CPUUpdateCPSR();
/////////////////////////////////////////////////////////////////////////////
// Disassemble dialog
Disassemble::Disassemble(CWnd* pParent /*=NULL*/)
: ResizeDlg(Disassemble::IDD, pParent)
{
//{{AFX_DATA_INIT(Disassemble)
m_c = FALSE;
m_f = FALSE;
m_i = FALSE;
m_n = FALSE;
m_t = FALSE;
m_v = FALSE;
m_z = FALSE;
mode = -1;
//}}AFX_DATA_INIT
mode = 0;
address = 0;
autoUpdate = false;
count = 1;
}
void Disassemble::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Disassemble)
DDX_Control(pDX, IDC_ADDRESS, m_address);
DDX_Control(pDX, IDC_DISASSEMBLE, m_list);
DDX_Check(pDX, IDC_C, m_c);
DDX_Check(pDX, IDC_F, m_f);
DDX_Check(pDX, IDC_I, m_i);
DDX_Check(pDX, IDC_N, m_n);
DDX_Check(pDX, IDC_T, m_t);
DDX_Check(pDX, IDC_V, m_v);
DDX_Check(pDX, IDC_Z, m_z);
DDX_Radio(pDX, IDC_AUTOMATIC, mode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Disassemble, CDialog)
//{{AFX_MSG_MAP(Disassemble)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
ON_BN_CLICKED(IDC_AUTOMATIC, OnAutomatic)
ON_BN_CLICKED(IDC_ARM, OnArm)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_BN_CLICKED(IDC_GO, OnGo)
ON_BN_CLICKED(IDC_GOPC, OnGopc)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_BN_CLICKED(IDC_THUMB, OnThumb)
ON_WM_VSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Disassemble message handlers
void Disassemble::OnAutoUpdate()
{
autoUpdate = !autoUpdate;
if (autoUpdate) {
theApp.winAddUpdateListener(this);
} else {
theApp.winRemoveUpdateListener(this);
}
}
void Disassemble::OnAutomatic()
{
mode = 0;
refresh();
}
void Disassemble::OnArm()
{
mode = 1;
address &= 0xfffffffC;
refresh();
}
void Disassemble::OnClose()
{
theApp.winRemoveUpdateListener(this);
DestroyWindow();
}
void Disassemble::OnGo()
{
CString buffer;
m_address.GetWindowText(buffer);
sscanf(buffer, "%x", &address);
if (mode == 1)
address &= 0xfffffffc;
else if (mode == 2)
address &= 0xfffffffe;
refresh();
}
void Disassemble::OnGopc()
{
if (rom != NULL) {
if (armState)
address = armNextPC - 16;
else
address = armNextPC - 8;
refresh();
}
}
void Disassemble::OnNext()
{
if (rom != NULL) {
CPULoop(1);
if (armState) {
uint32_t total = address + count * 4;
if (armNextPC >= address && armNextPC < total) {
} else {
OnGopc();
}
} else {
uint32_t total = address + count * 2;
if (armNextPC >= address && armNextPC < total) {
} else {
OnGopc();
}
}
refresh();
}
}
void Disassemble::OnRefresh()
{
refresh();
}
void Disassemble::OnThumb()
{
mode = 2;
address &= 0xfffffffe;
refresh();
}
BOOL Disassemble::OnInitDialog()
{
CDialog::OnInitDialog();
DIALOG_SIZER_START(sz)
DIALOG_SIZER_ENTRY(IDC_DISASSEMBLE, DS_SizeY)
DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_NEXT, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_AUTO_UPDATE, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_GOPC, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_VSCROLL, DS_SizeY)
DIALOG_SIZER_END()
SetData(sz,
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\DisassembleView",
NULL);
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
si.nMin = 0;
si.nMax = 100;
si.nPos = 50;
si.nPage = 0;
GetDlgItem(IDC_VSCROLL)->SetScrollInfo(SB_CTL, &si, TRUE);
CFont* font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
m_list.SetFont(font, FALSE);
for (int i = 0; i < 17; i++)
GetDlgItem(IDC_R0 + i)->SetFont(font, FALSE);
GetDlgItem(IDC_MODE)->SetFont(font, FALSE);
m_address.LimitText(8);
refresh();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Disassemble::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
switch (nSBCode) {
case SB_LINEDOWN:
if (mode == 0) {
if (armState)
address += 4;
else
address += 2;
} else if (mode == 1)
address += 4;
else
address += 2;
break;
case SB_LINEUP:
if (mode == 0) {
if (armState)
address -= 4;
else
address -= 2;
} else if (mode == 1)
address -= 4;
else
address -= 2;
break;
case SB_PAGEDOWN:
if (mode == 0) {
if (armState)
address += count * 4;
else
address += count * 2;
} else if (mode == 1)
address += count * 4;
else
address += count * 2;
break;
case SB_PAGEUP:
if (mode == 0) {
if (armState)
address -= count * 4;
else
address -= count * 2;
} else if (mode == 1)
address -= count * 4;
else
address -= count * 2;
break;
}
refresh();
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
void Disassemble::refresh()
{
if (rom == NULL)
return;
bool arm = armState;
if (mode != 0) {
if (mode == 1)
arm = true;
else
arm = false;
}
int h = m_list.GetItemHeight(0);
RECT r;
m_list.GetClientRect(&r);
count = (r.bottom - r.top + 1) / h;
m_list.ResetContent();
if (!emulating && theApp.cartridgeType == 0)
return;
char buffer[80];
uint32_t addr = address;
int i;
int sel = -1;
for (i = 0; i < count; i++) {
if (addr == armNextPC)
sel = i;
if (arm) {
addr += disArm(addr, buffer, 3);
} else {
addr += disThumb(addr, buffer, 3);
}
m_list.InsertString(-1, buffer);
}
if (sel != -1)
m_list.SetCurSel(sel);
CPUUpdateCPSR();
for (i = 0; i < 17; i++) {
sprintf(buffer, "%08x", reg[i].I);
GetDlgItem(IDC_R0 + i)->SetWindowText(buffer);
}
m_n = (reg[16].I & 0x80000000) != 0;
m_z = (reg[16].I & 0x40000000) != 0;
m_c = (reg[16].I & 0x20000000) != 0;
m_v = (reg[16].I & 0x10000000) != 0;
m_i = (reg[16].I & 0x80) != 0;
m_f = (reg[16].I & 0x40) != 0;
m_t = (reg[16].I & 0x20) != 0;
UpdateData(FALSE);
int v = reg[16].I & 0x1f;
sprintf(buffer, "%02x", v);
GetDlgItem(IDC_MODE)->SetWindowText(buffer);
}
void Disassemble::update()
{
OnGopc();
refresh();
}
void Disassemble::PostNcDestroy()
{
delete this;
}

View File

@ -1,72 +0,0 @@
#if !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_)
#define AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Disassemble.h : header file
//
#include "../System.h" // Added by ClassView
#include "IUpdate.h"
#include "ResizeDlg.h"
/////////////////////////////////////////////////////////////////////////////
// Disassemble dialog
class Disassemble : public ResizeDlg, IUpdateListener {
// Construction
public:
virtual void update();
void refresh();
int count;
bool autoUpdate;
uint32_t address;
Disassemble(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Disassemble)
enum { IDD = IDD_DISASSEMBLE };
CEdit m_address;
CListBox m_list;
BOOL m_c;
BOOL m_f;
BOOL m_i;
BOOL m_n;
BOOL m_t;
BOOL m_v;
BOOL m_z;
int mode;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Disassemble)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Disassemble)
afx_msg void OnAutoUpdate();
afx_msg void OnAutomatic();
afx_msg void OnArm();
afx_msg void OnClose();
afx_msg void OnGo();
afx_msg void OnGopc();
afx_msg void OnNext();
afx_msg void OnRefresh();
afx_msg void OnThumb();
virtual BOOL OnInitDialog();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_)

View File

@ -1,99 +0,0 @@
#pragma once
#include <memory.h>
enum DISPLAY_TYPE { DIRECT_3D = 0,
OPENGL = 1 };
class IDisplay {
public:
IDisplay(){};
virtual ~IDisplay(){};
struct VIDEO_MODE {
unsigned int adapter;
unsigned int width;
unsigned int height;
unsigned int bitDepth;
unsigned int frequency;
};
virtual bool initialize() = 0;
virtual void cleanup() = 0;
virtual void render() = 0;
virtual void clear() = 0;
virtual bool changeRenderSize(int w, int h)
{
return true;
};
virtual void resize(int w, int h){};
virtual void setOption(const char* option, int value){};
virtual DISPLAY_TYPE getType() = 0;
virtual bool selectFullScreenMode(VIDEO_MODE& mode) = 0;
};
inline void cpyImg32(unsigned char* dst, unsigned int dstPitch, unsigned char* src,
unsigned int srcPitch, unsigned short width, unsigned short height)
{
// fast, iterative C version
// copies an width*height array of visible pixels from src to dst
// srcPitch and dstPitch are the number of garbage bytes after a scanline
register unsigned short lineSize = width << 2;
while (height--) {
memcpy(dst, src, lineSize);
src += srcPitch;
dst += dstPitch;
}
}
inline void cpyImg32bmp(unsigned char* dst, unsigned char* src, unsigned int srcPitch,
unsigned short width, unsigned short height)
{
// dst will be an upside down bitmap with 24bit colors
// pix must contain 32bit colors (XRGB)
unsigned short srcLineSize = width << 2;
dst += height * width * 3; // move to the last scanline
register unsigned char r, g, b;
while (height--) {
unsigned short x = width;
src += srcLineSize;
while (x--) {
--src; // ignore one of 4 bytes
b = *--src;
g = *--src;
r = *--src;
*--dst = b;
*--dst = g;
*--dst = r;
}
src += srcPitch;
}
}
inline void cpyImg16(unsigned char* dst, unsigned int dstPitch, unsigned char* src,
unsigned int srcPitch, unsigned short width, unsigned short height)
{
register unsigned short lineSize = width << 1;
while (height--) {
memcpy(dst, src, lineSize);
src += srcPitch;
dst += dstPitch;
}
}
inline void cpyImg16bmp(unsigned char* dst, unsigned char* src, unsigned int srcPitch,
unsigned short width, unsigned short height)
{
// dst will be an upside down bitmap with 16bit colors
register unsigned short lineSize = width << 1;
dst += (height - 1) * lineSize; // move to the last scanline
while (height--) {
memcpy(dst, src, lineSize);
src += srcPitch;
dst -= lineSize;
}
}

Some files were not shown because too many files have changed in this diff Show More