From 5a3017d0823bcbee7e795b06bd89947751558e2d Mon Sep 17 00:00:00 2001 From: sergiobenrocha2 Date: Mon, 27 Jul 2015 18:18:11 -0300 Subject: [PATCH 01/58] Add debian packaging. --- tools/debian/changelog | 5 + tools/debian/clean | 2 + tools/debian/compat | 1 + tools/debian/control | 78 +++++ tools/debian/copyright | 472 ++++++++++++++++++++++++++ tools/debian/docs | 2 + tools/debian/libmgba.install.in | 1 + tools/debian/libretro-mgba.install.in | 1 + tools/debian/mgba-qt.install | 3 + tools/debian/mgba-sdl.install | 1 + tools/debian/rules | 22 ++ tools/debian/source/format | 1 + tools/debian/watch | 3 + 13 files changed, 592 insertions(+) create mode 100644 tools/debian/changelog create mode 100644 tools/debian/clean create mode 100644 tools/debian/compat create mode 100644 tools/debian/control create mode 100644 tools/debian/copyright create mode 100644 tools/debian/docs create mode 100644 tools/debian/libmgba.install.in create mode 100644 tools/debian/libretro-mgba.install.in create mode 100644 tools/debian/mgba-qt.install create mode 100644 tools/debian/mgba-sdl.install create mode 100755 tools/debian/rules create mode 100644 tools/debian/source/format create mode 100644 tools/debian/watch diff --git a/tools/debian/changelog b/tools/debian/changelog new file mode 100644 index 000000000..0b703b13a --- /dev/null +++ b/tools/debian/changelog @@ -0,0 +1,5 @@ +mgba (0.2.1-1) UNRELEASED; urgency=low + + * Initial release (closes: Bug#787470). + + -- Sérgio Benjamim Mon, 01 Jun 2015 18:40:00 -0300 diff --git a/tools/debian/clean b/tools/debian/clean new file mode 100644 index 000000000..d5cc2a095 --- /dev/null +++ b/tools/debian/clean @@ -0,0 +1,2 @@ +debian/libmgba.install +debian/libretro-mgba.install diff --git a/tools/debian/compat b/tools/debian/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/tools/debian/compat @@ -0,0 +1 @@ +9 diff --git a/tools/debian/control b/tools/debian/control new file mode 100644 index 000000000..747d284f9 --- /dev/null +++ b/tools/debian/control @@ -0,0 +1,78 @@ +Source: mgba +Section: otherosfs +Priority: extra +Maintainer: Sérgio Benjamim +Build-Depends: cmake (>= 2.8.11), + debhelper (>= 9), + libavcodec-dev, + libavformat-dev, + libavresample-dev, + libavutil-dev, + libedit-dev, + libmagickwand-dev, + libpng-dev, + libqt5opengl5-dev, + libsdl2-dev, + libswscale-dev, + libzip-dev, + pkg-config, + qtbase5-dev, + qtmultimedia5-dev, + zlib1g-dev +Standards-Version: 3.9.6 +Homepage: https://endrift.com/mgba/ + +Package: libmgba +Architecture: any +Multi-Arch: same +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: Game Boy Advance emulator (common library for mGBA) + mGBA is a new emulator for running Game Boy Advance games. It aims to be faster + and more accurate than many existing Game Boy Advance emulators, as well as + adding features that other emulators lack. + . + This package provides the common library for mGBA. + . + Game Boy Advance is a registered trademark of Nintendo of America Inc. mGBA is + not affiliated with or endorsed by any of the companies mentioned. + +Package: mgba-qt +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: Game Boy Advance emulator (Qt frontend for mGBA) + mGBA is a new emulator for running Game Boy Advance games. It aims to be faster + and more accurate than many existing Game Boy Advance emulators, as well as + adding features that other emulators lack. + . + This package provides the Qt GUI frontend for mGBA. + . + Game Boy Advance is a registered trademark of Nintendo of America Inc. mGBA is + not affiliated with or endorsed by any of the companies mentioned. + +Package: mgba-sdl +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: Game Boy Advance emulator (SDL frontend for mGBA) + mGBA is a new emulator for running Game Boy Advance games. It aims to be faster + and more accurate than many existing Game Boy Advance emulators, as well as + adding features that other emulators lack. + . + This package provides the SDL UI console for mGBA. + . + Game Boy Advance is a registered trademark of Nintendo of America Inc. mGBA is + not affiliated with or endorsed by any of the companies mentioned. + +Package: libretro-mgba +Architecture: any +Multi-Arch: same +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: Libretro wrapper for mGBA + This wrapper makes mGBA API compatible with libretro, thus allowing its use + with libretro frontends, such as RetroArch. + . + mGBA is a new emulator for running Game Boy Advance games. It aims to be faster + and more accurate than many existing Game Boy Advance emulators, as well as + adding features that other emulators lack. + . + Game Boy Advance is a registered trademark of Nintendo of America Inc. mGBA is + not affiliated with or endorsed by any of the companies mentioned. diff --git a/tools/debian/copyright b/tools/debian/copyright new file mode 100644 index 000000000..75a308d13 --- /dev/null +++ b/tools/debian/copyright @@ -0,0 +1,472 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: mGBA +Upstream-Contact: Jeffrey Pfau (aka endrift) +Source: https://github.com/mgba-emu/mgba +Comment: This package was debianized by + Sergio Benjamim (sergio-br2) on Mon, 01 Jun 2015 18:40:00 -0300 + + +Files: * +Copyright: 2013-2015 Jeffrey Pfau +License: MPL-2.0 + +Files: src/third-party/blip_buf/* +Copyright: 2003-2009 Shay Green +License: LGPL-2.1+ + +Files: src/third-party/inih/* +Copyright: 2009 Brush Technology. All rights reserved. +License: BSD-3-clause-Brush-Technology + +Files: src/third-party/lzma/* +Copyright: 2008-2015 Igor Pavlov +License: public-domain + These files have been put in the public domain by their author + +Files: src/platform/libretro/libretro.h +Copyright: 2010-2015 The RetroArch Team +License: Expat + +Files: debian/* +Copyright: 2015 Sergio Benjamim (sergio-br2) +License: MPL-2.0 + + +License: MPL-2.0 + Mozilla Public License Version 2.0 + ================================== + . + 1. Definitions + -------------- + . + 1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + . + 1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + . + 1.3. "Contribution" + means Covered Software of a particular Contributor. + . + 1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + . + 1.5. "Incompatible With Secondary Licenses" + means + . + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + . + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + . + 1.6. "Executable Form" + means any form of the work other than Source Code Form. + . + 1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + . + 1.8. "License" + means this document. + . + 1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + . + 1.10. "Modifications" + means any of the following: + . + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + . + (b) any new file in Source Code Form that contains any Covered + Software. + . + 1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + . + 1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + . + 1.13. "Source Code Form" + means the form of the work preferred for making modifications. + . + 1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + . + 2. License Grants and Conditions + -------------------------------- + . + 2.1. Grants + . + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + . + (a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + . + (b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + . + 2.2. Effective Date + . + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + . + 2.3. Limitations on Grant Scope + . + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + . + (a) for any code that a Contributor has removed from Covered Software; + or + . + (b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + . + (c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + . + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + . + 2.4. Subsequent Licenses + . + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + . + 2.5. Representation + . + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights + to grant the rights to its Contributions conveyed by this License. + . + 2.6. Fair Use + . + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + . + 2.7. Conditions + . + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted + in Section 2.1. + . + 3. Responsibilities + ------------------- + . + 3.1. Distribution of Source Form + . + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + . + 3.2. Distribution of Executable Form + . + If You distribute Covered Software in Executable Form then: + . + (a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + . + (b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + . + 3.3. Distribution of a Larger Work + . + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + . + 3.4. Notices + . + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, + or limitations of liability) contained within the Source Code Form of + the Covered Software, except that You may alter any license notices to + the extent required to remedy known factual inaccuracies. + . + 3.5. Application of Additional Terms + . + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + . + 4. Inability to Comply Due to Statute or Regulation + --------------------------------------------------- + . + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Software due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description must + be placed in a text file included with all distributions of the Covered + Software under this License. Except to the extent prohibited by statute + or regulation, such description must be sufficiently detailed for a + recipient of ordinary skill to be able to understand it. + . + 5. Termination + -------------- + . + 5.1. The rights granted under this License will terminate automatically + if You fail to comply with any of its terms. However, if You become + compliant, then the rights granted under this License from a particular + Contributor are reinstated (a) provisionally, unless and until such + Contributor explicitly and finally terminates Your grants, and (b) on an + ongoing basis, if such Contributor fails to notify You of the + non-compliance by some reasonable means prior to 60 days after You have + come back into compliance. Moreover, Your grants from a particular + Contributor are reinstated on an ongoing basis if such Contributor + notifies You of the non-compliance by some reasonable means, this is the + first time You have received notice of non-compliance with this License + from such Contributor, and You become compliant prior to 30 days after + Your receipt of the notice. + . + 5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + . + 5.3. In the event of termination under Sections 5.1 or 5.2 above, all + end user license agreements (excluding distributors and resellers) which + have been validly granted by You or Your distributors under this License + prior to termination shall survive termination. + . + ************************************************************************ + * * + * 6. Disclaimer of Warranty * + * ------------------------- * + * * + * Covered Software is provided under this License on an "as is" * + * basis, without warranty of any kind, either expressed, implied, or * + * statutory, including, without limitation, warranties that the * + * Covered Software is free of defects, merchantable, fit for a * + * particular purpose or non-infringing. The entire risk as to the * + * quality and performance of the Covered Software is with You. * + * Should any Covered Software prove defective in any respect, You * + * (not any Contributor) assume the cost of any necessary servicing, * + * repair, or correction. This disclaimer of warranty constitutes an * + * essential part of this License. No use of any Covered Software is * + * authorized under this License except under this disclaimer. * + * * + ************************************************************************ + . + ************************************************************************ + * * + * 7. Limitation of Liability * + * -------------------------- * + * * + * Under no circumstances and under no legal theory, whether tort * + * (including negligence), contract, or otherwise, shall any * + * Contributor, or anyone who distributes Covered Software as * + * permitted above, be liable to You for any direct, indirect, * + * special, incidental, or consequential damages of any character * + * including, without limitation, damages for lost profits, loss of * + * goodwill, work stoppage, computer failure or malfunction, or any * + * and all other commercial damages or losses, even if such party * + * shall have been informed of the possibility of such damages. This * + * limitation of liability shall not apply to liability for death or * + * personal injury resulting from such party's negligence to the * + * extent applicable law prohibits such limitation. Some * + * jurisdictions do not allow the exclusion or limitation of * + * incidental or consequential damages, so this exclusion and * + * limitation may not apply to You. * + * * + ************************************************************************ + . + 8. Litigation + ------------- + . + Any litigation relating to this License may be brought only in the + courts of a jurisdiction where the defendant maintains its principal + place of business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. + Nothing in this Section shall prevent a party's ability to bring + cross-claims or counter-claims. + . + 9. Miscellaneous + ---------------- + . + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides + that the language of a contract shall be construed against the drafter + shall not be used to construe this License against a Contributor. + . + 10. Versions of the License + --------------------------- + . + 10.1. New Versions + . + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + . + 10.2. Effect of New Versions + . + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + . + 10.3. Modified Versions + . + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + . + 10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses + . + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + . + Exhibit A - Source Code Form License Notice + ------------------------------------------- + . + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + . + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to look + for such a notice. + . + You may add additional accurate notices of copyright ownership. + . + Exhibit B - "Incompatible With Secondary Licenses" Notice + --------------------------------------------------------- + . + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + + +License: BSD-3-clause-Brush-Technology + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Brush Technology nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + +License: LGPL-2.1+ + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + . + This library 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 + Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + . + On Debian systems, the full text of the GNU Lesser General Public + License version 2.1 can be found in the file + `/usr/share/common-licenses/LGPL-2.1'. diff --git a/tools/debian/docs b/tools/debian/docs new file mode 100644 index 000000000..77001cf9b --- /dev/null +++ b/tools/debian/docs @@ -0,0 +1,2 @@ +README.md +CHANGES diff --git a/tools/debian/libmgba.install.in b/tools/debian/libmgba.install.in new file mode 100644 index 000000000..f29fc8c85 --- /dev/null +++ b/tools/debian/libmgba.install.in @@ -0,0 +1 @@ +obj/libmgba.so* usr/lib/@DEB_HOST_MULTIARCH@/ diff --git a/tools/debian/libretro-mgba.install.in b/tools/debian/libretro-mgba.install.in new file mode 100644 index 000000000..4f15c2df0 --- /dev/null +++ b/tools/debian/libretro-mgba.install.in @@ -0,0 +1 @@ +obj/mgba_libretro.so usr/lib/@DEB_HOST_MULTIARCH@/libretro diff --git a/tools/debian/mgba-qt.install b/tools/debian/mgba-qt.install new file mode 100644 index 000000000..c17eafba0 --- /dev/null +++ b/tools/debian/mgba-qt.install @@ -0,0 +1,3 @@ +usr/bin/mgba-qt +usr/share/applications/mgba-qt.desktop +usr/share/icons diff --git a/tools/debian/mgba-sdl.install b/tools/debian/mgba-sdl.install new file mode 100644 index 000000000..104a1b436 --- /dev/null +++ b/tools/debian/mgba-sdl.install @@ -0,0 +1 @@ +usr/bin/mgba diff --git a/tools/debian/rules b/tools/debian/rules new file mode 100755 index 000000000..0c82ec22e --- /dev/null +++ b/tools/debian/rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +# Copyright (C) 2015 Sergio Benjamim + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +%: + dh $@ --buildsystem=cmake --builddirectory=obj --parallel + +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_SKIP_RPATH=ON -DBUILD_LIBRETRO=ON + sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \ + debian/libretro-mgba.install.in > debian/libretro-mgba.install + sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \ + debian/libmgba.install.in > debian/libmgba.install + +override_dh_installchangelogs: + dh_installchangelogs -k CHANGES diff --git a/tools/debian/source/format b/tools/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/tools/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/tools/debian/watch b/tools/debian/watch new file mode 100644 index 000000000..90bf499e4 --- /dev/null +++ b/tools/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/mgba-$1\.tar\.gz/ \ + https://github.com/mgba-emu/mgba/tags .*/v?(\d\S*)\.tar\.gz From 717e5b5b89bdf505df35fbe702df22270beca594 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Wed, 29 Jul 2015 00:41:00 -0600 Subject: [PATCH 02/58] SDL: Add a manpage --- doc/mgba.6 | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 doc/mgba.6 diff --git a/doc/mgba.6 b/doc/mgba.6 new file mode 100644 index 000000000..88452e933 --- /dev/null +++ b/doc/mgba.6 @@ -0,0 +1,99 @@ +.\" Copyright (c) 2015 Anthony J. Bentley +.\" +.\" This Source Code Form is subject to the terms of the Mozilla Public +.\" License, v. 2.0. If a copy of the MPL was not distributed with this +.\" file, you can obtain one at https://mozilla.org/MPL/2.0/. +.Dd July 29, 2015 +.Dt MGBA 6 +.Os +.Sh NAME +.Nm mgba +.Nd Game Boy Advance emulator +.Sh SYNOPSIS +.Nm mgba +.Op Fl 123456dfg +.Op Fl b Ar biosfile +.Op Fl c Ar cheatfile +.Op Fl p Ar patchfile +.Op Fl s Ar n +.Op Fl v Ar moviefile +.Ar file +.Sh DESCRIPTION +.Nm +is a Game Boy Advance emulator. +The options are as follows: +.Bl -tag -width Ds +.It Fl 1 +Scale the window 1\(mu. +.It Fl 2 +Scale the window 2\(mu. +.It Fl 3 +Scale the window 3\(mu. +.It Fl 4 +Scale the window 4\(mu. +.It Fl 5 +Scale the window 5\(mu. +.It Fl 6 +Scale the window 6\(mu. +.It Fl b Ar biosfile , Fl -bios Ar biosfile +Specify a BIOS file to use during boot. +If this flag is omitted, +.Nm +will use a high\(hylevel emulated BIOS. +.It Fl c Ar cheatfile , Fl -cheats Ar cheatfile +Apply cheat codes from +.Ar cheatfile . +.It Fl d +Start emulating via the command\(hyline debugger. +.It Fl f +Start the emulator full\(hyscreen. +.It Fl g +Start a +.Xr gdb 1 +session. +By default the session starts on port 2345. +.It Fl p Ar patchfile , Fl -patch Ar patchfile +Specify a patch file in IPS or UPS format. +.It Fl s Ar n , Fl -frameskip Ar n +Skip every +.Ar n +frames. +.It Fl v Ar moviefile , Fl -movie Ar moviefile +Play back a movie of recording input from +.Ar moviefile . +.El +.Sh CONTROLS +The default controls are as follows: +.Bl -hang -width Select -compact +.It A +.Cm x +.It B +.Cm z +.It L +.Cm a +.It R +.Cm s +.It Start +.Aq Cm Enter +.It Select +.Aq Cm Backspace +.It Load state +.Cm F1 Ns \(en Ns Cm F9 +.It Save state +.Ao Cm Shift Ac Ns \(hy Ns Cm F1 Ns \(en Ns Cm F9 +.It Frame advance +.Ao Cm Ctrl Ac Ns \(hy Ns Cm n +.El +.Sh AUTHORS +.An Jeffrey Pfau Aq Mt jeffrey@endrift.com +.Sh HOMEPAGE +.Bl -bullet +.It +.Lk https://endrift.com/mgba/ "mGBA homepage" +.It +.Lk https://github.com/mgba-emu/mgba "Development repository" +.It +.Lk https://endrift.com/mgba/bugs/ "Bug tracker" +.It +.Lk https://forums.mgba.io/ "Message board" +.El From 5a66261d1d7b83df7ba056cc86eb9e1c4824a566 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Wed, 29 Jul 2015 01:22:36 -0600 Subject: [PATCH 03/58] SDL: Update URLs in documentation --- doc/mgba.6 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 88452e933..39590d4a6 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -89,11 +89,11 @@ The default controls are as follows: .Sh HOMEPAGE .Bl -bullet .It -.Lk https://endrift.com/mgba/ "mGBA homepage" +.Lk https://mgba.io/ "mGBA homepage" .It .Lk https://github.com/mgba-emu/mgba "Development repository" .It -.Lk https://endrift.com/mgba/bugs/ "Bug tracker" +.Lk https://github.com/mgba-emu/mgba/issues "Bug tracker" .It .Lk https://forums.mgba.io/ "Message board" .El From 341ab1ea75d5b8ee58ecf6cb724d697e1ea93626 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Wed, 29 Jul 2015 02:03:35 -0600 Subject: [PATCH 04/58] SDL: Document debugger commands --- doc/mgba.6 | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 39590d4a6..3d12ea685 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -64,7 +64,7 @@ Play back a movie of recording input from .El .Sh CONTROLS The default controls are as follows: -.Bl -hang -width Select -compact +.Bl -hang -width "Frame advance" -compact .It A .Cm x .It B @@ -84,6 +84,79 @@ The default controls are as follows: .It Frame advance .Ao Cm Ctrl Ac Ns \(hy Ns Cm n .El +.Sh DEBUGGER +When +.Nm +is run with the +.Fl d +option, the command\(hyline debugger is enabled. +It supports the following commands: +.Pp +.Bl -tag -compact -width 1 +.It Cm b Ns Oo Cm reak Oc Ar address +.It Cm b Ns Oo Cm reak Oc Ns Cm /a Ar address +.It Cm b Ns Oo Cm reak Oc Ns Cm /t Ar address +Set a breakpoint at +.Ar address . +.It Cm c Ns Op Cm ontinue +Continue execution. +.It Cm d Ns Oo elete Oc Ar address +Delete a breakpoint at +.Ar address . +.It Cm dis Ns Oo Cm asm Oc Ar address Op Ar count +.It Cm dis Ns Oo Cm asm Oc Ns Cm /a Ar address Op Ar count +.It Cm dis Ns Oo Cm asm Oc Ns Cm /t Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Ns Cm /a Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Ns Cm /t Ar address Op Ar count +Disassemble +.Ar count +instructions starting at address +.Ar address . +If +.Ar count +is not specified, only disassemble the instruction at +.Ar address . +.It Cm h Ns Op Cm elp +Print help. +.It Cm i Ns Op Cm nfo +.It Cm status +Print the current contents of general\(hypurpose registers. +.It Cm n Ns Op Cm ext +Execute the next instruction. +.It Cm p Ns Oo Cm rint Oc Ar value ... +.It Cm p Ns Oo Cm rint Oc Ns Cm /t Ar value ... +.It Cm p Ns Oo Cm rint Oc Ns Cm /x Ar value ... +Print +.Ar value . +.It Cm q Ns Op Cm uit +Quit the emulator. +.It Cm reset +Reset the emulation. +.It Cm r/1 Ar address +.It Cm r/2 Ar address +.It Cm r/4 Ar address +Read a byte, halfword, or word from +.Ar address . +.It Cm w Ns Oo Cm atch Oc Ar address +Set a watchpoint at +.Ar address . +.It Cm w/1 Ar address +.It Cm w/2 Ar address +.It Cm w/4 Ar address +Write a byte, halfword, or word to +.Ar address . +.It Cm w/r Ar register +Write a word to +.Ar register . +.It Cm x/1 Ar address +.It Cm x/2 Ar address +.It Cm x/4 Ar address +Examine bytes, halfwords, or words from +.Ar address . +.It Cm \&!\ \& +Break into the attached debugger. +.El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com .Sh HOMEPAGE From 541191648f463e1e3813bead8e5b18070e253ae8 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 30 Jul 2015 03:03:16 -0600 Subject: [PATCH 05/58] Qt: Add barebones manpage (no command line options yet) --- doc/mgba-qt.6 | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 doc/mgba-qt.6 diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 new file mode 100644 index 000000000..1687e7f32 --- /dev/null +++ b/doc/mgba-qt.6 @@ -0,0 +1,52 @@ +.\" Copyright (c) 2015 Anthony J. Bentley +.\" +.\" This Source Code Form is subject to the terms of the Mozilla Public +.\" License, v. 2.0. If a copy of the MPL was not distributed with this +.\" file, you can obtain one at https://mozilla.org/MPL/2.0/. +.Dd July 29, 2015 +.Dt MGBA-QT 6 +.Os +.Sh NAME +.Nm mgba-qt +.Nd Game Boy Advance emulator +.Sh SYNOPSIS +.Nm mgba-qt +.Ar file +.Sh DESCRIPTION +.Nm +is a Game Boy Advance emulator. +.Sh CONTROLS +The default controls are as follows: +.Bl -hang -width "Frame advance" -compact +.It A +.Cm x +.It B +.Cm z +.It L +.Cm a +.It R +.Cm s +.It Start +.Aq Cm Enter +.It Select +.Aq Cm Backspace +.It Load state +.Cm F1 Ns \(en Ns Cm F9 +.It Save state +.Ao Cm Shift Ac Ns \(hy Ns Cm F1 Ns \(en Ns Cm F9 +.It Frame advance +.Ao Cm Ctrl Ac Ns \(hy Ns Cm n +.El +.Sh AUTHORS +.An Jeffrey Pfau Aq Mt jeffrey@endrift.com +.Sh HOMEPAGE +.Bl -bullet +.It +.Lk https://mgba.io/ "mGBA homepage" +.It +.Lk https://github.com/mgba-emu/mgba "Development repository" +.It +.Lk https://github.com/mgba-emu/mgba/issues "Bug tracker" +.It +.Lk https://forums.mgba.io/ "Message board" +.El From f9110a9432b84e5cd43183bbc3b8e18c9177e9f0 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 01:34:45 -0600 Subject: [PATCH 06/58] Qt: Document -b, -s, -p in the manual --- doc/mgba-qt.6 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 1687e7f32..1c79de2c9 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -11,10 +11,27 @@ .Nd Game Boy Advance emulator .Sh SYNOPSIS .Nm mgba-qt +.Op Fl b Ar biosfile +.Op Fl p Ar patchfile +.Op Fl s Ar n .Ar file .Sh DESCRIPTION .Nm is a Game Boy Advance emulator. +The options are as follows: +.Bl -tag -width Ds +.It Fl b Ar biosfile , Fl -bios Ar biosfile +Specify a BIOS file to use during boot. +If this flag is omitted, +.Nm +will use a high\(hylevel emulated BIOS. +.It Fl p Ar patchfile , Fl -patch Ar patchfile +Specify a patch file in IPS or UPS format. +.It Fl s Ar n , Fl -frameskip Ar n +Skip every +.Ar n +frames. +.El .Sh CONTROLS The default controls are as follows: .Bl -hang -width "Frame advance" -compact From d6ccfe003a25bafdc9a6de93c25785fc4e42fcf4 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 01:50:52 -0600 Subject: [PATCH 07/58] SDL: Document -l in the manual --- doc/mgba.6 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/mgba.6 b/doc/mgba.6 index 3d12ea685..b29ecf010 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -14,6 +14,7 @@ .Op Fl 123456dfg .Op Fl b Ar biosfile .Op Fl c Ar cheatfile +.Op Fl l Ar loglevel .Op Fl p Ar patchfile .Op Fl s Ar n .Op Fl v Ar moviefile @@ -52,6 +53,34 @@ Start a .Xr gdb 1 session. By default the session starts on port 2345. +.It Fl l Ar loglevel +Log messages during emulation to +.Dv stdout . +.Ar loglevel +is a bitmask defining which types of messages to log: +.Bl -inset +.It 0x01 +fatal errors +.It 0x02 +errors +.It 0x04 +warnings +.It 0x08 +informative messages +.It 0x10 +debugging messages +.It 0x20 +stub messages +.It 0x100 +in\(hygame errors +.It 0x200 +software interrupts +.It 0x400 +emulator status messages +.It 0x800 +serial I/O messages +.El +The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile Specify a patch file in IPS or UPS format. .It Fl s Ar n , Fl -frameskip Ar n From 4951ab974c8d582a63d5133be57ac0efe2415f08 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 01:51:08 -0600 Subject: [PATCH 08/58] Qt: Document -l in the manual --- doc/mgba-qt.6 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 1c79de2c9..1b32d3527 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -12,6 +12,7 @@ .Sh SYNOPSIS .Nm mgba-qt .Op Fl b Ar biosfile +.Op Fl l Ar loglevel .Op Fl p Ar patchfile .Op Fl s Ar n .Ar file @@ -25,6 +26,33 @@ Specify a BIOS file to use during boot. If this flag is omitted, .Nm will use a high\(hylevel emulated BIOS. +.It Fl l Ar loglevel +Log messages during emulation. +.Ar loglevel +is a bitmask defining which types of messages to log: +.Bl -inset +.It 0x01 +fatal errors +.It 0x02 +errors +.It 0x04 +warnings +.It 0x08 +informative messages +.It 0x10 +debugging messages +.It 0x20 +stub messages +.It 0x100 +in\(hygame errors +.It 0x200 +software interrupts +.It 0x400 +emulator status messages +.It 0x800 +serial I/O messages +.El +The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile Specify a patch file in IPS or UPS format. .It Fl s Ar n , Fl -frameskip Ar n From 35d3313c069f13003856538449e314d2419358bc Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 02:02:07 -0600 Subject: [PATCH 09/58] SDL: Document debugger command suffixes --- doc/mgba.6 | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index b29ecf010..5727c7848 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -125,7 +125,11 @@ It supports the following commands: .It Cm b Ns Oo Cm reak Oc Ar address .It Cm b Ns Oo Cm reak Oc Ns Cm /a Ar address .It Cm b Ns Oo Cm reak Oc Ns Cm /t Ar address -Set a breakpoint at +Set a breakpoint \(en ARM +.Pq Ql /a , +Thumb +.Pq Ql /t , +or the current CPU mode \(en at .Ar address . .It Cm c Ns Op Cm ontinue Continue execution. @@ -140,8 +144,13 @@ Delete a breakpoint at .It Cm dis Ns Oo Cm assemble Oc Ns Cm /t Ar address Op Ar count Disassemble .Ar count -instructions starting at address -.Ar address . +instructions starting at +.Ar address , +as ARM +.Pq Ql /a , +Thumb +.Pq Ql /t , +or the current CPU mode. If .Ar count is not specified, only disassemble the instruction at @@ -156,8 +165,13 @@ Execute the next instruction. .It Cm p Ns Oo Cm rint Oc Ar value ... .It Cm p Ns Oo Cm rint Oc Ns Cm /t Ar value ... .It Cm p Ns Oo Cm rint Oc Ns Cm /x Ar value ... -Print -.Ar value . +Print one or more +.Ar value Ns s +as binary +.Pq Ql /t , +hexadecimal +.Pq Ql /x , +or decimal. .It Cm q Ns Op Cm uit Quit the emulator. .It Cm reset @@ -165,7 +179,13 @@ Reset the emulation. .It Cm r/1 Ar address .It Cm r/2 Ar address .It Cm r/4 Ar address -Read a byte, halfword, or word from +Read a byte +.Pq Ql /1 , +halfword +.Pq Ql /2 , +or word +.Pq Ql /4 +from .Ar address . .It Cm w Ns Oo Cm atch Oc Ar address Set a watchpoint at @@ -173,7 +193,13 @@ Set a watchpoint at .It Cm w/1 Ar address .It Cm w/2 Ar address .It Cm w/4 Ar address -Write a byte, halfword, or word to +Write a byte +.Pq Ql /1 , +halfword +.Pq Ql /2 , +or word +.Pq Ql /4 +to .Ar address . .It Cm w/r Ar register Write a word to @@ -181,7 +207,13 @@ Write a word to .It Cm x/1 Ar address .It Cm x/2 Ar address .It Cm x/4 Ar address -Examine bytes, halfwords, or words from +Examine bytes +.Pq Ql /1 , +halfwords +.Pq Ql /2 , +or words +.Pq Ql /4 +from .Ar address . .It Cm \&!\ \& Break into the attached debugger. From 6612adc05c63eeaebc4b4d8129580219a6010f6e Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 10:31:05 -0600 Subject: [PATCH 10/58] Qt, SDL: Mention BPS in relation to -p --- doc/mgba-qt.6 | 2 +- doc/mgba.6 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 1b32d3527..85c16a2d2 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -54,7 +54,7 @@ serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile -Specify a patch file in IPS or UPS format. +Specify a patch file in BPS, IPS, or UPS format. .It Fl s Ar n , Fl -frameskip Ar n Skip every .Ar n diff --git a/doc/mgba.6 b/doc/mgba.6 index 5727c7848..d6f514104 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -82,7 +82,7 @@ serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile -Specify a patch file in IPS or UPS format. +Specify a patch file in BPS, IPS, or UPS format. .It Fl s Ar n , Fl -frameskip Ar n Skip every .Ar n From 099b6f20c57424da8b9a6dcedbfcc363cbd29e37 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 10:33:14 -0600 Subject: [PATCH 11/58] Qt, SDL: Refer to decimal values in the documentation for -l --- doc/mgba-qt.6 | 20 ++++++++++---------- doc/mgba.6 | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 85c16a2d2..e9130f2fe 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -31,25 +31,25 @@ Log messages during emulation. .Ar loglevel is a bitmask defining which types of messages to log: .Bl -inset -.It 0x01 +.It 1 fatal errors -.It 0x02 +.It 2 errors -.It 0x04 +.It 4 warnings -.It 0x08 +.It 8 informative messages -.It 0x10 +.It 16 debugging messages -.It 0x20 +.It 32 stub messages -.It 0x100 +.It 256 in\(hygame errors -.It 0x200 +.It 512 software interrupts -.It 0x400 +.It 1024 emulator status messages -.It 0x800 +.It 2048 serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. diff --git a/doc/mgba.6 b/doc/mgba.6 index d6f514104..132e4ba9d 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -59,25 +59,25 @@ Log messages during emulation to .Ar loglevel is a bitmask defining which types of messages to log: .Bl -inset -.It 0x01 +.It 1 fatal errors -.It 0x02 +.It 2 errors -.It 0x04 +.It 4 warnings -.It 0x08 +.It 8 informative messages -.It 0x10 +.It 16 debugging messages -.It 0x20 +.It 32 stub messages -.It 0x100 +.It 256 in\(hygame errors -.It 0x200 +.It 512 software interrupts -.It 0x400 +.It 1024 emulator status messages -.It 0x800 +.It 2048 serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. From 0cfdb19df4642262d893670b868312eee287fe45 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 10:39:50 -0600 Subject: [PATCH 12/58] Qt, SDL: Point out that without -b the default is set in config --- doc/mgba-qt.6 | 3 ++- doc/mgba.6 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index e9130f2fe..cd3ac99d4 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -25,7 +25,8 @@ The options are as follows: Specify a BIOS file to use during boot. If this flag is omitted, .Nm -will use a high\(hylevel emulated BIOS. +will use the BIOS specified in the configuration file, +or a high\(hylevel emulated BIOS if none is specified. .It Fl l Ar loglevel Log messages during emulation. .Ar loglevel diff --git a/doc/mgba.6 b/doc/mgba.6 index 132e4ba9d..c1db2f2b2 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -40,7 +40,8 @@ Scale the window 6\(mu. Specify a BIOS file to use during boot. If this flag is omitted, .Nm -will use a high\(hylevel emulated BIOS. +will use the BIOS specified in the configuration file, +or a high\(hylevel emulated BIOS if none is specified. .It Fl c Ar cheatfile , Fl -cheats Ar cheatfile Apply cheat codes from .Ar cheatfile . From bc12a28bf61d96b174bd04dcddf3bd146342c2ff Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 10:46:44 -0600 Subject: [PATCH 13/58] Qt, SDL: Add a FILES section to the manuals --- doc/mgba-qt.6 | 11 +++++++++++ doc/mgba.6 | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index cd3ac99d4..dfda7a7aa 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -83,6 +83,17 @@ The default controls are as follows: .It Frame advance .Ao Cm Ctrl Ac Ns \(hy Ns Cm n .El +.Sh FILES +.Bl -tag -width ~/.config/mgba/config.ini -compact +.It Pa ~/.config/mgba/config.ini +Default +.Xr mgba 6 +configuration file. +.It Pa ~/.config/mgba/qt.ini +Default +.Nm mgba-qt +configuration file. +.El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com .Sh HOMEPAGE diff --git a/doc/mgba.6 b/doc/mgba.6 index c1db2f2b2..c05a87166 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -219,6 +219,13 @@ from .It Cm \&!\ \& Break into the attached debugger. .El +.Sh FILES +.Bl -tag -width ~/.config/mgba/config.ini -compact +.It Pa ~/.config/mgba/config.ini +Default +.Nm +configuration file. +.El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com .Sh HOMEPAGE From 542f25ca5d8bca553e228adce2bc13cb898f2c3e Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Thu, 6 Aug 2015 10:49:19 -0600 Subject: [PATCH 14/58] Qt, SDL: Tweak wording for stub loglevels --- doc/mgba-qt.6 | 2 +- doc/mgba.6 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index dfda7a7aa..5cbf2a3cf 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -43,7 +43,7 @@ informative messages .It 16 debugging messages .It 32 -stub messages +stub messages for unimplemented features .It 256 in\(hygame errors .It 512 diff --git a/doc/mgba.6 b/doc/mgba.6 index c05a87166..ab5f77779 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -71,7 +71,7 @@ informative messages .It 16 debugging messages .It 32 -stub messages +stub messages for unimplemented features .It 256 in\(hygame errors .It 512 From 581d5fab3b0b724d782ca01cf7d920043c8d0f45 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 6 Aug 2015 15:54:55 -0700 Subject: [PATCH 15/58] All: Update PORTING --- PORTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PORTING.md b/PORTING.md index baa6f3712..ef7216c21 100644 --- a/PORTING.md +++ b/PORTING.md @@ -30,13 +30,12 @@ The ports are vaguely usable, but by no means should be considered stable. ### PS Vita (port/psp2) * Add menu -* Add audio +* Fix audio * Make it faster * Threaded renderer shim * Hardware acceleration ### Wii (port/wii) * Add menu -* Add audio * Thread support * Clean up video detection From 870c8ebb8c529daeb5326c836322a72114a76c5d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 6 Aug 2015 19:04:03 -0700 Subject: [PATCH 16/58] Qt: Fix sync, hopefully --- CHANGES | 1 + src/platform/qt/DisplayGL.cpp | 74 +++++++++++++++++++++++++----- src/platform/qt/DisplayGL.h | 10 +++- src/platform/qt/GameController.cpp | 9 ++-- src/platform/qt/GameController.h | 1 + 5 files changed, 80 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index b3a18ad7e..ce4b8cb80 100644 --- a/CHANGES +++ b/CHANGES @@ -30,6 +30,7 @@ Features: - Libretro now supports BIOS, rumble and solar sensor - Implement BIOS call Stop, for sleep mode - Automatically load patches, if found + - Improved video synchronization Bugfixes: - ARM7: Fix SWI and IRQ timings - GBA Audio: Force audio FIFOs to 32-bit diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index 9446da083..e55208425 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -118,7 +118,8 @@ void DisplayGL::filter(bool filter) { void DisplayGL::framePosted(const uint32_t* buffer) { if (m_drawThread && buffer) { - QMetaObject::invokeMethod(m_painter, "setBacking", Q_ARG(const uint32_t*, buffer)); + m_painter->enqueue(buffer); + QMetaObject::invokeMethod(m_painter, "draw"); } } @@ -152,6 +153,19 @@ PainterGL::PainterGL(QGLWidget* parent) m_backend.d.user = this; m_backend.d.filter = false; m_backend.d.lockAspectRatio = false; + + for (int i = 0; i < 2; ++i) { + m_free.append(new uint32_t[256 * 256]); + } +} + +PainterGL::~PainterGL() { + while (!m_queue.isEmpty()) { + delete[] m_queue.dequeue(); + } + for (auto item : m_free) { + delete[] item; + } } void PainterGL::setContext(GBAThread* context) { @@ -162,15 +176,6 @@ void PainterGL::setMessagePainter(MessagePainter* messagePainter) { m_messagePainter = messagePainter; } -void PainterGL::setBacking(const uint32_t* backing) { - m_gl->makeCurrent(); - m_backend.d.postFrame(&m_backend.d, backing); - if (m_active) { - draw(); - } - m_gl->doneCurrent(); -} - void PainterGL::resize(const QSize& size) { m_size = size; if (m_active) { @@ -200,7 +205,11 @@ void PainterGL::start() { } void PainterGL::draw() { - if (GBASyncWaitFrameStart(&m_context->sync, m_context->frameskip)) { + if (m_queue.isEmpty()) { + return; + } + if (GBASyncWaitFrameStart(&m_context->sync, m_context->frameskip) || !m_queue.isEmpty()) { + dequeue(); m_painter.begin(m_gl->context()->device()); performDraw(); m_painter.end(); @@ -209,6 +218,9 @@ void PainterGL::draw() { } else { GBASyncWaitFrameEnd(&m_context->sync); } + if (!m_queue.isEmpty()) { + QMetaObject::invokeMethod(this, "draw", Qt::QueuedConnection); + } } void PainterGL::forceDraw() { @@ -221,6 +233,7 @@ void PainterGL::forceDraw() { void PainterGL::stop() { m_active = false; m_gl->makeCurrent(); + dequeueAll(); m_backend.d.clear(&m_backend.d); m_backend.d.swap(&m_backend.d); m_backend.d.deinit(&m_backend.d); @@ -232,8 +245,11 @@ void PainterGL::stop() { void PainterGL::pause() { m_active = false; // Make sure both buffers are filled + m_gl->makeCurrent(); + dequeueAll(); forceDraw(); forceDraw(); + m_gl->doneCurrent(); } void PainterGL::unpause() { @@ -250,3 +266,39 @@ void PainterGL::performDraw() { m_messagePainter->paint(&m_painter); } } + +void PainterGL::enqueue(const uint32_t* backing) { + m_mutex.lock(); + uint32_t* buffer; + if (m_free.isEmpty()) { + buffer = m_queue.dequeue(); + } else { + buffer = m_free.takeLast(); + } + memcpy(buffer, backing, 256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); + m_queue.enqueue(buffer); + m_mutex.unlock(); +} + +void PainterGL::dequeue() { + m_mutex.lock(); + if (m_queue.isEmpty()) { + m_mutex.unlock(); + return; + } + uint32_t* buffer = m_queue.dequeue(); + m_backend.d.postFrame(&m_backend.d, buffer); + m_free.append(buffer); + m_mutex.unlock(); +} + +void PainterGL::dequeueAll() { + uint32_t* buffer; + m_mutex.lock(); + while (!m_queue.isEmpty()) { + buffer = m_queue.dequeue(); + m_free.append(buffer); + } + m_backend.d.postFrame(&m_backend.d, buffer); + m_mutex.unlock(); +} diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index ebca3d635..bad1b252a 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -9,7 +9,9 @@ #include "Display.h" #include +#include #include +#include #include #include @@ -74,12 +76,13 @@ Q_OBJECT public: PainterGL(QGLWidget* parent); + ~PainterGL(); void setContext(GBAThread*); void setMessagePainter(MessagePainter*); + void enqueue(const uint32_t* backing); public slots: - void setBacking(const uint32_t*); void forceDraw(); void draw(); void start(); @@ -92,8 +95,13 @@ public slots: private: void performDraw(); + void dequeue(); + void dequeueAll(); + QList m_free; + QQueue m_queue; QPainter m_painter; + QMutex m_mutex; QGLWidget* m_gl; bool m_active; GBAThread* m_context; diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 91b22a921..a5a345cfe 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -31,7 +31,8 @@ using namespace std; GameController::GameController(QObject* parent) : QObject(parent) - , m_drawContext(new uint32_t[256 * 256]) + , m_drawContext(new uint32_t[256 * VIDEO_HORIZONTAL_PIXELS]) + , m_frontBuffer(new uint32_t[256 * 256]) , m_threadContext() , m_activeKeys(0) , m_inactiveKeys(0) @@ -122,7 +123,8 @@ GameController::GameController(QObject* parent) m_threadContext.frameCallback = [](GBAThread* context) { GameController* controller = static_cast(context->userData); if (GBASyncDrawingFrame(&controller->m_threadContext.sync)) { - controller->frameAvailable(controller->m_drawContext); + memcpy(controller->m_frontBuffer, controller->m_drawContext, 256 * VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); + controller->frameAvailable(controller->m_frontBuffer); } else { controller->frameAvailable(nullptr); } @@ -216,6 +218,7 @@ GameController::~GameController() { GBACheatDeviceDestroy(&m_cheatDevice); delete m_renderer; delete[] m_drawContext; + delete[] m_frontBuffer; delete m_backupLoadState; } @@ -339,7 +342,7 @@ void GameController::openGame(bool biosOnly) { } m_inputController->recalibrateAxes(); - memset(m_drawContext, 0xF8, 1024 * 256); + memset(m_drawContext, 0xF8, 1024 * VIDEO_HORIZONTAL_PIXELS); if (!GBAThreadStart(&m_threadContext)) { m_gameOpen = false; diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index 14fbdf7e4..9267668b5 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -167,6 +167,7 @@ private: void enableTurbo(); uint32_t* m_drawContext; + uint32_t* m_frontBuffer; GBAThread m_threadContext; GBAVideoSoftwareRenderer* m_renderer; GBACheatDevice m_cheatDevice; From 9a5ac0bf72d88ef3a380eae86ad0a31ba5e102b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 6 Aug 2015 19:42:08 -0700 Subject: [PATCH 17/58] Qt: Fix pausing and disable double buffering, since it is no longer needed --- src/platform/qt/Display.cpp | 2 +- src/platform/qt/DisplayGL.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 014162562..3766baf7b 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -22,7 +22,7 @@ Display::Driver Display::s_driver = Display::Driver::QT; Display* Display::create(QWidget* parent) { #ifdef BUILD_GL - QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); + QGLFormat format(QGLFormat(QGL::Rgba | QGL::SingleBuffer)); format.setSwapInterval(1); #endif diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index e55208425..8a1bd5ebb 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -244,12 +244,9 @@ void PainterGL::stop() { void PainterGL::pause() { m_active = false; - // Make sure both buffers are filled - m_gl->makeCurrent(); - dequeueAll(); - forceDraw(); - forceDraw(); - m_gl->doneCurrent(); + if (!m_queue.isEmpty()) { + QMetaObject::invokeMethod(this, "pause", Qt::QueuedConnection); + } } void PainterGL::unpause() { @@ -293,12 +290,14 @@ void PainterGL::dequeue() { } void PainterGL::dequeueAll() { - uint32_t* buffer; + uint32_t* buffer = 0; m_mutex.lock(); while (!m_queue.isEmpty()) { buffer = m_queue.dequeue(); m_free.append(buffer); } - m_backend.d.postFrame(&m_backend.d, buffer); + if (buffer) { + m_backend.d.postFrame(&m_backend.d, buffer); + } m_mutex.unlock(); } From c39be359df21c462b110ab049608c6e7e1e5aef8 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 7 Aug 2015 19:10:08 -0700 Subject: [PATCH 18/58] Qt: Fix regression with held reverse breaking (fixes #78) --- src/platform/qt/GameController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index a5a345cfe..6432a2ba6 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -533,9 +533,9 @@ void GameController::startRewinding() { return; } m_wasPaused = isPaused(); - bool signalsBlocked = blockSignals(true); - setPaused(true); - blockSignals(signalsBlocked); + if (!GBAThreadIsPaused(&m_threadContext)) { + GBAThreadPause(&m_threadContext); + } m_rewindTimer.start(); } From 3dc22d9cc5c93429dabd8428bfc359132543f318 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 7 Aug 2015 20:26:19 -0700 Subject: [PATCH 19/58] Qt: Ensure frame size options stay checked --- src/platform/qt/Window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 60b8861ee..205fcd6ea 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -939,9 +939,12 @@ void Window::setupMenu(QMenuBar* menubar) { for (int i = 1; i <= 6; ++i) { QAction* setSize = new QAction(tr("%1x").arg(QString::number(i)), avMenu); setSize->setCheckable(true); - connect(setSize, &QAction::triggered, [this, i]() { + connect(setSize, &QAction::triggered, [this, i, setSize]() { showNormal(); resizeFrame(VIDEO_HORIZONTAL_PIXELS * i, VIDEO_VERTICAL_PIXELS * i); + bool enableSignals = setSize->blockSignals(true); + setSize->setChecked(true); + setSize->blockSignals(enableSignals); }); m_frameSizes[i] = setSize; addControlledAction(frameMenu, setSize, QString("frame%1x").arg(QString::number(i))); From a9620df0b8fbe74d48a6f459592049291a93948e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 7 Aug 2015 21:04:47 -0700 Subject: [PATCH 20/58] Qt: Create a new cheat set if no cheat set is specified --- src/platform/qt/CheatsView.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/platform/qt/CheatsView.cpp b/src/platform/qt/CheatsView.cpp index c39ad398b..357a0c788 100644 --- a/src/platform/qt/CheatsView.cpp +++ b/src/platform/qt/CheatsView.cpp @@ -99,19 +99,29 @@ void CheatsView::removeSet() { } void CheatsView::enterCheat(std::function callback) { - GBACheatSet* set; + GBACheatSet* set = nullptr; QModelIndexList selection = m_ui.cheatList->selectionModel()->selectedIndexes(); - if (selection.count() != 1) { - return; + QModelIndex index; + if (selection.count() == 0) { + set = new GBACheatSet; + GBACheatSetInit(set, nullptr); + } else if (selection.count() == 1) { + index = selection[0]; + set = m_model.itemAt(index); } - set = m_model.itemAt(selection[0]); + if (!set) { return; } m_controller->threadInterrupt(); + if (selection.count() == 0) { + m_model.addSet(set); + index = m_model.index(m_model.rowCount() - 1, 0, QModelIndex()); + m_ui.cheatList->selectionModel()->select(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + } QStringList cheats = m_ui.codeEntry->toPlainText().split('\n', QString::SkipEmptyParts); for (const QString& string : cheats) { - m_model.beginAppendRow(selection[0]); + m_model.beginAppendRow(index); callback(set, string.toUtf8().constData()); m_model.endAppendRow(); } From db17646fe5fc818930c77f4e13e643285ce9a209 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 7 Aug 2015 23:23:20 -0700 Subject: [PATCH 21/58] Qt: Fix forums link --- src/platform/qt/AboutScreen.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/qt/AboutScreen.ui b/src/platform/qt/AboutScreen.ui index 8a4865936..d03c9dfd6 100644 --- a/src/platform/qt/AboutScreen.ui +++ b/src/platform/qt/AboutScreen.ui @@ -145,7 +145,7 @@ - <a href="http://mgba.io/">Website</a> • <a href="https://forumsmgba.io/">Forums / Support</a> • <a href="https://github.com/mgba-emu/mgba/tree/{gitBranch}">Source</a> • <a href="https://github.com/mgba-emu/mgba/blob/{gitBranch}/LICENSE">License</a> + <a href="http://mgba.io/">Website</a> • <a href="https://forums/mgba.io/">Forums / Support</a> • <a href="https://github.com/mgba-emu/mgba/tree/{gitBranch}">Source</a> • <a href="https://github.com/mgba-emu/mgba/blob/{gitBranch}/LICENSE">License</a> Qt::AlignCenter From b7a875a486eb38cda9d1e0074a72b6a3f1fcce35 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:13:08 -0600 Subject: [PATCH 22/58] SDL: Add missed markup in manual --- doc/mgba.6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index ab5f77779..442196557 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -134,7 +134,7 @@ or the current CPU mode \(en at .Ar address . .It Cm c Ns Op Cm ontinue Continue execution. -.It Cm d Ns Oo elete Oc Ar address +.It Cm d Ns Oo Cm elete Oc Ar address Delete a breakpoint at .Ar address . .It Cm dis Ns Oo Cm asm Oc Ar address Op Ar count From 623185bb4331868e4b0e2f96e89455927c5f4e2e Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:17:07 -0600 Subject: [PATCH 23/58] Qt, SDL: Use a bulleted list for loglevels in the manual --- doc/mgba-qt.6 | 42 +++++++++++++++++++++--------------------- doc/mgba.6 | 42 +++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 5cbf2a3cf..5346ddb47 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -31,27 +31,27 @@ or a high\(hylevel emulated BIOS if none is specified. Log messages during emulation. .Ar loglevel is a bitmask defining which types of messages to log: -.Bl -inset -.It 1 -fatal errors -.It 2 -errors -.It 4 -warnings -.It 8 -informative messages -.It 16 -debugging messages -.It 32 -stub messages for unimplemented features -.It 256 -in\(hygame errors -.It 512 -software interrupts -.It 1024 -emulator status messages -.It 2048 -serial I/O messages +.Bl -bullet -compact +.It +1 \(en fatal errors +.It +2 \(en errors +.It +4 \(en warnings +.It +8 \(en informative messages +.It +16 \(en debugging messages +.It +32 \(en stub messages for unimplemented features +.It +256 \(en in\(hygame errors +.It +512 \(en software interrupts +.It +1024 \(en emulator status messages +.It +2048 \(en serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile diff --git a/doc/mgba.6 b/doc/mgba.6 index 442196557..452b2282b 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -59,27 +59,27 @@ Log messages during emulation to .Dv stdout . .Ar loglevel is a bitmask defining which types of messages to log: -.Bl -inset -.It 1 -fatal errors -.It 2 -errors -.It 4 -warnings -.It 8 -informative messages -.It 16 -debugging messages -.It 32 -stub messages for unimplemented features -.It 256 -in\(hygame errors -.It 512 -software interrupts -.It 1024 -emulator status messages -.It 2048 -serial I/O messages +.Bl -bullet -compact +.It +1 \(en fatal errors +.It +2 \(en errors +.It +4 \(en warnings +.It +8 \(en informative messages +.It +16 \(en debugging messages +.It +32 \(en stub messages for unimplemented features +.It +256 \(en in\(hygame errors +.It +512 \(en software interrupts +.It +1024 \(en emulator status messages +.It +2048 \(en serial I/O messages .El The default is to log warnings, errors, fatal errors, and status messages. .It Fl p Ar patchfile , Fl -patch Ar patchfile From 2c1f5c48a64b31e296e8fae321a5e8582d556d18 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:20:56 -0600 Subject: [PATCH 24/58] Qt, SDL: Document portable.ini and its effects --- doc/mgba-qt.6 | 9 +++++++++ doc/mgba.6 | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 5346ddb47..256384721 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -93,6 +93,15 @@ configuration file. Default .Nm mgba-qt configuration file. +.It Pa portable.ini +If this file exists in the current directory, +.Nm +will read +.Pa config.ini +and +.Pa qt.ini +from the current directory instead of +.Pa ~/.config/mgba . .El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com diff --git a/doc/mgba.6 b/doc/mgba.6 index 452b2282b..1cd69d202 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -225,6 +225,13 @@ Break into the attached debugger. Default .Nm configuration file. +.It Pa portable.ini +If this file exists in the current directory, +.Nm +will read +.Pa config.ini +from the current directory instead of +.Pa ~/.config/mgba . .El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com From ad8e030fbb7618f4356df74c31811ba3259b4f04 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:23:34 -0600 Subject: [PATCH 25/58] SDL: Document disasm's address argument as optional --- doc/mgba.6 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 1cd69d202..7855986cc 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -137,12 +137,12 @@ Continue execution. .It Cm d Ns Oo Cm elete Oc Ar address Delete a breakpoint at .Ar address . -.It Cm dis Ns Oo Cm asm Oc Ar address Op Ar count -.It Cm dis Ns Oo Cm asm Oc Ns Cm /a Ar address Op Ar count -.It Cm dis Ns Oo Cm asm Oc Ns Cm /t Ar address Op Ar count -.It Cm dis Ns Oo Cm assemble Oc Ar address Op Ar count -.It Cm dis Ns Oo Cm assemble Oc Ns Cm /a Ar address Op Ar count -.It Cm dis Ns Oo Cm assemble Oc Ns Cm /t Ar address Op Ar count +.It Cm dis Ns Oo Cm asm Oc Op Ar address Op Ar count +.It Cm dis Ns Oo Cm asm Oc Ns Cm /a Op Ar address Op Ar count +.It Cm dis Ns Oo Cm asm Oc Ns Cm /t Op Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Op Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Ns Cm /a Op Ar address Op Ar count +.It Cm dis Ns Oo Cm assemble Oc Ns Cm /t Op Ar address Op Ar count Disassemble .Ar count instructions starting at @@ -156,6 +156,9 @@ If .Ar count is not specified, only disassemble the instruction at .Ar address . +If +.Ar address +is not specified, only disassemble the current address. .It Cm h Ns Op Cm elp Print help. .It Cm i Ns Op Cm nfo From aca5c742cb14b80626e4b1b0b8069a1f2491c6d8 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:24:39 -0600 Subject: [PATCH 26/58] SDL: Correct the documentation of the info/status commands --- doc/mgba.6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 7855986cc..e7098bfed 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -163,7 +163,8 @@ is not specified, only disassemble the current address. Print help. .It Cm i Ns Op Cm nfo .It Cm status -Print the current contents of general\(hypurpose registers. +Print the current contents of general\(hypurpose registers and the current +program state register, and disassemble the current instruction. .It Cm n Ns Op Cm ext Execute the next instruction. .It Cm p Ns Oo Cm rint Oc Ar value ... From 791b678021e91d05c26688fba16593875914158d Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:26:14 -0600 Subject: [PATCH 27/58] SDL: Document the missing data argument to w/1, w/2, w/4 --- doc/mgba.6 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index e7098bfed..512ea638d 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -195,10 +195,12 @@ from .It Cm w Ns Oo Cm atch Oc Ar address Set a watchpoint at .Ar address . -.It Cm w/1 Ar address -.It Cm w/2 Ar address -.It Cm w/4 Ar address -Write a byte +.It Cm w/1 Ar address data +.It Cm w/2 Ar address data +.It Cm w/4 Ar address data +Write +.Ar data +as a byte .Pq Ql /1 , halfword .Pq Ql /2 , From a65015fcbd2143c57c814a1023f6d8ce691aa9e3 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:29:42 -0600 Subject: [PATCH 28/58] SDL: Document the optional count argument for x --- doc/mgba.6 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 512ea638d..db1ccd035 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -211,10 +211,12 @@ to .It Cm w/r Ar register Write a word to .Ar register . -.It Cm x/1 Ar address -.It Cm x/2 Ar address -.It Cm x/4 Ar address -Examine bytes +.It Cm x/1 Ar address Op Ar count +.It Cm x/2 Ar address Op Ar count +.It Cm x/4 Ar address Op Ar count +Examine +.Ar count +bytes .Pq Ql /1 , halfwords .Pq Ql /2 , @@ -222,6 +224,9 @@ or words .Pq Ql /4 from .Ar address . +If +.Ar count +is not specified, examine 16 bytes, 8 halfwords, or 4 words. .It Cm \&!\ \& Break into the attached debugger. .El From 7a311b339cdab640c9c66c34250a1dac2a7a0e99 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sat, 8 Aug 2015 01:38:29 -0600 Subject: [PATCH 29/58] Qt: Really fix forums link --- src/platform/qt/AboutScreen.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/qt/AboutScreen.ui b/src/platform/qt/AboutScreen.ui index d03c9dfd6..6d2662c45 100644 --- a/src/platform/qt/AboutScreen.ui +++ b/src/platform/qt/AboutScreen.ui @@ -145,7 +145,7 @@ - <a href="http://mgba.io/">Website</a> • <a href="https://forums/mgba.io/">Forums / Support</a> • <a href="https://github.com/mgba-emu/mgba/tree/{gitBranch}">Source</a> • <a href="https://github.com/mgba-emu/mgba/blob/{gitBranch}/LICENSE">License</a> + <a href="http://mgba.io/">Website</a> • <a href="https://forums.mgba.io/">Forums / Support</a> • <a href="https://github.com/mgba-emu/mgba/tree/{gitBranch}">Source</a> • <a href="https://github.com/mgba-emu/mgba/blob/{gitBranch}/LICENSE">License</a> Qt::AlignCenter From c9c9ff802c424c39a7b5be207789152553944e6d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 8 Aug 2015 02:26:35 -0700 Subject: [PATCH 30/58] Debugger: Only support breaking into the external debugger in debug builds --- src/debugger/cli-debugger.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index f7d1014d5..c3f0c9de1 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -18,7 +18,9 @@ static const char* ERROR_OVERFLOW = "Arguments overflow"; static struct CLIDebugger* _activeDebugger; +#ifndef NDEBUG static void _breakInto(struct CLIDebugger*, struct CLIDebugVector*); +#endif static void _continue(struct CLIDebugger*, struct CLIDebugVector*); static void _disassemble(struct CLIDebugger*, struct CLIDebugVector*); static void _disassembleArm(struct CLIDebugger*, struct CLIDebugVector*); @@ -99,7 +101,9 @@ static struct CLIDebuggerCommandSummary _debuggerCommands[] = { { "x/1", _dumpByte, CLIDVParse, "Examine bytes at a specified offset" }, { "x/2", _dumpHalfword, CLIDVParse, "Examine halfwords at a specified offset" }, { "x/4", _dumpWord, CLIDVParse, "Examine words at a specified offset" }, +#ifndef NDEBUG { "!", _breakInto, 0, "Break into attached debugger (for developers)" }, +#endif { 0, 0, 0, 0 } }; @@ -114,6 +118,7 @@ static inline void _printPSR(union PSR psr) { psr.t ? 'T' : '-'); } +#ifndef NDEBUG static void _handleDeath(int sig) { UNUSED(sig); printf("No debugger attached!\n"); @@ -135,6 +140,7 @@ static void _breakInto(struct CLIDebugger* debugger, struct CLIDebugVector* dv) #endif sigaction(SIGTRAP, &osa, 0); } +#endif static void _continue(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { UNUSED(dv); From 0fb8f51df47a1701097150dd2c9103bf5044e24c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 8 Aug 2015 13:20:30 -0700 Subject: [PATCH 31/58] GBA Hardware: Fix savestates with the Game Boy Player attached --- src/gba/hardware.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gba/hardware.c b/src/gba/hardware.c index b445660ef..5d8d28020 100644 --- a/src/gba/hardware.c +++ b/src/gba/hardware.c @@ -612,6 +612,7 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer hw->readWrite = state->hw.readWrite; hw->pinState = state->hw.pinState; hw->direction = state->hw.pinDirection; + hw->devices = state->hw.devices; hw->rtc = state->hw.rtc; hw->gyroSample = state->hw.gyroSample; hw->gyroEdge = state->hw.gyroEdge; @@ -624,4 +625,7 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer hw->gbpInputsPosted = state->hw.gbpInputsPosted; hw->gbpTxPosition = state->hw.gbpTxPosition; hw->gbpNextEvent = state->hw.gbpNextEvent; + if (hw->devices & HW_GB_PLAYER) { + GBASIOSetDriver(&hw->p->sio, &hw->gbpDriver.d, SIO_NORMAL_32); + } } From 12ef93d784c377fa8cf137abaae6a19a2541381d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 8 Aug 2015 21:38:47 -0700 Subject: [PATCH 32/58] Qt: Use openView for GDBWindow --- src/platform/qt/Window.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 205fcd6ea..8639a4e32 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -393,9 +393,7 @@ void Window::gdbOpen() { m_gdbController = new GDBController(m_controller, this); } GDBWindow* window = new GDBWindow(m_gdbController); - connect(this, SIGNAL(shutdown()), window, SLOT(close())); - window->setAttribute(Qt::WA_DeleteOnClose); - window->show(); + openView(window); } #endif From e422c64a25f0e2d66fed1717ee8e82d39e947b89 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 8 Aug 2015 21:39:33 -0700 Subject: [PATCH 33/58] Qt: Convert several dialogs into QDialogs --- src/platform/qt/GDBWindow.cpp | 2 +- src/platform/qt/GDBWindow.h | 4 ++-- src/platform/qt/OverrideView.cpp | 2 +- src/platform/qt/OverrideView.h | 4 ++-- src/platform/qt/SensorView.cpp | 2 +- src/platform/qt/SensorView.h | 4 ++-- src/platform/qt/SettingsView.cpp | 4 ++-- src/platform/qt/SettingsView.h | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/platform/qt/GDBWindow.cpp b/src/platform/qt/GDBWindow.cpp index 26191b6e0..10e4b55d8 100644 --- a/src/platform/qt/GDBWindow.cpp +++ b/src/platform/qt/GDBWindow.cpp @@ -18,7 +18,7 @@ using namespace QGBA; GDBWindow::GDBWindow(GDBController* controller, QWidget* parent) - : QWidget(parent) + : QDialog(parent) , m_gdbController(controller) { setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint); diff --git a/src/platform/qt/GDBWindow.h b/src/platform/qt/GDBWindow.h index 683e7c632..9759df05b 100644 --- a/src/platform/qt/GDBWindow.h +++ b/src/platform/qt/GDBWindow.h @@ -6,7 +6,7 @@ #ifndef QGBA_GDB_WINDOW #define QGBA_GDB_WINDOW -#include +#include class QLineEdit; class QPushButton; @@ -15,7 +15,7 @@ namespace QGBA { class GDBController; -class GDBWindow : public QWidget { +class GDBWindow : public QDialog { Q_OBJECT public: diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index 738760684..b836f7ce0 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -15,7 +15,7 @@ extern "C" { using namespace QGBA; OverrideView::OverrideView(GameController* controller, ConfigController* config, QWidget* parent) - : QWidget(parent) + : QDialog(parent) , m_controller(controller) , m_config(config) { diff --git a/src/platform/qt/OverrideView.h b/src/platform/qt/OverrideView.h index 6a217edd5..3ed5d3e20 100644 --- a/src/platform/qt/OverrideView.h +++ b/src/platform/qt/OverrideView.h @@ -6,7 +6,7 @@ #ifndef QGBA_OVERRIDE_VIEW #define QGBA_OVERRIDE_VIEW -#include +#include #include "ui_OverrideView.h" @@ -21,7 +21,7 @@ namespace QGBA { class ConfigController; class GameController; -class OverrideView : public QWidget { +class OverrideView : public QDialog { Q_OBJECT public: diff --git a/src/platform/qt/SensorView.cpp b/src/platform/qt/SensorView.cpp index 501b05fd9..9a2edd6e4 100644 --- a/src/platform/qt/SensorView.cpp +++ b/src/platform/qt/SensorView.cpp @@ -12,7 +12,7 @@ using namespace QGBA; SensorView::SensorView(GameController* controller, InputController* input, QWidget* parent) - : QWidget(parent) + : QDialog(parent) , m_controller(controller) , m_input(input) , m_rotation(input->rotationSource()) diff --git a/src/platform/qt/SensorView.h b/src/platform/qt/SensorView.h index a37fb6e65..50c96ecf1 100644 --- a/src/platform/qt/SensorView.h +++ b/src/platform/qt/SensorView.h @@ -7,7 +7,7 @@ #define QGBA_SENSOR_VIEW #include -#include +#include #include @@ -22,7 +22,7 @@ class GameController; class GamepadAxisEvent; class InputController; -class SensorView : public QWidget { +class SensorView : public QDialog { Q_OBJECT public: diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index cc343cd29..53ed8fac2 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -13,8 +13,8 @@ using namespace QGBA; SettingsView::SettingsView(ConfigController* controller, QWidget* parent) - : QWidget(parent) - , m_controller(controller) + : QDialog(parent) + , m_controller(controller) { m_ui.setupUi(this); diff --git a/src/platform/qt/SettingsView.h b/src/platform/qt/SettingsView.h index 782e20e63..e47cda889 100644 --- a/src/platform/qt/SettingsView.h +++ b/src/platform/qt/SettingsView.h @@ -6,7 +6,7 @@ #ifndef QGBA_SETTINGS_VIEW #define QGBA_SETTINGS_VIEW -#include +#include #include "ui_SettingsView.h" @@ -14,7 +14,7 @@ namespace QGBA { class ConfigController; -class SettingsView : public QWidget { +class SettingsView : public QDialog { Q_OBJECT public: From 273a2b0afd42afe6dccc8dbf6a9178f64173fe54 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sun, 9 Aug 2015 02:23:40 -0600 Subject: [PATCH 34/58] SDL: Don't document ! in debugger, since it's disabled in releases --- doc/mgba.6 | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index db1ccd035..6a23a356e 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -227,8 +227,6 @@ from If .Ar count is not specified, examine 16 bytes, 8 halfwords, or 4 words. -.It Cm \&!\ \& -Break into the attached debugger. .El .Sh FILES .Bl -tag -width ~/.config/mgba/config.ini -compact From 60b121a6153f48ab85529adbd4adc5f107134f31 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sun, 9 Aug 2015 02:24:52 -0600 Subject: [PATCH 35/58] SDL: Document required argument to w/r --- doc/mgba.6 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/mgba.6 b/doc/mgba.6 index 6a23a356e..d2a4cb05b 100644 --- a/doc/mgba.6 +++ b/doc/mgba.6 @@ -208,8 +208,10 @@ or word .Pq Ql /4 to .Ar address . -.It Cm w/r Ar register -Write a word to +.It Cm w/r Ar register data +Write +.Ar data +as a word to .Ar register . .It Cm x/1 Ar address Op Ar count .It Cm x/2 Ar address Op Ar count From 805e0b17eb3e7cb1cb6e01370811d7c9dd7f0377 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 9 Aug 2015 01:52:49 -0700 Subject: [PATCH 36/58] All: Add manpage to CMake --- CMakeLists.txt | 10 +++++++--- src/platform/qt/CMakeLists.txt | 3 +++ src/platform/sdl/CMakeLists.txt | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb535e642..9fdacfcc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,13 +44,17 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release or Debug)" FORCE) endif() +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}") + +include(GNUInstallDirs) + if (NOT DEFINED LIBDIR) set(LIBDIR "lib") endif() -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}") - -include(GNUInstallDirs) +if (NOT DEFINED MANDIR) + set(MANDIR ${CMAKE_INSTALL_MANDIR}) +endif() # Function definitions include(FindPkgConfig) diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index 9aac6faca..3c1de1151 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -170,6 +170,9 @@ if(UNIX AND NOT APPLE) install(CODE "execute_process(COMMAND ${DESKTOP_FILE_INSTALL} \"${CMAKE_SOURCE_DIR}/res/mgba-qt.desktop\" --dir \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/applications/\")") endif() endif() +if(UNIX) + install(FILES ${CMAKE_SOURCE_DIR}/doc/mgba-qt.6 DESTINATION ${MANDIR}/man6 COMPONENT ${BINARY_NAME}-qt) +endif() if(APPLE OR WIN32) set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) endif() diff --git a/src/platform/sdl/CMakeLists.txt b/src/platform/sdl/CMakeLists.txt index 6e02b2933..3368a15ce 100644 --- a/src/platform/sdl/CMakeLists.txt +++ b/src/platform/sdl/CMakeLists.txt @@ -84,3 +84,6 @@ set_target_properties(${BINARY_NAME}-sdl PROPERTIES COMPILE_DEFINITIONS "${FEATU target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) set_target_properties(${BINARY_NAME}-sdl PROPERTIES OUTPUT_NAME ${BINARY_NAME}) install(TARGETS ${BINARY_NAME}-sdl DESTINATION bin COMPONENT ${BINARY_NAME}-sdl) +if(UNIX) + install(FILES ${CMAKE_SOURCE_DIR}/doc/mgba.6 DESTINATION ${MANDIR}/man6 COMPONENT ${BINARY_NAME}-sdl) +endif() From 9c5852e89ea26959c7a1872c7cee8d02e11d2317 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 9 Aug 2015 21:36:43 -0700 Subject: [PATCH 37/58] SDL, Qt: Configurable audio sample rate --- CHANGES | 1 + src/gba/supervisor/config.c | 2 ++ src/gba/supervisor/config.h | 1 + src/platform/qt/AudioProcessor.h | 3 +- src/platform/qt/AudioProcessorQt.cpp | 12 ++++++- src/platform/qt/AudioProcessorQt.h | 4 ++- src/platform/qt/AudioProcessorSDL.cpp | 18 ++++++++-- src/platform/qt/AudioProcessorSDL.h | 4 ++- src/platform/qt/GBAApp.cpp | 4 +-- src/platform/qt/GameController.cpp | 49 +++++++++++++++++++++------ src/platform/qt/GameController.h | 1 + src/platform/qt/Window.cpp | 6 ++++ src/platform/qt/Window.h | 1 + src/platform/sdl/main.c | 4 +++ src/platform/sdl/sdl-audio.c | 2 +- src/platform/sdl/sdl-audio.h | 1 + 16 files changed, 91 insertions(+), 22 deletions(-) diff --git a/CHANGES b/CHANGES index ce4b8cb80..466341681 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,7 @@ Features: - Implement BIOS call Stop, for sleep mode - Automatically load patches, if found - Improved video synchronization + - Configurable audio output sample rate Bugfixes: - ARM7: Fix SWI and IRQ timings - GBA Audio: Force audio FIFOs to 32-bit diff --git a/src/gba/supervisor/config.c b/src/gba/supervisor/config.c index 19e5c2bd6..ecf175dbb 100644 --- a/src/gba/supervisor/config.c +++ b/src/gba/supervisor/config.c @@ -247,6 +247,7 @@ void GBAConfigMap(const struct GBAConfig* config, struct GBAOptions* opts) { if (_lookupUIntValue(config, "audioBuffers", &audioBuffers)) { opts->audioBuffers = audioBuffers; } + _lookupUIntValue(config, "sampleRate", &opts->sampleRate); int fakeBool; if (_lookupIntValue(config, "useBios", &fakeBool)) { @@ -305,6 +306,7 @@ void GBAConfigLoadDefaults(struct GBAConfig* config, const struct GBAOptions* op ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindBufferInterval", opts->rewindBufferInterval); ConfigurationSetFloatValue(&config->defaultsTable, 0, "fpsTarget", opts->fpsTarget); ConfigurationSetUIntValue(&config->defaultsTable, 0, "audioBuffers", opts->audioBuffers); + ConfigurationSetUIntValue(&config->defaultsTable, 0, "sampleRate", opts->sampleRate); ConfigurationSetIntValue(&config->defaultsTable, 0, "audioSync", opts->audioSync); ConfigurationSetIntValue(&config->defaultsTable, 0, "videoSync", opts->videoSync); ConfigurationSetIntValue(&config->defaultsTable, 0, "fullscreen", opts->fullscreen); diff --git a/src/gba/supervisor/config.h b/src/gba/supervisor/config.h index 07c824cd2..35d822838 100644 --- a/src/gba/supervisor/config.h +++ b/src/gba/supervisor/config.h @@ -29,6 +29,7 @@ struct GBAOptions { int rewindBufferInterval; float fpsTarget; size_t audioBuffers; + unsigned sampleRate; int fullscreen; int width; diff --git a/src/platform/qt/AudioProcessor.h b/src/platform/qt/AudioProcessor.h index abbca9395..74d76a345 100644 --- a/src/platform/qt/AudioProcessor.h +++ b/src/platform/qt/AudioProcessor.h @@ -31,6 +31,7 @@ public: virtual void setInput(GBAThread* input); int getBufferSamples() const { return m_samples; } + virtual unsigned sampleRate() const = 0; public slots: virtual void start() = 0; @@ -39,7 +40,7 @@ public slots: virtual void setBufferSamples(int samples) = 0; virtual void inputParametersChanged() = 0; - virtual unsigned sampleRate() const = 0; + virtual void requestSampleRate(unsigned) = 0; protected: GBAThread* input() { return m_context; } diff --git a/src/platform/qt/AudioProcessorQt.cpp b/src/platform/qt/AudioProcessorQt.cpp index 281ca6bba..c28d934b9 100644 --- a/src/platform/qt/AudioProcessorQt.cpp +++ b/src/platform/qt/AudioProcessorQt.cpp @@ -20,6 +20,7 @@ AudioProcessorQt::AudioProcessorQt(QObject* parent) : AudioProcessor(parent) , m_audioOutput(nullptr) , m_device(nullptr) + , m_sampleRate(44100) { } @@ -45,7 +46,7 @@ void AudioProcessorQt::start() { if (!m_audioOutput) { QAudioFormat format; - format.setSampleRate(44100); + format.setSampleRate(m_sampleRate); format.setChannelCount(2); format.setSampleSize(16); format.setCodec("audio/pcm"); @@ -84,6 +85,15 @@ void AudioProcessorQt::inputParametersChanged() { } } +void AudioProcessorQt::requestSampleRate(unsigned rate) { + m_sampleRate = rate; + if (m_device) { + QAudioFormat format(m_audioOutput->format()); + format.setSampleRate(rate); + m_device->setFormat(format); + } +} + unsigned AudioProcessorQt::sampleRate() const { if (!m_audioOutput) { return 0; diff --git a/src/platform/qt/AudioProcessorQt.h b/src/platform/qt/AudioProcessorQt.h index ee9dde24d..52d7b606c 100644 --- a/src/platform/qt/AudioProcessorQt.h +++ b/src/platform/qt/AudioProcessorQt.h @@ -20,6 +20,7 @@ public: AudioProcessorQt(QObject* parent = nullptr); virtual void setInput(GBAThread* input); + virtual unsigned sampleRate() const override; public slots: virtual void start(); @@ -28,11 +29,12 @@ public slots: virtual void setBufferSamples(int samples); virtual void inputParametersChanged(); - virtual unsigned sampleRate() const override; + virtual void requestSampleRate(unsigned) override; private: QAudioOutput* m_audioOutput; AudioDevice* m_device; + unsigned m_sampleRate; }; } diff --git a/src/platform/qt/AudioProcessorSDL.cpp b/src/platform/qt/AudioProcessorSDL.cpp index 0caa9765c..2db807f3f 100644 --- a/src/platform/qt/AudioProcessorSDL.cpp +++ b/src/platform/qt/AudioProcessorSDL.cpp @@ -15,7 +15,7 @@ using namespace QGBA; AudioProcessorSDL::AudioProcessorSDL(QObject* parent) : AudioProcessor(parent) - , m_audio() + , m_audio{ 2048, 44100 } { } @@ -55,6 +55,18 @@ void AudioProcessorSDL::setBufferSamples(int samples) { void AudioProcessorSDL::inputParametersChanged() { } -unsigned AudioProcessorSDL::sampleRate() const { - return m_audio.obtainedSpec.freq; +void AudioProcessorSDL::requestSampleRate(unsigned rate) { + m_audio.sampleRate = rate; + if (m_audio.thread) { + GBASDLDeinitAudio(&m_audio); + GBASDLInitAudio(&m_audio, input()); + } +} + +unsigned AudioProcessorSDL::sampleRate() const { + if (m_audio.thread) { + return m_audio.obtainedSpec.freq; + } else { + return 0; + } } diff --git a/src/platform/qt/AudioProcessorSDL.h b/src/platform/qt/AudioProcessorSDL.h index 002dcd839..c98d00473 100644 --- a/src/platform/qt/AudioProcessorSDL.h +++ b/src/platform/qt/AudioProcessorSDL.h @@ -22,6 +22,8 @@ public: AudioProcessorSDL(QObject* parent = nullptr); ~AudioProcessorSDL(); + virtual unsigned sampleRate() const override; + public slots: virtual void start(); virtual void pause(); @@ -29,7 +31,7 @@ public slots: virtual void setBufferSamples(int samples); virtual void inputParametersChanged(); - virtual unsigned sampleRate() const override; + virtual void requestSampleRate(unsigned) override; private: GBASDLAudio m_audio; diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 3200f45e7..786dd2f7b 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -53,6 +53,7 @@ GBAApp::GBAApp(int& argc, char* argv[]) return; } + AudioProcessor::setDriver(static_cast(m_configController.getQtOption("audioDriver").toInt())); Window* w = new Window(&m_configController); connect(w, &Window::destroyed, [this]() { m_windows[0] = nullptr; @@ -67,9 +68,6 @@ GBAApp::GBAApp(int& argc, char* argv[]) freeArguments(&args); w->show(); - AudioProcessor::setDriver(static_cast(m_configController.getQtOption("audioDriver").toInt())); - w->controller()->reloadAudioDriver(); - w->controller()->setMultiplayerController(&m_multiplayer); } diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 6432a2ba6..63df80baa 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -87,7 +87,9 @@ GameController::GameController(QObject* parent) m_threadContext.startCallback = [](GBAThread* context) { GameController* controller = static_cast(context->userData); - controller->m_audioProcessor->setInput(context); + if (controller->m_audioProcessor) { + controller->m_audioProcessor->setInput(context); + } context->gba->luminanceSource = &controller->m_lux; GBARTCGenericSourceInit(&controller->m_rtc, context->gba); context->gba->rtcSource = &controller->m_rtc.d; @@ -588,10 +590,21 @@ void GameController::clearKeys() { } void GameController::setAudioBufferSamples(int samples) { - threadInterrupt(); - redoSamples(samples); - threadContinue(); - QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples)); + if (m_audioProcessor) { + threadInterrupt(); + redoSamples(samples); + threadContinue(); + QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples)); + } +} + +void GameController::setAudioSampleRate(unsigned rate) { + if (m_audioProcessor) { + threadInterrupt(); + redoSamples(m_audioProcessor->getBufferSamples()); + threadContinue(); + QMetaObject::invokeMethod(m_audioProcessor, "requestSampleRate", Q_ARG(unsigned, rate)); + } } void GameController::setAudioChannelEnabled(int channel, bool enable) { @@ -644,7 +657,9 @@ void GameController::setFPSTarget(float fps) { if (m_turbo && m_turboSpeed > 0) { m_threadContext.fpsTarget *= m_turboSpeed; } - redoSamples(m_audioProcessor->getBufferSamples()); + if (m_audioProcessor) { + redoSamples(m_audioProcessor->getBufferSamples()); + } threadContinue(); } @@ -801,7 +816,9 @@ void GameController::enableTurbo() { m_threadContext.sync.audioWait = true; m_threadContext.sync.videoFrameWait = false; } - redoSamples(m_audioProcessor->getBufferSamples()); + if (m_audioProcessor) { + redoSamples(m_audioProcessor->getBufferSamples()); + } threadContinue(); } @@ -830,11 +847,21 @@ void GameController::screenshot() { #endif void GameController::reloadAudioDriver() { - QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); - int samples = m_audioProcessor->getBufferSamples(); - delete m_audioProcessor; + int samples = 0; + unsigned sampleRate = 0; + if (m_audioProcessor) { + QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); + samples = m_audioProcessor->getBufferSamples(); + sampleRate = m_audioProcessor->sampleRate(); + delete m_audioProcessor; + } m_audioProcessor = AudioProcessor::create(); - m_audioProcessor->setBufferSamples(samples); + if (samples) { + m_audioProcessor->setBufferSamples(samples); + } + if (sampleRate) { + m_audioProcessor->requestSampleRate(sampleRate); + } m_audioProcessor->moveToThread(m_audioThread); connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start())); connect(this, SIGNAL(gameStopped(GBAThread*)), m_audioProcessor, SLOT(pause())); diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index 9267668b5..a4de17fff 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -119,6 +119,7 @@ public slots: void keyReleased(int key); void clearKeys(); void setAudioBufferSamples(int samples); + void setAudioSampleRate(unsigned rate); void setAudioChannelEnabled(int channel, bool enable = true); void setVideoLayerEnabled(int layer, bool enable = true); void setFPSTarget(float fps); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 8639a4e32..6fd233b60 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -127,6 +127,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) connect(this, SIGNAL(shutdown()), m_controller, SLOT(closeGame())); connect(this, SIGNAL(shutdown()), m_logView, SLOT(hide())); connect(this, SIGNAL(audioBufferSamplesChanged(int)), m_controller, SLOT(setAudioBufferSamples(int))); + connect(this, SIGNAL(sampleRateChanged(unsigned)), m_controller, SLOT(setAudioSampleRate(unsigned))); connect(this, SIGNAL(fpsTargetChanged(float)), m_controller, SLOT(setFPSTarget(float))); connect(&m_fpsTimer, SIGNAL(timeout()), this, SLOT(showFPS())); connect(m_display, &Display::hideCursor, [this]() { @@ -195,6 +196,7 @@ void Window::loadConfig() { m_controller->loadBIOS(opts->bios); } + // TODO: Move these to ConfigController if (opts->fpsTarget) { emit fpsTargetChanged(opts->fpsTarget); } @@ -203,6 +205,10 @@ void Window::loadConfig() { emit audioBufferSamplesChanged(opts->audioBuffers); } + if (opts->sampleRate) { + emit sampleRateChanged(opts->sampleRate); + } + if (opts->width && opts->height) { resizeFrame(opts->width, opts->height); } diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 16295f264..ebc923776 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -54,6 +54,7 @@ signals: void startDrawing(GBAThread*); void shutdown(); void audioBufferSamplesChanged(int samples); + void sampleRateChanged(unsigned samples); void fpsTargetChanged(float target); public slots: diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index 058055ac2..78dda4706 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -112,6 +112,10 @@ int main(int argc, char** argv) { bool didFail = false; renderer.audio.samples = context.audioBuffers; + renderer.audio.sampleRate = 44100; + if (opts.sampleRate) { + renderer.audio.sampleRate = opts.sampleRate; + } if (!GBASDLInitAudio(&renderer.audio, &context)) { didFail = true; } diff --git a/src/platform/sdl/sdl-audio.c b/src/platform/sdl/sdl-audio.c index 6e0fdebb2..321679a96 100644 --- a/src/platform/sdl/sdl-audio.c +++ b/src/platform/sdl/sdl-audio.c @@ -22,7 +22,7 @@ bool GBASDLInitAudio(struct GBASDLAudio* context, struct GBAThread* threadContex return false; } - context->desiredSpec.freq = 44100; + context->desiredSpec.freq = context->sampleRate; context->desiredSpec.format = AUDIO_S16SYS; context->desiredSpec.channels = 2; context->desiredSpec.samples = context->samples; diff --git a/src/platform/sdl/sdl-audio.h b/src/platform/sdl/sdl-audio.h index 6730333eb..f2f0b8df2 100644 --- a/src/platform/sdl/sdl-audio.h +++ b/src/platform/sdl/sdl-audio.h @@ -15,6 +15,7 @@ struct GBASDLAudio { // Input size_t samples; + unsigned sampleRate; // State SDL_AudioSpec desiredSpec; From 2a4ecde790e92a389500aac625f372103d7cf0e5 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 9 Aug 2015 21:47:16 -0700 Subject: [PATCH 38/58] Qt: Change default buffer size to 1536, remove from menu and add more presets --- src/platform/qt/ConfigController.cpp | 2 +- src/platform/qt/SettingsView.ui | 19 +++++++++++++++++-- src/platform/qt/Window.cpp | 14 -------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 65ee51528..021908680 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -107,7 +107,7 @@ ConfigController::ConfigController(QObject* parent) m_opts.audioSync = GameController::AUDIO_SYNC; m_opts.videoSync = GameController::VIDEO_SYNC; m_opts.fpsTarget = 60; - m_opts.audioBuffers = 2048; + m_opts.audioBuffers = 1536; m_opts.volume = GBA_AUDIO_VOLUME_MAX; m_opts.logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS; m_opts.rewindEnable = false; diff --git a/src/platform/qt/SettingsView.ui b/src/platform/qt/SettingsView.ui index bfd7af451..b59dae40a 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -62,26 +62,41 @@ true - 2048 + 1536 - 2 + 3 512 + + + 768 + + 1024 + + + 1536 + + 2048 + + + 3072 + + 4096 diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 6fd233b60..8ee53dca2 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -987,20 +987,6 @@ void Window::setupMenu(QMenuBar* menubar) { avMenu->addSeparator(); - QMenu* buffersMenu = avMenu->addMenu(tr("Audio buffer &size")); - ConfigOption* buffers = m_config->addOption("audioBuffers"); - buffers->connect([this](const QVariant& value) { - emit audioBufferSamplesChanged(value.toInt()); - }, this); - buffers->addValue(tr("512"), 512, buffersMenu); - buffers->addValue(tr("768"), 768, buffersMenu); - buffers->addValue(tr("1024"), 1024, buffersMenu); - buffers->addValue(tr("2048"), 2048, buffersMenu); - buffers->addValue(tr("4096"), 4096, buffersMenu); - m_config->updateOption("audioBuffers"); - - avMenu->addSeparator(); - QMenu* target = avMenu->addMenu(tr("FPS target")); ConfigOption* fpsTargetOption = m_config->addOption("fpsTarget"); fpsTargetOption->connect([this](const QVariant& value) { From 709f4f7a83ed10ab79f38343d33d9b582f746534 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 9 Aug 2015 21:54:50 -0700 Subject: [PATCH 39/58] Qt: Add sample rate option to settings --- src/platform/qt/SettingsView.cpp | 2 + src/platform/qt/SettingsView.ui | 93 ++++++++++++++++++++++++-------- src/platform/qt/Window.cpp | 10 ++++ 3 files changed, 84 insertions(+), 21 deletions(-) diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 53ed8fac2..f60a43cd3 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -22,6 +22,7 @@ SettingsView::SettingsView(ConfigController* controller, QWidget* parent) loadSetting("useBios", m_ui.useBios); loadSetting("skipBios", m_ui.skipBios); loadSetting("audioBuffers", m_ui.audioBufferSize); + loadSetting("sampleRate", m_ui.sampleRate); loadSetting("videoSync", m_ui.videoSync); loadSetting("audioSync", m_ui.audioSync); loadSetting("frameskip", m_ui.frameskip); @@ -102,6 +103,7 @@ void SettingsView::updateConfig() { saveSetting("useBios", m_ui.useBios); saveSetting("skipBios", m_ui.skipBios); saveSetting("audioBuffers", m_ui.audioBufferSize); + saveSetting("sampleRate", m_ui.sampleRate); saveSetting("videoSync", m_ui.videoSync); saveSetting("audioSync", m_ui.audioSync); saveSetting("frameskip", m_ui.frameskip); diff --git a/src/platform/qt/SettingsView.ui b/src/platform/qt/SettingsView.ui index b59dae40a..f9302a87c 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -114,13 +114,20 @@ + + + Sample rate: + + + + Volume: - + @@ -147,28 +154,38 @@ - + Qt::Horizontal - + Display driver: - + + + + + 0 + 0 + + + + + Frameskip: - + @@ -189,14 +206,14 @@ - + FPS target: - + @@ -220,21 +237,21 @@ - + Qt::Horizontal - + Sync: - + @@ -252,29 +269,63 @@ - + Lock aspect ratio - + Resample video - - - - - 0 - 0 - - - + + + + + + true + + + 44100 + + + 2 + + + + 22050 + + + + + 32000 + + + + + 44100 + + + + + 48000 + + + + + + + + Hz + + + + diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 8ee53dca2..94673f371 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -1122,6 +1122,16 @@ void Window::setupMenu(QMenuBar* menubar) { m_controller->setSkipBIOS(value.toBool()); }, this); + ConfigOption* buffers = m_config->addOption("audioBuffers"); + buffers->connect([this](const QVariant& value) { + emit audioBufferSamplesChanged(value.toInt()); + }, this); + + ConfigOption* sampleRate = m_config->addOption("sampleRate"); + sampleRate->connect([this](const QVariant& value) { + emit sampleRateChanged(value.toUInt()); + }, this); + ConfigOption* volume = m_config->addOption("volume"); volume->connect([this](const QVariant& value) { m_controller->setVolume(value.toInt()); From 9352f75e6fa0cd4e2f6b482ef2f8cc3e62626e25 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 9 Aug 2015 23:25:03 -0700 Subject: [PATCH 40/58] Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls --- CHANGES | 1 + src/platform/qt/GBAApp.cpp | 2 ++ src/platform/qt/GameController.cpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 466341681..46842b914 100644 --- a/CHANGES +++ b/CHANGES @@ -69,6 +69,7 @@ Bugfixes: - Qt: Fix analog buttons not getting unmapped - GBA Video: Prevent tiles < 512 from being used in modes 3 - 5 - Qt: Fix passing command line options + - Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 786dd2f7b..a651f4698 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -15,6 +15,7 @@ #include extern "C" { +#include "gba/supervisor/thread.h" #include "platform/commandline.h" #include "util/socket.h" } @@ -37,6 +38,7 @@ GBAApp::GBAApp(int& argc, char* argv[]) SocketSubsystemInit(); qRegisterMetaType("const uint32_t*"); + qRegisterMetaType("GBAThread*"); QApplication::setApplicationName(projectName); QApplication::setApplicationVersion(projectVersion); diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 63df80baa..3253a5b9f 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -114,25 +114,25 @@ GameController::GameController(QObject* parent) vf->truncate(vf, 0); } } - controller->gameStarted(context); + QMetaObject::invokeMethod(controller, "gameStarted", Q_ARG(GBAThread*, context)); }; m_threadContext.cleanCallback = [](GBAThread* context) { GameController* controller = static_cast(context->userData); - controller->gameStopped(context); + QMetaObject::invokeMethod(controller, "gameStopped", Q_ARG(GBAThread*, context)); }; m_threadContext.frameCallback = [](GBAThread* context) { GameController* controller = static_cast(context->userData); if (GBASyncDrawingFrame(&controller->m_threadContext.sync)) { memcpy(controller->m_frontBuffer, controller->m_drawContext, 256 * VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); - controller->frameAvailable(controller->m_frontBuffer); + QMetaObject::invokeMethod(controller, "frameAvailable", Q_ARG(const uint32_t*, controller->m_frontBuffer)); } else { - controller->frameAvailable(nullptr); + QMetaObject::invokeMethod(controller, "frameAvailable", Q_ARG(const uint32_t*, nullptr)); } if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) { GBAThreadPauseFromThread(context); - controller->gamePaused(&controller->m_threadContext); + QMetaObject::invokeMethod(controller, "gamePaused", Q_ARG(GBAThread*, context)); } }; @@ -161,7 +161,7 @@ GameController::GameController(QObject* parent) va_copy(argc, args); int immediate = va_arg(argc, int); va_end(argc); - controller->unimplementedBiosCall(immediate); + QMetaObject::invokeMethod(controller, "unimplementedBiosCall", Q_ARG(int, immediate)); } else if (level == GBA_LOG_STATUS) { // Slot 0 is reserved for suspend points if (strncmp(savestateMessage, format, strlen(savestateMessage)) == 0) { @@ -189,9 +189,9 @@ GameController::GameController(QObject* parent) } QString message(QString().vsprintf(format, args)); if (level == GBA_LOG_STATUS) { - controller->statusPosted(message); + QMetaObject::invokeMethod(controller, "statusPosted", Q_ARG(const QString&, message)); } - controller->postLog(level, message); + QMetaObject::invokeMethod(controller, "postLog", Q_ARG(int, level), Q_ARG(const QString&, message)); }; connect(&m_rewindTimer, &QTimer::timeout, [this]() { From 1f58db096f12dfe655fd81fc8729c704e581b676 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 10 Aug 2015 01:38:08 -0700 Subject: [PATCH 41/58] Qt: Code cleanup --- src/platform/qt/DisplayGL.cpp | 3 --- src/platform/qt/Window.cpp | 17 +++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index 8a1bd5ebb..d0a5f4db3 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -244,9 +244,6 @@ void PainterGL::stop() { void PainterGL::pause() { m_active = false; - if (!m_queue.isEmpty()) { - QMetaObject::invokeMethod(this, "pause", Qt::QueuedConnection); - } } void PainterGL::unpause() { diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 94673f371..96226f596 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -100,6 +100,14 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) connect(m_controller, SIGNAL(gameStopped(GBAThread*)), &m_inputController, SLOT(resumeScreensaver())); connect(m_controller, SIGNAL(stateLoaded(GBAThread*)), m_display, SLOT(forceDraw())); connect(m_controller, SIGNAL(rewound(GBAThread*)), m_display, SLOT(forceDraw())); + connect(m_controller, &GameController::gamePaused, [this]() { + QImage currentImage(reinterpret_cast(m_controller->drawContext()), VIDEO_HORIZONTAL_PIXELS, + VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGB32); + QPixmap pixmap; + pixmap.convertFromImage(currentImage.rgbSwapped()); + m_screenWidget->setPixmap(pixmap); + m_screenWidget->setLockAspectRatio(3, 2); + }); connect(m_controller, SIGNAL(gamePaused(GBAThread*)), m_display, SLOT(pauseDrawing())); #ifndef Q_OS_MAC connect(m_controller, SIGNAL(gamePaused(GBAThread*)), menuBar(), SLOT(show())); @@ -827,13 +835,6 @@ void Window::setupMenu(QMenuBar* menubar) { connect(pause, SIGNAL(triggered(bool)), m_controller, SLOT(setPaused(bool))); connect(m_controller, &GameController::gamePaused, [this, pause]() { pause->setChecked(true); - - QImage currentImage(reinterpret_cast(m_controller->drawContext()), VIDEO_HORIZONTAL_PIXELS, - VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGB32); - QPixmap pixmap; - pixmap.convertFromImage(currentImage.rgbSwapped()); - m_screenWidget->setPixmap(pixmap); - m_screenWidget->setLockAspectRatio(3, 2); }); connect(m_controller, &GameController::gameUnpaused, [pause]() { pause->setChecked(false); }); m_gameActions.append(pause); @@ -1174,7 +1175,7 @@ void Window::setupMenu(QMenuBar* menubar) { void Window::attachWidget(QWidget* widget) { m_screenWidget->layout()->addWidget(widget); - unsetCursor(); + m_screenWidget->unsetCursor(); static_cast(m_screenWidget->layout())->setCurrentWidget(widget); } From d4e7bf68622768a1d9e7a97c0f1160ef7b478eaa Mon Sep 17 00:00:00 2001 From: sergiobenrocha2 Date: Mon, 10 Aug 2015 22:36:19 -0300 Subject: [PATCH 42/58] Debian packaging update. --- tools/debian/control | 2 +- tools/debian/mgba-qt.install | 2 +- tools/debian/mgba-qt.manpages | 1 + tools/debian/mgba-sdl.manpages | 1 + tools/debian/rules | 7 ++++++- 5 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tools/debian/mgba-qt.manpages create mode 100644 tools/debian/mgba-sdl.manpages diff --git a/tools/debian/control b/tools/debian/control index 747d284f9..79b508833 100644 --- a/tools/debian/control +++ b/tools/debian/control @@ -20,7 +20,7 @@ Build-Depends: cmake (>= 2.8.11), qtmultimedia5-dev, zlib1g-dev Standards-Version: 3.9.6 -Homepage: https://endrift.com/mgba/ +Homepage: http://mgba.io/ Package: libmgba Architecture: any diff --git a/tools/debian/mgba-qt.install b/tools/debian/mgba-qt.install index c17eafba0..7216bba6f 100644 --- a/tools/debian/mgba-qt.install +++ b/tools/debian/mgba-qt.install @@ -1,3 +1,3 @@ usr/bin/mgba-qt -usr/share/applications/mgba-qt.desktop +res/mgba-qt.desktop usr/share/applications usr/share/icons diff --git a/tools/debian/mgba-qt.manpages b/tools/debian/mgba-qt.manpages new file mode 100644 index 000000000..2c3d1c5ed --- /dev/null +++ b/tools/debian/mgba-qt.manpages @@ -0,0 +1 @@ +doc/mgba-qt.6 diff --git a/tools/debian/mgba-sdl.manpages b/tools/debian/mgba-sdl.manpages new file mode 100644 index 000000000..96e337fb7 --- /dev/null +++ b/tools/debian/mgba-sdl.manpages @@ -0,0 +1 @@ +doc/mgba.6 diff --git a/tools/debian/rules b/tools/debian/rules index 0c82ec22e..ebe066d37 100755 --- a/tools/debian/rules +++ b/tools/debian/rules @@ -7,12 +7,17 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. */ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH) + +ifeq ($(ARCH),armhf) + ARM=-DBUILD_GL=OFF -DBUILD_GLES2=ON +endif %: dh $@ --buildsystem=cmake --builddirectory=obj --parallel override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_SKIP_RPATH=ON -DBUILD_LIBRETRO=ON + dh_auto_configure -- -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_SKIP_RPATH=ON -DBUILD_LIBRETRO=ON $(ARM) sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \ debian/libretro-mgba.install.in > debian/libretro-mgba.install sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \ From c7b009b20784e3fcd38569858ce17380598b3c43 Mon Sep 17 00:00:00 2001 From: sergiobenrocha2 Date: Tue, 11 Aug 2015 01:53:33 -0300 Subject: [PATCH 43/58] Bump the version in debian/changelog. --- tools/debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/debian/changelog b/tools/debian/changelog index 0b703b13a..18bed0d13 100644 --- a/tools/debian/changelog +++ b/tools/debian/changelog @@ -1,5 +1,5 @@ -mgba (0.2.1-1) UNRELEASED; urgency=low +mgba (0.3.0-1) UNRELEASED; urgency=low * Initial release (closes: Bug#787470). - -- Sérgio Benjamim Mon, 01 Jun 2015 18:40:00 -0300 + -- Sérgio Benjamim Mon, 17 Aug 2015 18:40:00 -0300 From 313877657f170245b5e4892af499db3768acf6ca Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 10 Aug 2015 22:15:27 -0700 Subject: [PATCH 44/58] Qt: No need to set global window icon on OS X --- src/platform/qt/GBAApp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index a651f4698..dc0399273 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -34,7 +34,9 @@ GBAApp::GBAApp(int& argc, char* argv[]) SDL_Init(SDL_INIT_NOPARACHUTE); #endif +#ifndef Q_OS_MAC setWindowIcon(QIcon(":/res/mgba-1024.png")); +#endif SocketSubsystemInit(); qRegisterMetaType("const uint32_t*"); From 1929047896659a90d64858eb3a90c186a14d996d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 10 Aug 2015 22:15:50 -0700 Subject: [PATCH 45/58] Qt: Use Format_RGBX8888 to avoid having to swap channels --- src/platform/qt/Window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 96226f596..ca73470b1 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -102,9 +102,9 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) connect(m_controller, SIGNAL(rewound(GBAThread*)), m_display, SLOT(forceDraw())); connect(m_controller, &GameController::gamePaused, [this]() { QImage currentImage(reinterpret_cast(m_controller->drawContext()), VIDEO_HORIZONTAL_PIXELS, - VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGB32); + VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGBX8888); QPixmap pixmap; - pixmap.convertFromImage(currentImage.rgbSwapped()); + pixmap.convertFromImage(currentImage); m_screenWidget->setPixmap(pixmap); m_screenWidget->setLockAspectRatio(3, 2); }); From 50005e0703fe9d6827875f4b2f870895e4033d0e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 10 Aug 2015 23:04:39 -0700 Subject: [PATCH 46/58] Qt: More cleanup --- src/platform/qt/LoadSaveState.cpp | 2 +- src/platform/qt/SavestateButton.cpp | 2 +- src/platform/qt/Window.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/LoadSaveState.cpp b/src/platform/qt/LoadSaveState.cpp index 054dd13b4..c14f7ccd7 100644 --- a/src/platform/qt/LoadSaveState.cpp +++ b/src/platform/qt/LoadSaveState.cpp @@ -26,6 +26,7 @@ LoadSaveState::LoadSaveState(GameController* controller, QWidget* parent) , m_currentFocus(controller->stateSlot() - 1) , m_mode(LoadSave::LOAD) { + setAttribute(Qt::WA_TranslucentBackground); m_ui.setupUi(this); m_slots[0] = m_ui.state1; @@ -208,6 +209,5 @@ void LoadSaveState::showEvent(QShowEvent* event) { void LoadSaveState::paintEvent(QPaintEvent*) { QPainter painter(this); QRect full(QPoint(), size()); - painter.drawPixmap(full, m_currentImage); painter.fillRect(full, QColor(0, 0, 0, 128)); } diff --git a/src/platform/qt/SavestateButton.cpp b/src/platform/qt/SavestateButton.cpp index c9f6560b0..d99ac34f6 100644 --- a/src/platform/qt/SavestateButton.cpp +++ b/src/platform/qt/SavestateButton.cpp @@ -13,7 +13,7 @@ using namespace QGBA; SavestateButton::SavestateButton(QWidget* parent) : QAbstractButton(parent) { - // Nothing to do + setAttribute(Qt::WA_TranslucentBackground); } void SavestateButton::paintEvent(QPaintEvent*) { diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index ca73470b1..ccec27219 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -685,7 +685,7 @@ void Window::openStateWindow(LoadSave ls) { connect(this, SIGNAL(shutdown()), m_stateWindow, SLOT(close())); connect(m_controller, SIGNAL(gameStopped(GBAThread*)), m_stateWindow, SLOT(close())); connect(m_stateWindow, &LoadSaveState::closed, [this]() { - m_screenWidget->layout()->removeWidget(m_stateWindow); + detachWidget(m_stateWindow); m_stateWindow = nullptr; QMetaObject::invokeMethod(this, "setFocus", Qt::QueuedConnection); }); From 013948f129f5449d7ba718fca940c0ad5c6cf8e9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Aug 2015 01:14:02 -0700 Subject: [PATCH 47/58] GBA Memory: Run multiple DMAs in a tight loop if they all occur before present --- CHANGES | 1 + src/gba/memory.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 46842b914..33d9f2668 100644 --- a/CHANGES +++ b/CHANGES @@ -118,6 +118,7 @@ Misc: - Qt: Increase usability of key mapper - Qt: Show checkmark for window sizes - Qt: Set window path to loaded ROM + - GBA Memory: Run multiple DMAs in a tight loop if they all occur before present 0.2.1: (2015-05-13) Bugfixes: diff --git a/src/gba/memory.c b/src/gba/memory.c index a1195eeb8..9da33f31b 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -1405,7 +1405,7 @@ int32_t GBAMemoryRunDMAs(struct GBA* gba, int32_t cycles) { } memory->nextDMA -= cycles; memory->eventDiff += cycles; - if (memory->nextDMA <= 0) { + while (memory->nextDMA <= 0) { struct GBADMA* dma = &memory->dma[memory->activeDMA]; GBAMemoryServiceDMA(gba, memory->activeDMA, dma); GBAMemoryUpdateDMAs(gba, memory->eventDiff); From e36f3c8211d6b10dbbd3e6c123773bc3b387cee8 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Aug 2015 01:14:40 -0700 Subject: [PATCH 48/58] GBA Video: Fix timing on first scanline --- CHANGES | 1 + src/gba/video.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 33d9f2668..e3fde14ff 100644 --- a/CHANGES +++ b/CHANGES @@ -70,6 +70,7 @@ Bugfixes: - GBA Video: Prevent tiles < 512 from being used in modes 3 - 5 - Qt: Fix passing command line options - Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls + - GBA Video: Fix timing on first scanline Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/gba/video.c b/src/gba/video.c index 39856c2a9..fef6e1b54 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -67,7 +67,7 @@ void GBAVideoReset(struct GBAVideo* video) { video->lastHblank = 0; video->nextHblank = VIDEO_HDRAW_LENGTH; video->nextEvent = video->nextHblank; - video->eventDiff = video->nextEvent; + video->eventDiff = 0; video->nextHblankIRQ = 0; video->nextVblankIRQ = 0; From 6822b8cabe2bca29944fe88f18226f1b89eab055 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Aug 2015 01:16:57 -0700 Subject: [PATCH 49/58] GBA: Ensure cycles never go negative --- CHANGES | 1 + src/gba/gba.c | 5 +++++ src/gba/serialize.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/CHANGES b/CHANGES index e3fde14ff..c0be41bf4 100644 --- a/CHANGES +++ b/CHANGES @@ -71,6 +71,7 @@ Bugfixes: - Qt: Fix passing command line options - Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls - GBA Video: Fix timing on first scanline + - GBA: Ensure cycles never go negative Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/gba/gba.c b/src/gba/gba.c index c221f587f..b5fdf83ac 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -184,6 +184,11 @@ static void GBAProcessEvents(struct ARMCore* cpu) { int32_t cycles = cpu->nextEvent; int32_t nextEvent = INT_MAX; int32_t testEvent; +#ifndef NDEBUG + if (cycles < 0) { + GBALog(gba, GBA_LOG_FATAL, "Negative cycles passed: %i", cycles); + } +#endif gba->bus = cpu->prefetch[1]; if (cpu->executionMode == MODE_THUMB) { diff --git a/src/gba/serialize.c b/src/gba/serialize.c index e7aa56fac..e58635bc4 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -87,6 +87,10 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are negative"); error = true; } + if (state->cpu.nextEvent < 0) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: Next event is negative"); + error = true; + } if (state->video.eventDiff < 0) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: video eventDiff is negative"); error = true; From ebfcc70b3d4a6ef57b6ae05f32e912518174ed73 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Aug 2015 21:12:59 -0700 Subject: [PATCH 50/58] GBA Audio: Process multiple audio events at once, if necessary --- CHANGES | 1 + src/gba/audio.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c0be41bf4..c9a836456 100644 --- a/CHANGES +++ b/CHANGES @@ -121,6 +121,7 @@ Misc: - Qt: Show checkmark for window sizes - Qt: Set window path to loaded ROM - GBA Memory: Run multiple DMAs in a tight loop if they all occur before present + - GBA Audio: Process multiple audio events at once, if necessary 0.2.1: (2015-05-13) Bugfixes: diff --git a/src/gba/audio.c b/src/gba/audio.c index 372c7ef25..6fac940b3 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -167,7 +167,7 @@ void GBAAudioResizeBuffer(struct GBAAudio* audio, size_t samples) { int32_t GBAAudioProcessEvents(struct GBAAudio* audio, int32_t cycles) { audio->nextEvent -= cycles; audio->eventDiff += cycles; - if (audio->nextEvent <= 0) { + while (audio->nextEvent <= 0) { audio->nextEvent = INT_MAX; if (audio->enable) { if (audio->playingCh1 && !audio->ch1.envelope.dead) { From 4fd479897c6972377ac625f43306aa794bc4d5c0 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Aug 2015 21:15:09 -0700 Subject: [PATCH 51/58] GBA: Process multiple timer events at once, if necessary --- CHANGES | 1 + src/gba/gba.c | 2 +- src/gba/serialize.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c9a836456..77643b674 100644 --- a/CHANGES +++ b/CHANGES @@ -122,6 +122,7 @@ Misc: - Qt: Set window path to loaded ROM - GBA Memory: Run multiple DMAs in a tight loop if they all occur before present - GBA Audio: Process multiple audio events at once, if necessary + - GBA: Process multiple timer events at once, if necessary 0.2.1: (2015-05-13) Bugfixes: diff --git a/src/gba/gba.c b/src/gba/gba.c index b5fdf83ac..a7356ad3a 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -244,7 +244,7 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) { if (timer->enable) { timer->nextEvent -= cycles; timer->lastEvent -= cycles; - if (timer->nextEvent <= 0) { + while (timer->nextEvent <= 0) { timer->lastEvent = timer->nextEvent; timer->nextEvent += timer->overflowInterval; gba->memory.io[REG_TM0CNT_LO >> 1] = timer->reload; diff --git a/src/gba/serialize.c b/src/gba/serialize.c index e58635bc4..96e7c0daa 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -103,6 +103,10 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: overflowInterval is negative"); error = true; } + if (state->timers[0].nextEvent < 0 || state->timers[1].nextEvent < 0 || state->timers[2].nextEvent < 0 || state->timers[3].nextEvent < 0) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: timer nextEvent is negative"); + error = true; + } if (state->audio.eventDiff < 0) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: audio eventDiff is negative"); error = true; From 0eb76806beb6af13d8aacf535795fc0f84b65233 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 13 Aug 2015 20:01:59 -0700 Subject: [PATCH 52/58] Qt: Fix changing whether a BIOS is used while the game is running --- src/platform/qt/GameController.cpp | 9 +++++++-- src/platform/qt/Window.cpp | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 3253a5b9f..57216ddb3 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -670,9 +670,14 @@ void GameController::setSkipBIOS(bool set) { } void GameController::setUseBIOS(bool use) { - threadInterrupt(); + if (use == m_useBios) { + return; + } m_useBios = use; - threadContinue(); + if (m_gameOpen) { + closeGame(); + openGame(); + } } void GameController::loadState(int slot) { diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index ccec27219..6307fdf12 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -1123,6 +1123,11 @@ void Window::setupMenu(QMenuBar* menubar) { m_controller->setSkipBIOS(value.toBool()); }, this); + ConfigOption* useBios = m_config->addOption("useBios"); + useBios->connect([this](const QVariant& value) { + m_controller->setUseBIOS(value.toBool()); + }, this); + ConfigOption* buffers = m_config->addOption("audioBuffers"); buffers->connect([this](const QVariant& value) { emit audioBufferSamplesChanged(value.toInt()); From e528f673b8c478a77b0e100590961edfe957259d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 14:48:01 -0700 Subject: [PATCH 53/58] Util: Fix formatting of floats --- CHANGES | 1 + src/util/formatting.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 77643b674..e80077b62 100644 --- a/CHANGES +++ b/CHANGES @@ -72,6 +72,7 @@ Bugfixes: - Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls - GBA Video: Fix timing on first scanline - GBA: Ensure cycles never go negative + - Util: Fix formatting of floats Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/util/formatting.c b/src/util/formatting.c index d14843d3f..0a0008c4f 100644 --- a/src/util/formatting.c +++ b/src/util/formatting.c @@ -9,20 +9,20 @@ int ftostr_l(char* restrict str, size_t size, float f, locale_t locale) { #ifdef HAVE_SNPRINTF_L - return snprintf_l(str, size, locale, "%*.g", FLT_DIG, f); + return snprintf_l(str, size, locale, "%.*g", FLT_DIG, f); #elif defined(HAVE_LOCALE) locale_t old = uselocale(locale); - int res = snprintf(str, size, "%*.g", FLT_DIG, f); + int res = snprintf(str, size, "%.*g", FLT_DIG, f); uselocale(old); return res; #elif defined(HAVE_SETLOCALE) char* old = setlocale(LC_NUMERIC, locale); - int res = snprintf(str, size, "%*.g", FLT_DIG, f); + int res = snprintf(str, size, "%.*g", FLT_DIG, f); setlocale(LC_NUMERIC, old); return res; #else UNUSED(locale); - return snprintf(str, size, "%*.g", FLT_DIG, f); + return snprintf(str, size, "%.*g", FLT_DIG, f); #endif } From e18c10e5e15fb7e7f8ae18699bc49a737916afd4 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 15:31:24 -0700 Subject: [PATCH 54/58] Qt: Set default sample rate --- src/platform/qt/ConfigController.cpp | 1 + src/platform/qt/GameController.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 021908680..2a0ae0184 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -108,6 +108,7 @@ ConfigController::ConfigController(QObject* parent) m_opts.videoSync = GameController::VIDEO_SYNC; m_opts.fpsTarget = 60; m_opts.audioBuffers = 1536; + m_opts.sampleRate = 44100; m_opts.volume = GBA_AUDIO_VOLUME_MAX; m_opts.logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS; m_opts.rewindEnable = false; diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 57216ddb3..b64d89193 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -599,6 +599,9 @@ void GameController::setAudioBufferSamples(int samples) { } void GameController::setAudioSampleRate(unsigned rate) { + if (!rate) { + return; + } if (m_audioProcessor) { threadInterrupt(); redoSamples(m_audioProcessor->getBufferSamples()); From 72f8657017040aad0999a9f0474332c8275e8f89 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 15:31:42 -0700 Subject: [PATCH 55/58] All: Set default git info to unknown --- version.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/version.cmake b/version.cmake index 5ec40e6bf..69c41c4a7 100644 --- a/version.cmake +++ b/version.cmake @@ -32,6 +32,16 @@ else() endif() endif() +if(NOT GIT_COMMIT) + set(GIT_COMMIT "(unknown)") +endif() +if(NOT GIT_COMMIT_SHORT) + set(GIT_COMMIT_SHORT "(unknown)") +endif() +if(NOT GIT_BRANCH) + set(GIT_BRANCH "(unknown)") +endif() + if(CONFIG_FILE AND OUT_FILE) configure_file("${CONFIG_FILE}" "${OUT_FILE}") endif() From ae1fecd4c8c02d1ddf321cad835eb9f63730f320 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 18:03:49 -0700 Subject: [PATCH 56/58] ARM7: Fix decoding some more load/store instructions --- src/arm/decoder-thumb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm/decoder-thumb.c b/src/arm/decoder-thumb.c index 626004f2c..27338ed4f 100644 --- a/src/arm/decoder-thumb.c +++ b/src/arm/decoder-thumb.c @@ -31,7 +31,7 @@ DEFINE_THUMB_DECODER(NAME, MNEMONIC, \ info->op1.reg = opcode & 0x0007; \ info->memory.baseReg = (opcode >> 3) & 0x0007; \ - info->memory.offset.immediate = ((opcode >> 6) & 0x0007) * WIDTH; \ + info->memory.offset.immediate = ((opcode >> 6) & 0x001F) * WIDTH; \ info->memory.width = (enum ARMMemoryAccessType) WIDTH; \ info->operandFormat = ARM_OPERAND_REGISTER_1 | \ ARM_OPERAND_AFFECTED_1 | \ From 9cda63f6c0a6d12cbb25438d0a85fef762f46f04 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 18:06:06 -0700 Subject: [PATCH 57/58] GBA Memory: Fix optimizations breaking GBALoad16 (fixes #82) --- src/gba/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gba/memory.c b/src/gba/memory.c index 9da33f31b..eda36f909 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -446,7 +446,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); LOAD_BAD; - uint32_t v2 = value; + volatile uint32_t v2 = value; LOAD_16(value, address & 2, &v2); } break; @@ -506,7 +506,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); LOAD_BAD; - uint32_t v2 = value; + volatile uint32_t v2 = value; LOAD_16(value, address & 2, &v2); break; } From 7a6582503fff4784d14250db3f3fa5592688bbee Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Aug 2015 20:32:43 -0700 Subject: [PATCH 58/58] GBA Memory: Fix bad Load16 on big endian --- src/gba/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gba/memory.c b/src/gba/memory.c index eda36f909..b97424130 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -446,8 +446,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); LOAD_BAD; - volatile uint32_t v2 = value; - LOAD_16(value, address & 2, &v2); + value = (value >> ((address & 2) * 8)) & 0xFFFF; } break; case REGION_WORKING_RAM: @@ -506,8 +505,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); LOAD_BAD; - volatile uint32_t v2 = value; - LOAD_16(value, address & 2, &v2); + value = (value >> ((address & 2) * 8)) & 0xFFFF; break; }