From: S?bastien G. <kx...@us...> - 2004-03-29 22:20:13
|
Update of /cvsroot/vba/VisualBoyAdvance/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3551/src/gtk Added Files: Makefile.am Makefile.in filters.h input.cpp input.h intl.h main.cpp screenarea.cpp system.cpp tools.cpp tools.h vba.glade window.cpp window.h Log Message: GTK+ frontend draft added. --- NEW FILE: tools.h --- // -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __VBA_TOOLS_H__ #define __VBA_TOOLS_H__ #include <string> namespace VBA { std::string sCutSuffix(const std::string & _sString, const std::string & _sSep = std::string(".")); } #endif // __VBA_TOOLS_H__ --- NEW FILE: input.h --- // -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __VBA_INPUT_H__ #define __VBA_INPUT_H__ #include <glib.h> namespace VBA { enum EKey { KEY_NONE, // GBA keys KEY_A, KEY_B, KEY_SELECT, KEY_START, KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN, KEY_R, KEY_L, // VBA extension KEY_SPEED, KEY_CAPTURE }; enum EKeyFlag { // GBA keys KEYFLAG_A = 1 << 0, KEYFLAG_B = 1 << 1, KEYFLAG_SELECT = 1 << 2, KEYFLAG_START = 1 << 3, KEYFLAG_RIGHT = 1 << 4, KEYFLAG_LEFT = 1 << 5, KEYFLAG_UP = 1 << 6, KEYFLAG_DOWN = 1 << 7, KEYFLAG_R = 1 << 8, KEYFLAG_L = 1 << 9, // VBA extension KEYFLAG_SPEED = 1 << 10, KEYFLAG_CAPTURE = 1 << 11, }; class Keymap { public: Keymap(); ~Keymap(); void vRegister(guint _uiVal, EKey _eKey); void vClear(); inline EKey eGetKey(guint _uiVal); private: GHashTable * m_pstTable; // noncopyable Keymap(const Keymap &); Keymap & operator=(const Keymap &); }; inline EKey Keymap::eGetKey(guint _uiVal) { return (EKey)GPOINTER_TO_UINT(g_hash_table_lookup(m_pstTable, GUINT_TO_POINTER(_uiVal))); } } // namespace VBA #endif // __VBA_INPUT_H__ --- NEW FILE: main.cpp --- // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <libglademm.h> #include <gtkmm/main.h> #include <gtkmm/messagedialog.h> #include "window.h" #include "intl.h" using Gnome::Glade::Xml; int main(int argc, char * argv[]) { #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); textdomain(GETTEXT_PACKAGE); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); #endif // ENABLE_NLS Gtk::Main oKit(argc, argv); Glib::RefPtr<Xml> poXml; try { poXml = Xml::create(PKGDATADIR "/vba.glade", "MainWindow"); } catch (const Xml::Error & e) { Gtk::MessageDialog oDialog(e.what(), Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE); oDialog.run(); return 1; } VBA::Window * poWindow = NULL; poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow); Gtk::Main::run(*poWindow); return 0; } --- NEW FILE: tools.cpp --- // -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tools.h" namespace VBA { std::string sCutSuffix(const std::string & _sString, const std::string & _sSep) { return _sString.substr(0, _sString.find_last_of(_sSep)); } } // namespace VBA --- NEW FILE: Makefile.in --- # Makefile.in generated by automake 1.7.9 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ [...1550 lines suppressed...] ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-dist_pkgdataDATA \ uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-noinstLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dist_pkgdataDATA \ install-exec install-exec-am install-info install-info-am \ install-man install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-dist_pkgdataDATA uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE: screenarea.cpp --- // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "screenarea.h" #include <string.h> namespace VBA { ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) : m_puiPixels(NULL), m_puiDelta(NULL), m_vFilter2x(NULL) { g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); m_iWidth = _iWidth; m_iHeight = _iHeight; m_iScale = _iScale; vUpdateSize(); set_events(Gdk::EXPOSURE_MASK); } ScreenArea::~ScreenArea() { if (m_puiPixels != NULL) { delete[] m_puiPixels; } if (m_puiDelta != NULL) { delete[] m_puiDelta; } } 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 != m_iScale) { m_iScale = _iScale; vUpdateSize(); } } void ScreenArea::vSetFilter2x(Filter2x _vFilter2x) { m_vFilter2x = _vFilter2x; } void ScreenArea::vDrawPixels(const u8 * _puiData) { if (m_iScale == 1) { u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1; u32 * puiPixel = m_puiPixels; for (int y = 0; y < m_iHeight; y++) { for (int x = 0; x < m_iWidth; x++) { *puiPixel++ = *puiSrc++; } puiSrc++; } } else if (m_iScale == 2 && m_vFilter2x != NULL) { m_vFilter2x(const_cast<u8 *>(_puiData) + m_iAreaWidth * 2 + 4, m_iAreaWidth * 2 + 4, m_puiDelta, (u8 *)m_puiPixels, m_iRowStride, m_iWidth, m_iHeight); } else { u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1; u32 * puiSrc2; u32 * puiPixel = m_puiPixels; for (int y = 0; y < m_iHeight; y++) { for (int j = 0; j < m_iScale; j++) { puiSrc2 = puiSrc; for (int x = 0; x < m_iWidth; x++) { for (int i = 0; i < m_iScale; i++) { *puiPixel++ = *puiSrc2; } puiSrc2++; } } puiSrc = puiSrc2 + 1; } } queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight); } void ScreenArea::vDrawColor(u32 _uiColor) { _uiColor = GUINT32_TO_BE(_uiColor) << 8; u32 * puiPixel = m_puiPixels; u32 * puiEnd = m_puiPixels + m_iAreaWidth * m_iAreaHeight; while (puiPixel != puiEnd) { *puiPixel++ = _uiColor; } queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight); } bool ScreenArea::on_expose_event(GdkEventExpose * _pstEvent) { if (_pstEvent->area.x + _pstEvent->area.width > m_iAreaWidth || _pstEvent->area.y + _pstEvent->area.height > m_iAreaHeight) { return false; } guchar * puiAreaPixels = (guchar *)m_puiPixels; if (_pstEvent->area.x != 0) { puiAreaPixels += _pstEvent->area.x << 2; } if (_pstEvent->area.y != 0) { puiAreaPixels += _pstEvent->area.y * m_iRowStride; } get_window()->draw_rgb_32_image(get_style()->get_fg_gc(get_state()), _pstEvent->area.x, _pstEvent->area.y, _pstEvent->area.width, _pstEvent->area.height, Gdk::RGB_DITHER_MAX, puiAreaPixels, m_iRowStride); return true; } void ScreenArea::vUpdateSize() { if (m_puiPixels != NULL) { delete[] m_puiPixels; } if (m_puiDelta != NULL) { delete[] m_puiDelta; } m_iAreaWidth = m_iScale * m_iWidth; m_iAreaHeight = m_iScale * m_iHeight; m_iRowStride = m_iAreaWidth * 4; m_puiPixels = new u32[m_iAreaWidth * m_iAreaHeight]; m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * 4]; memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 4); set_size_request(m_iAreaWidth, m_iAreaHeight); } } // namespace VBA --- NEW FILE: filters.h --- // -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __VBA_FILTERS_H__ #define __VBA_FILTERS_H__ #include "../System.h" int Init_2xSaI(u32); void _2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int); void _2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int); void Super2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int); void Super2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int); void SuperEagle (u8 *, u32, u8 *, u8 *, u32, int, int); void SuperEagle32 (u8 *, u32, u8 *, u8 *, u32, int, int); void Pixelate (u8 *, u32, u8 *, u8 *, u32, int, int); void Pixelate32 (u8 *, u32, u8 *, u8 *, u32, int, int); void MotionBlur (u8 *, u32, u8 *, u8 *, u32, int, int); void MotionBlur32 (u8 *, u32, u8 *, u8 *, u32, int, int); void AdMame2x (u8 *, u32, u8 *, u8 *, u32, int, int); void AdMame2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); void Simple2x (u8 *, u32, u8 *, u8 *, u32, int, int); void Simple2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); void Bilinear (u8 *, u32, u8 *, u8 *, u32, int, int); void Bilinear32 (u8 *, u32, u8 *, u8 *, u32, int, int); void BilinearPlus (u8 *, u32, u8 *, u8 *, u32, int, int); void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int); void Scanlines (u8 *, u32, u8 *, u8 *, u32, int, int); void Scanlines32 (u8 *, u32, u8 *, u8 *, u32, int, int); void ScanlinesTV (u8 *, u32, u8 *, u8 *, u32, int, int); void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int); void hq2x (u8 *, u32, u8 *, u8 *, u32, int, int); void hq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); void lq2x (u8 *, u32, u8 *, u8 *, u32, int, int); void lq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); void SmartIB (u8 *, u32, int, int); void SmartIB32 (u8 *, u32, int, int); void MotionBlurIB (u8 *, u32, int, int); void MotionBlurIB32(u8 *, u32, int, int); typedef void (*Filter2x)(u8 *, u32, u8 *, u8 *, u32, int, int); typedef void (*FilterIB)(u8 *, u32, int, int); #endif // __VBA_FILTERS_H__ --- NEW FILE: vba.glade --- <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkWindow" id="MainWindow"> <property name="visible">True</property> <property name="title" translatable="yes">VisualBoyAdvance</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <child> <widget class="GtkVBox" id="vbox1"> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">0</property> <child> <widget class="GtkHandleBox" id="handlebox1"> <property name="visible">True</property> <property name="shadow_type">GTK_SHADOW_OUT</property> <property name="handle_position">GTK_POS_LEFT</property> <property name="snap_edge">GTK_POS_TOP</property> <child> <widget class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <child> <widget class="GtkMenuItem" id="FileMenu"> <property name="visible">True</property> <property name="label" translatable="yes">_File</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="FileMenu_menu"> <child> <widget class="GtkImageMenuItem" id="FileOpen"> <property name="visible">True</property> <property name="label">gtk-open</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkCheckMenuItem" id="FilePause"> <property name="visible">True</property> <property name="label" translatable="yes">_Pause</property> <property name="use_underline">True</property> <property name="active">False</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="FileReset"> <property name="visible">True</property> <property name="label" translatable="yes">_Reset</property> <property name="use_underline">True</property> <child internal-child="image"> <widget class="GtkImage" id="image2"> <property name="visible">True</property> <property name="stock">gtk-refresh</property> <property name="icon_size">1</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="separatormenuitem1"> <property name="visible">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="FileClose"> <property name="visible">True</property> <property name="label">gtk-close</property> <property name="use_stock">True</property> </widget> </child> <child> <widget class="GtkImageMenuItem" id="FileQuit"> <property name="visible">True</property> <property name="label">gtk-quit</property> <property name="use_stock">True</property> </widget> </child> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="VideoMenu"> <property name="visible">True</property> <property name="label" translatable="yes">_Video</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="VideoMenu_menu"> <child> <widget class="GtkMenuItem" id="VideoZoom"> <property name="visible">True</property> <property name="label" translatable="yes">_Zoom</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="VideoZoom_menu"> <child> <widget class="GtkRadioMenuItem" id="VideoZoom1x"> <property name="visible">True</property> <property name="label" translatable="yes">_1x</property> <property name="use_underline">True</property> <property name="active">False</property> </widget> </child> <child> <widget class="GtkRadioMenuItem" id="VideoZoom2x"> <property name="visible">True</property> <property name="label" translatable="yes">_2x</property> <property name="use_underline">True</property> <property name="active">False</property> <property name="group">VideoZoom1x</property> </widget> </child> <child> <widget class="GtkRadioMenuItem" id="VideoZoom3x"> <property name="visible">True</property> <property name="label" translatable="yes">_3x</property> <property name="use_underline">True</property> <property name="active">False</property> <property name="group">VideoZoom1x</property> </widget> </child> <child> <widget class="GtkRadioMenuItem" id="VideoZoom4x"> <property name="visible">True</property> <property name="label" translatable="yes">_4x</property> <property name="use_underline">True</property> <property name="active">False</property> <property name="group">VideoZoom1x</property> </widget> </child> </widget> </child> </widget> </child> </widget> </child> </widget> </child> <child> <widget class="GtkMenuItem" id="HelpMenu"> <property name="visible">True</property> <property name="label" translatable="yes">_Help</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="HelpMenu_menu"> <child> <widget class="GtkMenuItem" id="HelpAbout"> <property name="visible">True</property> <property name="label" translatable="yes">_About</property> <property name="use_underline">True</property> </widget> </child> </widget> </child> </widget> </child> </widget> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> </packing> </child> <child> <widget class="GtkAlignment" id="ScreenContainer"> <property name="visible">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xscale">0</property> <property name="yscale">0</property> <child> <placeholder/> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> </packing> </child> </widget> </child> </widget> <widget class="GtkDialog" id="AboutDialog"> <property name="title" translatable="yes">About VBA</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="has_separator">True</property> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog-vbox1"> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">0</property> <child internal-child="action_area"> <widget class="GtkHButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="layout_style">GTK_BUTTONBOX_END</property> <child> <widget class="GtkButton" id="closebutton1"> <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> <property name="label">gtk-close</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="response_id">-7</property> </widget> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> <property name="pack_type">GTK_PACK_END</property> </packing> </child> <child> <widget class="GtkLabel" id="VersionLabel"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes"></property> <property name="use_underline">False</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_CENTER</property> <property name="wrap">False</property> <property name="selectable">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">5</property> <property name="ypad">5</property> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">False</property> </packing> </child> <child> <widget class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">An emulator for Gameboy⢠and GameboyAdvanceâ¢.</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_CENTER</property> <property name="wrap">True</property> <property name="selectable">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">5</property> <property name="ypad">5</property> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">False</property> </packing> </child> <child> <widget class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes"><small>Copyright © 1999-2004 Forgotten</small></property> <property name="use_underline">False</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_CENTER</property> <property name="wrap">True</property> <property name="selectable">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">5</property> <property name="ypad">5</property> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">False</property> </packing> </child> </widget> </child> </widget> </glade-interface> --- NEW FILE: Makefile.am --- bin_PROGRAMS = gVisualBoyAdvance noinst_LIBRARIES = libgba.a gVisualBoyAdvance_SOURCES = \ filters.h \ input.cpp \ input.h \ intl.h \ main.cpp \ screenarea.cpp \ screenarea.h \ system.cpp \ tools.cpp \ tools.h \ window.cpp \ window.h gVisualBoyAdvance_LDADD = libgba.a @VBA_LIBS@ @GTKMM_LIBS@ @LIBINTL@ @SDL_LIBS@ gVisualBoyAdvance_CPPFLAGS = \ -DPKGDATADIR=\"$(pkgdatadir)\" \ -DLOCALEDIR=\"$(datadir)/locale\" \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" gVisualBoyAdvance_CXXFLAGS = @GTKMM_CFLAGS@ @SDL_CFLAGS@ libgba_a_SOURCES = \ ../2xSaI.cpp \ ../AutoBuild.h \ ../Cheats.cpp \ ../Cheats.h \ ../EEprom.cpp \ ../EEprom.h \ ../Flash.cpp \ ../Flash.h \ ../GBA.cpp \ ../GBA.h \ ../GBAinline.h \ ../Gfx.cpp \ ../Gfx.h \ ../Globals.cpp \ ../Globals.h \ ../Mode0.cpp \ ../Mode1.cpp \ ../Mode2.cpp \ ../Mode3.cpp \ ../Mode4.cpp \ ../Mode5.cpp \ ../NLS.h \ ../Port.h \ ../RTC.cpp \ ../RTC.h \ ../Sound.cpp \ ../Sound.h \ ../Sram.cpp \ ../Sram.h \ ../System.h \ ../Text.cpp \ ../Text.h \ ../Util.cpp \ ../Util.h \ ../admame.cpp \ ../agbprint.cpp \ ../agbprint.h \ ../arm-new.h \ ../armdis.cpp \ ../armdis.h \ ../bilinear.cpp \ ../bios.cpp \ ../bios.h \ ../elf.cpp \ ../elf.h \ ../getopt.c \ ../getopt.h \ ../getopt1.c \ ../hq2x.cpp \ ../hq2x.h \ ../interframe.cpp \ ../interp.h \ ../lq2x.h \ ../memgzio.c \ ../memgzio.h \ ../motionblur.cpp \ ../pixel.cpp \ ../remote.cpp \ ../scanline.cpp \ ../simple2x.cpp \ ../thumb.h \ ../unzip.cpp \ ../unzip.h libgba_a_CPPFLAGS = -DSDL libgba_a_CXXFLAGS = -fno-exceptions dist_pkgdata_DATA = vba.glade --- NEW FILE: system.cpp --- // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <stdio.h> #include <stdarg.h> #include <SDL.h> #include "../GBA.h" #include "../gb/GB.h" #include "../gb/gbGlobals.h" #include "../Util.h" #include "window.h" int systemRedShift; int systemGreenShift; int systemBlueShift; int systemColorDepth; int systemDebug; int systemVerbose; int systemSaveUpdateCounter; int systemFrameSkip; u32 systemColorMap32[0x10000]; u16 systemColorMap16[0x10000]; u16 systemGbPalette[24]; bool systemSoundOn; int emulating; bool debugger; 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); char * csMsg = g_strdup_vprintf(_csFormat, args); va_end(args); Gtk::MessageDialog oDialog(*gui(), csMsg, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); oDialog.run(); free(csMsg); } void systemDrawScreen() { gui()->vDrawScreen(); } bool systemReadJoypads() { return true; } u32 systemReadJoypad(int) { return gui()->uiReadJoypad(); } void systemShowSpeed(int _iSpeed) { char csTitle[50]; snprintf(csTitle, 50, "VisualBoyAdvance-%.3d%%", _iSpeed); gui()->set_title(csTitle); } void system10Frames(int _iRate) { } void systemFrame() { } void systemSetTitle(const char * _csTitle) { gui()->set_title(_csTitle); } void systemScreenCapture(int _iNum) { } void systemWriteDataToSoundBuffer() { } bool systemSoundInit() { return true; } void systemSoundShutdown() { } void systemSoundPause() { } void systemSoundResume() { } void systemSoundReset() { } u32 systemGetClock() { return SDL_GetTicks(); } void systemUpdateMotionSensor() { } int systemGetSensorX() { return 0; } int systemGetSensorY() { return 0; } void systemGbPrint(u8 * _puiData, int _iPages, int _iFeed, int _iPalette, int _iContrast) { } void systemScreenMessage(const char * _csMsg) { } bool systemCanChangeSoundQuality() { return false; } bool systemPauseOnFrame() { return false; } void systemGbBorderOn() { } void debuggerMain() { } void debuggerSignal(int, int) { } void debuggerOutput(char *, u32) { } void (*dbgMain)() = debuggerMain; void (*dbgSignal)(int, int) = debuggerSignal; void (*dbgOutput)(char *, u32) = debuggerOutput; --- NEW FILE: intl.h --- // -*- C++ -*- /* * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator * Copyrigh(c) 1999-2002 Forgotten (vb...@em...) * * 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 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __VBA_INTL_H__ #define __VBA_INTL_H__ #ifndef GETTEXT_PACKAGE # error "GETTEXT_PACKAGE must be defined" #endif #ifdef ENABLE_NLS # include <libintl.h> # define _(String) gettext(String) # define N_(String) (String) #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__ --- NEW FILE: window.h --- // -*- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __VBA_WINDOW_H__ #define __VBA_WINDOW_H__ #include <libglademm.h> #include <gtkmm.h> #include <string> #include "screenarea.h" #include "input.h" #include "filters.h" namespace VBA { class Window : public Gtk::Window { friend class Gnome::Glade::Xml; public: inline static Window * poGetInstance() { return m_poInstance; } void vDrawScreen(); inline u32 uiReadJoypad() { return m_uiJoypadState; } enum ECartridge { NO_CARTRIDGE, GB_CARTRIDGE, GBA_CARTRIDGE }; inline ECartridge eGetCartridge() { return m_eCartridge; } protected: virtual bool on_key_press_event(GdkEventKey * _pstEvent); virtual bool on_key_release_event(GdkEventKey * _pstEvent); private: Window(GtkWindow * _pstWindow, const Glib::RefPtr<Gnome::Glade::Xml> & _poXml); ~Window(); static Window * m_poInstance; Gtk::FileSelection * m_poFileOpenDialog; ScreenArea * m_poScreenArea; Gtk::CheckMenuItem * m_poFilePauseItem; SigC::Connection m_oEmuSig; std::string m_sFilename; ECartridge m_eCartridge; EmulatedSystem m_stEmulator; Keymap m_oKeymap; u32 m_uiJoypadState; int m_iScreenWidth; int m_iScreenHeight; int m_iScreenScale; Filter2x m_vFilter2x; FilterIB m_vFilterIB; void vInitSystem(); void vInitSDL(); void vLoadKeymap(); void vUpdateScreen(); void vDrawDefaultScreen(); bool bLoadROM(const std::string & _rsFilename); void vLoadBattery(); void vSaveBattery(); void vLoadState(int _iNum); void vSaveState(int _iNum); void vStartEmu(); void vStopEmu(); void vOnFileOpen(); void vOnFilePause(); void vOnFileReset(); void vOnFileClose(); void vOnFileQuit(); void vOnVideoZoom1x(); void vOnVideoZoom2x(); void vOnVideoZoom3x(); void vOnVideoZoom4x(); void vOnHelpAbout(); bool bOnEmuIdle(); }; } // namespace VBA #endif // __VBA_WINDOW_H__ --- NEW FILE: window.cpp --- // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "window.h" #include <SDL.h> #include "../GBA.h" #include "../gb/GB.h" #include "../gb/gbGlobals.h" #include "../Util.h" #include "tools.h" #include "intl.h" extern bool debugger; extern int RGB_LOW_BITS_MASK; namespace VBA { using Gnome::Glade::Xml; Window * Window::m_poInstance = NULL; const int iGBScreenWidth = 160; const int iGBScreenHeight = 144; const int iSGBScreenWidth = 256; const int iSGBScreenHeight = 224; const int iGBAScreenWidth = 240; const int iGBAScreenHeight = 160; Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) : Gtk::Window(_pstWindow), m_poFileOpenDialog(NULL), m_eCartridge(NO_CARTRIDGE), m_uiJoypadState(0), m_iScreenWidth(iGBAScreenWidth), m_iScreenHeight(iGBAScreenHeight), m_iScreenScale(1), m_vFilter2x(NULL), m_vFilterIB(NULL) { vInitSystem(); vInitSDL(); vLoadKeymap(); Gtk::Container * poC; poC = dynamic_cast<Gtk::Container *>(_poXml->get_widget("ScreenContainer")); m_poScreenArea = Gtk::manage(new ScreenArea(m_iScreenWidth, m_iScreenHeight)); poC->add(*m_poScreenArea); vDrawDefaultScreen(); m_poScreenArea->vSetFilter2x(SuperEagle32); // TEST m_poScreenArea->show(); m_poFilePauseItem = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget("FilePause")); m_poFilePauseItem->signal_toggled().connect(SigC::slot(*this, &Window::vOnFilePause)); Gtk::MenuItem * poMI; poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileOpen")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileOpen)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileReset")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileReset)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileClose")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileClose)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileQuit")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileQuit)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoZoom1x")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnVideoZoom1x)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoZoom2x")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnVideoZoom2x)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoZoom3x")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnVideoZoom3x)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoZoom4x")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnVideoZoom4x)); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("HelpAbout")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnHelpAbout)); if (m_poInstance == NULL) { m_poInstance = this; } else { abort(); } } Window::~Window() { vOnFileClose(); if (m_poFileOpenDialog != NULL) { delete m_poFileOpenDialog; } m_poInstance = NULL; } void Window::vInitSystem() { Init_2xSaI(32); #if G_BYTE_ORDER == G_LITTLE_ENDIAN systemRedShift = 3; systemGreenShift = 11; systemBlueShift = 19; RGB_LOW_BITS_MASK = 0x00010101; #else systemRedShift = 27; systemGreenShift = 19; systemBlueShift = 11; RGB_LOW_BITS_MASK = 0x01010100; #endif systemColorDepth = 32; systemDebug = 0; systemVerbose = 0; systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; systemFrameSkip = 5; // TEST systemSoundOn = false; emulating = 0; debugger = true; for (int i = 0; i < 0x10000; i++) { #if G_BYTE_ORDER == G_LITTLE_ENDIAN systemColorMap32[i] = (((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift) | 0xff000000); #else systemColorMap32[i] = (((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift) | 0xff); #endif } // TODO : GB init and 16-bit color map (?) } void Window::vInitSDL() { static bool bDone = false; if (bDone) return; int iFlags = (SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); if (SDL_Init(iFlags) < 0) { fprintf(stderr, "Failed to init SDL: %s", SDL_GetError()); abort(); } bDone = true; } void Window::vLoadKeymap() { // TODO : load from prefs m_oKeymap.vRegister(GDK_z, KEY_A); m_oKeymap.vRegister(GDK_Z, KEY_A); m_oKeymap.vRegister(GDK_x, KEY_B); m_oKeymap.vRegister(GDK_X, KEY_B); m_oKeymap.vRegister(GDK_BackSpace, KEY_SELECT); m_oKeymap.vRegister(GDK_Return, KEY_START); m_oKeymap.vRegister(GDK_Right, KEY_RIGHT); m_oKeymap.vRegister(GDK_Left, KEY_LEFT); m_oKeymap.vRegister(GDK_Up, KEY_UP); m_oKeymap.vRegister(GDK_Down, KEY_DOWN); m_oKeymap.vRegister(GDK_s, KEY_R); m_oKeymap.vRegister(GDK_S, KEY_R); m_oKeymap.vRegister(GDK_a, KEY_L); m_oKeymap.vRegister(GDK_A, KEY_L); m_oKeymap.vRegister(GDK_space, KEY_SPEED); m_oKeymap.vRegister(GDK_F12, KEY_CAPTURE); } void Window::vUpdateScreen() { g_return_if_fail(m_iScreenWidth >= 1 && m_iScreenHeight >= 1 && m_iScreenScale >= 1); m_poScreenArea->vSetSize(m_iScreenWidth, m_iScreenHeight); m_poScreenArea->vSetScale(m_iScreenScale); resize(1, 1); if (emulating) { vDrawScreen(); } else { vDrawDefaultScreen(); } } void Window::vDrawScreen() { m_poScreenArea->vDrawPixels(pix); } void Window::vDrawDefaultScreen() { m_poScreenArea->vDrawColor(0x000000); // Black } bool Window::bLoadROM(const std::string & _rsFilename) { vOnFileClose(); m_sFilename = _rsFilename; const char * csFilename = _rsFilename.c_str(); IMAGE_TYPE eType = utilFindType(csFilename); if (eType == IMAGE_UNKNOWN) { systemMessage(0, _("Unknown file type %s"), csFilename); return false; } bool bLoaded = false; if (eType == IMAGE_GB) { bLoaded = gbLoadRom(csFilename); if (bLoaded) { m_eCartridge = GB_CARTRIDGE; m_stEmulator = GBSystem; //if(sdlAutoIPS) { // int size = gbRomSize; // utilApplyIPS(ipsname, &gbRom, &size); // if(size != gbRomSize) { // extern bool gbUpdateSizes(); // gbUpdateSizes(); // gbReset(); // } //} if (gbBorderOn) { m_iScreenWidth = iSGBScreenWidth; m_iScreenHeight = iSGBScreenHeight; gbBorderLineSkip = iSGBScreenWidth; gbBorderColumnSkip = (iSGBScreenWidth - iGBScreenWidth) / 2; gbBorderRowSkip = (iSGBScreenHeight - iGBScreenHeight) / 2; } else { m_iScreenWidth = iGBScreenWidth; m_iScreenHeight = iGBScreenHeight; gbBorderLineSkip = iGBScreenWidth; gbBorderColumnSkip = 0; gbBorderRowSkip = 0; } // TODO //systemFrameSkip = gbFrameSkip; } } else if (eType == IMAGE_GBA) { int iSize = CPULoadRom(csFilename); bLoaded = (iSize > 0); if (bLoaded) { //sdlApplyPerImagePreferences(); m_eCartridge = GBA_CARTRIDGE; m_stEmulator = GBASystem; // TODO //CPUInit(biosFileName, useBios); useBios = false; CPUInit(NULL, useBios); CPUReset(); //if(sdlAutoIPS) { // int size = 0x2000000; // utilApplyIPS(ipsname, &rom, &size); // if(size != 0x2000000) { // CPUReset(); // } //} m_iScreenWidth = iGBAScreenWidth; m_iScreenHeight = iGBAScreenHeight; // TODO //systemFrameSkip = frameSkip; } } if (! bLoaded) { systemMessage(0, _("Failed to load file %s"), csFilename); return false; } vLoadBattery(); vUpdateScreen(); emulating = 1; if (m_poFilePauseItem->get_active()) { m_poFilePauseItem->set_active(false); } else { vStartEmu(); } return true; } void Window::vLoadBattery() { // TODO : from battery dir std::string sBattery = sCutSuffix(m_sFilename) + ".sav"; if (m_stEmulator.emuReadBattery(sBattery.c_str())) { systemScreenMessage(_("Loaded battery")); } } void Window::vSaveBattery() { // TODO : from battery dir std::string sBattery = sCutSuffix(m_sFilename) + ".sav"; if (m_stEmulator.emuWriteBattery(sBattery.c_str())) { systemScreenMessage(_("Saved battery")); } } void Window::vLoadState(int _iNum) { // TODO } void Window::vSaveState(int _iNum) { // TODO } void Window::vStartEmu() { if (m_oEmuSig.connected()) { return; } m_oEmuSig = Glib::signal_idle().connect(SigC::slot(*this, &Window::bOnEmuIdle), Glib::PRIORITY_DEFAULT_IDLE); } void Window::vStopEmu() { m_oEmuSig.disconnect(); } void Window::vOnFileOpen() { if (m_poFileOpenDialog == NULL) { m_poFileOpenDialog = new Gtk::FileSelection(_("Open a ROM")); } m_poFileOpenDialog->show(); int iResponse = m_poFileOpenDialog->run(); if (iResponse == Gtk::RESPONSE_OK) { if (! bLoadROM(m_poFileOpenDialog->get_filename())) { return; } } m_poFileOpenDialog->hide(); } void Window::vOnFilePause() { if (emulating) { if (m_poFilePauseItem->get_active()) { vStopEmu(); } else { vStartEmu(); } } } void Window::vOnFileReset() { if (emulating) { m_stEmulator.emuReset(); } } void Window::vOnFileClose() { if (emulating) { vSaveBattery(); m_stEmulator.emuCleanUp(); emulating = 0; } m_eCartridge = NO_CARTRIDGE; vStopEmu(); vDrawDefaultScreen(); } void Window::vOnFileQuit() { hide(); } void Window::vOnVideoZoom1x() { m_iScreenScale = 1; vUpdateScreen(); } void Window::vOnVideoZoom2x() { m_iScreenScale = 2; vUpdateScreen(); } void Window::vOnVideoZoom3x() { m_iScreenScale = 3; vUpdateScreen(); } void Window::vOnVideoZoom4x() { m_iScreenScale = 4; vUpdateScreen(); } void Window::vOnHelpAbout() { Glib::RefPtr<Xml> poXml; poXml = Xml::create(PKGDATADIR "/vba.glade", "AboutDialog"); Gtk::Dialog * poDialog = dynamic_cast<Gtk::Dialog *>(poXml->get_widget("AboutDialog")); Gtk::Label * poLabel = dynamic_cast<Gtk::Label *>(poXml->get_widget("VersionLabel")); poLabel->set_markup("<b><big>" PACKAGE " " VERSION "</big></b>"); poDialog->run(); delete poDialog; } bool Window::bOnEmuIdle() { if (emulating) { m_stEmulator.emuMain(m_stEmulator.emuCount); } return true; } bool Window::on_key_press_event(GdkEventKey * _pstEvent) { EKey eKey; if ((_pstEvent->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) || (eKey = m_oKeymap.eGetKey(_pstEvent->keyval)) == KEY_NONE) { return Gtk::Window::on_key_press_event(_pstEvent); } switch (eKey) { case KEY_A: m_uiJoypadState |= KEYFLAG_A; break; case KEY_B: m_uiJoypadState |= KEYFLAG_B; break; case KEY_SELECT: m_uiJoypadState |= KEYFLAG_SELECT; break; case KEY_START: m_uiJoypadState |= KEYFLAG_START; break; case KEY_RIGHT: m_uiJoypadState |= KEYFLAG_RIGHT; m_uiJoypadState &= ~KEYFLAG_LEFT; break; case KEY_LEFT: m_uiJoypadState |= KEYFLAG_LEFT; m_uiJoypadState &= ~KEYFLAG_RIGHT; break; case KEY_UP: m_uiJoypadState |= KEYFLAG_UP; m_uiJoypadState &= ~KEYFLAG_DOWN; break; case KEY_DOWN: m_uiJoypadState |= KEYFLAG_DOWN; m_uiJoypadState &= ~KEYFLAG_UP; break; case KEY_R: m_uiJoypadState |= KEYFLAG_R; break; case KEY_L: m_uiJoypadState |= KEYFLAG_L; break; case KEY_SPEED: m_uiJoypadState |= KEYFLAG_SPEED; break; case KEY_CAPTURE: m_uiJoypadState |= KEYFLAG_CAPTURE; break; case KEY_NONE: break; } return true; } bool Window::on_key_release_event(GdkEventKey * _pstEvent) { EKey eKey; if ((_pstEvent->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) || (eKey = m_oKeymap.eGetKey(_pstEvent->keyval)) == KEY_NONE) { return Gtk::Window::on_key_press_event(_pstEvent); } switch (eKey) { case KEY_A: m_uiJoypadState &= ~KEYFLAG_A; break; case KEY_B: m_uiJoypadState &= ~KEYFLAG_B; break; case KEY_SELECT: m_uiJoypadState &= ~KEYFLAG_SELECT; break; case KEY_START: m_uiJoypadState &= ~KEYFLAG_START; break; case KEY_RIGHT: m_uiJoypadState &= ~KEYFLAG_RIGHT; break; case KEY_LEFT: m_uiJoypadState &= ~KEYFLAG_LEFT; break; case KEY_UP: m_uiJoypadState &= ~KEYFLAG_UP; break; case KEY_DOWN: m_uiJoypadState &= ~KEYFLAG_DOWN; break; case KEY_R: m_uiJoypadState &= ~KEYFLAG_R; break; case KEY_L: m_uiJoypadState &= ~KEYFLAG_L; break; case KEY_SPEED: m_uiJoypadState &= ~KEYFLAG_SPEED; break; case KEY_CAPTURE: m_uiJoypadState &= ~KEYFLAG_CAPTURE; break; case KEY_NONE: break; } return true; } } // VBA namespace --- NEW FILE: input.cpp --- // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "input.h" #include <new> namespace VBA { Keymap::Keymap() { m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal); if (m_pstTable == NULL) { throw std::bad_alloc(); } } Keymap::~Keymap() { g_hash_table_destroy(m_pstTable); } void Keymap::vRegister(guint _uiVal, EKey _eKey) { g_hash_table_insert(m_pstTable, GUINT_TO_POINTER(_uiVal), GUINT_TO_POINTER(_eKey)); } void Keymap::vClear() { g_hash_table_destroy(m_pstTable); m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal); } } // namespace VBA |