├── .drone.yml ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .travis.yml ├── .tx └── config ├── CHANGELOG.md ├── CMakeLists.txt ├── CMakeSettings.json ├── README.md ├── cmake ├── Architecture.cmake ├── CMakeASM_NASMInformation.cmake ├── CMakeDetermineASM_NASMCompiler.cmake ├── CMakeTestASM_NASMCompiler.cmake ├── ChangeLogVersion.cmake ├── FindDirectX.cmake ├── FindGettext.cmake ├── FindOpenAL.cmake ├── FindSDL2.cmake ├── FindSFML.cmake ├── FindSSP.cmake ├── GetGitRevisionDescription.cmake ├── GetGitRevisionDescription.cmake.in ├── GitTagVersion.cmake ├── HostCompile.cmake ├── LLVMToolchain.cmake ├── MacPackageManagers.cmake ├── PathRun.cmake ├── Set-Toolchain-vcpkg.cmake ├── Toolchain-cross-MinGW-w64-i686.cmake ├── Toolchain-cross-MinGW-w64-x86_64.cmake ├── Toolchain-cross-m32.cmake ├── UseGCCBinUtilsWrappers.cmake └── VbamFunctions.cmake ├── data ├── Nintendo - Game Boy Advance (Scene).zip ├── Nintendo - Game Boy Advance.zip └── Official No-Intro Nintendo Gameboy Advance Number (Date).zip ├── doc ├── DevInfo.txt ├── License.txt ├── ReadMe.MFC.txt ├── ReadMe.SDL.txt ├── gpl.txt └── ips.htm ├── fex ├── 7z_C │ ├── 7z.h │ ├── 7zAlloc.c │ ├── 7zAlloc.h │ ├── 7zBuf.c │ ├── 7zBuf.h │ ├── 7zC.txt │ ├── 7zCrc.c │ ├── 7zCrc.h │ ├── 7zCrcOpt.c │ ├── 7zDec.c │ ├── 7zIn.c │ ├── 7zStream.c │ ├── Bcj2.c │ ├── Bcj2.h │ ├── Bra.c │ ├── Bra.h │ ├── Bra86.c │ ├── CpuArch.c │ ├── CpuArch.h │ ├── Lzma2Dec.c │ ├── Lzma2Dec.h │ ├── LzmaDec.c │ ├── LzmaDec.h │ ├── Ppmd.h │ ├── Ppmd7.c │ ├── Ppmd7.h │ ├── Ppmd7Dec.c │ ├── Types.h │ └── lzma.txt ├── CMakeLists.txt ├── changes.txt ├── fex.txt ├── fex │ ├── Binary_Extractor.cpp │ ├── Binary_Extractor.h │ ├── Data_Reader.cpp │ ├── Data_Reader.h │ ├── File_Extractor.cpp │ ├── File_Extractor.h │ ├── Gzip_Extractor.cpp │ ├── Gzip_Extractor.h │ ├── Gzip_Reader.cpp │ ├── Gzip_Reader.h │ ├── Rar_Extractor.cpp │ ├── Rar_Extractor.h │ ├── Zip7_Extractor.cpp │ ├── Zip7_Extractor.h │ ├── Zip_Extractor.cpp │ ├── Zip_Extractor.h │ ├── Zlib_Inflater.cpp │ ├── Zlib_Inflater.h │ ├── blargg_common.cpp │ ├── blargg_common.h │ ├── blargg_config.h │ ├── blargg_endian.h │ ├── blargg_errors.cpp │ ├── blargg_errors.h │ ├── blargg_source.h │ ├── fex.cpp │ └── fex.h ├── internals.txt ├── license.txt └── readme.txt ├── headers └── stb │ └── stb_image.h ├── installdeps ├── installer.nsi ├── po ├── CMakeLists.txt ├── update_pot.sh └── wxvbam │ ├── CMakeLists.txt │ ├── ar.po │ ├── br.po │ ├── bs.po │ ├── ca.po │ ├── ca_ES.po │ ├── cs.po │ ├── da.po │ ├── da_DK.po │ ├── de.po │ ├── de_DE.po │ ├── el.po │ ├── el_GR.po │ ├── en.po │ ├── en_GB.po │ ├── en_US.po │ ├── es.po │ ├── es_419.po │ ├── es_AR.po │ ├── es_CL.po │ ├── es_CO.po │ ├── es_ES.po │ ├── es_MX.po │ ├── es_PR.po │ ├── es_US.po │ ├── fil.po │ ├── fr.po │ ├── fr_CA.po │ ├── fr_FR.po │ ├── gl.po │ ├── haw.po │ ├── he.po │ ├── he_IL.po │ ├── hr.po │ ├── hu.po │ ├── hu_HU.po │ ├── id.po │ ├── id_ID.po │ ├── it.po │ ├── it_IT.po │ ├── ja.po │ ├── ja_JP.po │ ├── jv.po │ ├── ko.po │ ├── ko_KR.po │ ├── ms_MY.po │ ├── nb.po │ ├── nl.po │ ├── nl_NL.po │ ├── no.po │ ├── pl.po │ ├── pl_PL.po │ ├── pt.po │ ├── pt_BR.po │ ├── pt_PT.po │ ├── ru.po │ ├── ru_RU.po │ ├── sk.po │ ├── sk_SK.po │ ├── sr.po │ ├── su.po │ ├── sv.po │ ├── tk.po │ ├── tr.po │ ├── wxvbam.pot │ ├── zh-Hans.po │ ├── zh.po │ ├── zh_CN.GB2312.po │ ├── zh_CN.po │ ├── zh_HK.po │ ├── zh_TW.Big5.po │ └── zh_TW.po ├── src ├── AutoBuild.h ├── NLS.h ├── System.h ├── Util.cpp ├── Util.h ├── apu │ ├── Blip_Buffer.cpp │ ├── Blip_Buffer.h │ ├── Effects_Buffer.cpp │ ├── Effects_Buffer.h │ ├── Gb_Apu.cpp │ ├── Gb_Apu.h │ ├── Gb_Apu_State.cpp │ ├── Gb_Oscs.cpp │ ├── Gb_Oscs.h │ ├── Multi_Buffer.cpp │ ├── Multi_Buffer.h │ ├── blargg_common.h │ ├── blargg_config.h │ └── blargg_source.h ├── art │ ├── vbam128.svg │ ├── vbam256.svg │ ├── vbam32.svg │ ├── vbam48.svg │ ├── vbam64.svg │ ├── vbam96.svg │ └── vbam_old.svg ├── common │ ├── BSD.h │ ├── ConfigManager.cpp │ ├── ConfigManager.h │ ├── Patch.cpp │ ├── Patch.h │ ├── Port.h │ ├── SoundDriver.h │ ├── SoundSDL.cpp │ ├── SoundSDL.h │ ├── Types.h │ ├── array.h │ ├── cstdint.h │ ├── dictionary.c │ ├── dictionary.h │ ├── ffmpeg.cpp │ ├── ffmpeg.h │ ├── iniparser.c │ ├── iniparser.h │ ├── memgzio.c │ ├── memgzio.h │ └── ringbuffer.h ├── debian │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── rules │ ├── source │ │ └── format │ ├── vbam-gtk.docs │ ├── vbam-sdl.docs │ ├── vbam-sdl.install │ ├── vbam-sdl.manpages │ ├── vbam-wx.docs │ ├── vbam-wx.install │ ├── vbam-wx.manpages │ ├── vbam-wx.menu │ ├── vbam.6 │ └── visualboyadvance-m.6 ├── filters │ ├── 2xSaI.cpp │ ├── 2xSaImmx.asm │ ├── admame.cpp │ ├── bilinear.cpp │ ├── hq │ │ ├── asm │ │ │ ├── hq3x32.cpp │ │ │ ├── hq3x_16.asm │ │ │ ├── hq3x_32.asm │ │ │ ├── hq4x_16.asm │ │ │ ├── hq4x_32.asm │ │ │ └── macros.mac │ │ └── c │ │ │ ├── hq3x_pattern.h │ │ │ ├── hq4x_pattern.h │ │ │ ├── hq_base.h │ │ │ ├── hq_implementation.cpp │ │ │ └── hq_shared.h │ ├── hq2x.cpp │ ├── hq2x.h │ ├── interframe.cpp │ ├── interframe.hpp │ ├── interp.h │ ├── lq2x.h │ ├── pixel.cpp │ ├── scanline.cpp │ ├── simpleFilter.cpp │ ├── xBRZ │ │ ├── config.h │ │ ├── xbrz.cpp │ │ └── xbrz.h │ └── xbrzfilter.cpp ├── gb │ ├── GB.cpp │ ├── gb.h │ ├── gbCheats.cpp │ ├── gbCheats.h │ ├── gbCodes.h │ ├── gbCodesCB.h │ ├── gbDis.cpp │ ├── gbGfx.cpp │ ├── gbGlobals.cpp │ ├── gbGlobals.h │ ├── gbMemory.cpp │ ├── gbMemory.h │ ├── gbPrinter.cpp │ ├── gbPrinter.h │ ├── gbSGB.cpp │ ├── gbSGB.h │ ├── gbSound.cpp │ └── gbSound.h ├── gba │ ├── BreakpointStructures.cpp │ ├── BreakpointStructures.h │ ├── CheatSearch.cpp │ ├── CheatSearch.h │ ├── Cheats.cpp │ ├── Cheats.h │ ├── EEprom.cpp │ ├── EEprom.h │ ├── Flash.cpp │ ├── Flash.h │ ├── GBA-arm.cpp │ ├── GBA-thumb.cpp │ ├── GBA.cpp │ ├── GBA.h │ ├── GBAGfx.cpp │ ├── GBAGfx.h │ ├── GBALink.cpp │ ├── GBALink.h │ ├── GBASockClient.cpp │ ├── GBASockClient.h │ ├── GBAcpu.h │ ├── GBAinline.h │ ├── Globals.cpp │ ├── Globals.h │ ├── Mode0.cpp │ ├── Mode1.cpp │ ├── Mode2.cpp │ ├── Mode3.cpp │ ├── Mode4.cpp │ ├── Mode5.cpp │ ├── RTC.cpp │ ├── RTC.h │ ├── Sound.cpp │ ├── Sound.h │ ├── Sram.cpp │ ├── Sram.h │ ├── agbprint.cpp │ ├── agbprint.h │ ├── armdis.cpp │ ├── armdis.h │ ├── bios.cpp │ ├── bios.h │ ├── debugger-expr-lex.c │ ├── debugger-expr-lex.cpp │ ├── debugger-expr-yacc.cpp │ ├── debugger-expr-yacc.hpp │ ├── debugger-expr.l │ ├── debugger-expr.y │ ├── elf.cpp │ ├── elf.h │ ├── ereader.cpp │ ├── ereader.h │ ├── gbafilter.cpp │ ├── gbafilter.h │ ├── remote.cpp │ └── remote.h ├── libretro │ ├── Makefile │ ├── Makefile.common │ ├── SoundRetro.cpp │ ├── SoundRetro.h │ ├── UtilRetro.cpp │ ├── gba-over.inc │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ ├── libretro-common │ │ └── include │ │ │ ├── libretro.h │ │ │ └── retro_inline.h │ ├── libretro.cpp │ ├── libretro_core_options.h │ ├── libretro_core_options_intl.h │ ├── link.T │ ├── scrc32.h │ └── vbam_libretro.info ├── sdl │ ├── SDL.cpp │ ├── debugger.cpp │ ├── debugger.h │ ├── expr-lex.cpp │ ├── expr.cpp │ ├── expr.cpp.h │ ├── expr.l │ ├── expr.ypp │ ├── exprNode.cpp │ ├── exprNode.h │ ├── filters.cpp │ ├── filters.h │ ├── getopt.c │ ├── getopt.h │ ├── getopt1.c │ ├── inputSDL.cpp │ ├── inputSDL.h │ ├── text.cpp │ ├── text.h │ └── vbam.cfg-example ├── snap │ └── snapcraft.yaml ├── vba-over.ini ├── version.h.in ├── vita │ └── memory.h └── wx │ ├── CMakeLists.txt │ ├── bin2c.c │ ├── cmdevents.cpp │ ├── copy-events.cmake │ ├── drawing.h │ ├── dsound.cpp │ ├── faudio.cpp │ ├── filters.h │ ├── gfxviewers.cpp │ ├── guiinit.cpp │ ├── icons │ ├── VBA.ico │ ├── sizes │ │ ├── 128x128 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 16x16 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 22x22 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 24x24 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 256x256 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 32x32 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 48x48 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 64x64 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ ├── 96x96 │ │ │ └── apps │ │ │ │ └── vbam.png │ │ └── scalable │ │ │ └── apps │ │ │ └── vbam.svg │ ├── vbam.icns │ ├── vbam.ico │ ├── vbam.png │ └── wxvbam.xpm │ ├── ioregs.h │ ├── link-static.cmake │ ├── mac-translations.cmake │ ├── macsupport.mm │ ├── msys-link-static.cmake │ ├── openal.cpp │ ├── openal.h │ ├── opts.cpp │ ├── opts.h │ ├── panel.cpp │ ├── pre-build.cmd │ ├── rpi.h │ ├── strutils.cpp │ ├── strutils.h │ ├── sys.cpp │ ├── viewers.cpp │ ├── viewsupt.cpp │ ├── viewsupt.h │ ├── wayland.cpp │ ├── wayland.h │ ├── widgets │ ├── checkedlistctrl.cpp │ ├── joyedit.cpp │ ├── keyedit.cpp │ ├── sdljoy.cpp │ ├── wx │ │ ├── checkedlistctrl.h │ │ ├── joyedit.h │ │ ├── keyedit.h │ │ ├── sdljoy.h │ │ ├── webupdatedef.h │ │ └── wxmisc.h │ └── wxmisc.cpp │ ├── wxhead.h │ ├── wxplist.in │ ├── wxvbam.appdata.xml │ ├── wxvbam.cpp │ ├── wxvbam.desktop │ ├── wxvbam.h │ ├── wxvbam.rc │ ├── xaudio2.cpp │ └── xrc │ ├── AccelConfig.xrc │ ├── CheatAdd.xrc │ ├── CheatCreate.xrc │ ├── CheatEdit.xrc │ ├── CheatList.xrc │ ├── CodeSelect.xrc │ ├── DirectoriesConfig.xrc │ ├── Disassemble.xrc │ ├── DisplayConfig.xrc │ ├── ExportSPS.xrc │ ├── GBAROMInfo.xrc │ ├── GBColorPrefPanel.xrc │ ├── GBDisassemble.xrc │ ├── GBMapViewer.xrc │ ├── GBOAMViewer.xrc │ ├── GBPaletteViewer.xrc │ ├── GBPrinter.xrc │ ├── GBROMInfo.xrc │ ├── GBTileViewer.xrc │ ├── GameBoyAdvanceConfig.xrc │ ├── GameBoyConfig.xrc │ ├── GeneralConfig.xrc │ ├── IOViewer.xrc │ ├── JoyPanel.xrc │ ├── JoypadConfig.xrc │ ├── LinkConfig.xrc │ ├── Logging.xrc │ ├── MainFrame.xrc │ ├── MainIcon.xrc │ ├── MainMenu.xrc │ ├── MapViewer.xrc │ ├── MemSelRegion.xrc │ ├── MemViewer.xrc │ ├── NetLink.xrc │ ├── OAMViewer.xrc │ ├── PaletteViewer.xrc │ ├── SoundConfig.xrc │ ├── SpeedupConfig.xrc │ ├── TileViewer.xrc │ └── vbam.xpm ├── todo.md └── tools ├── builder ├── core.sh ├── mingw-cross.sh ├── mingw.sh └── unix.sh ├── linux └── builder ├── osx ├── builder └── third_party_libs_tool ├── unix └── builder └── win ├── cygwin-cross-builder ├── linux-cross-builder ├── mac-cross-builder └── msys2-builder /.drone.yml: -------------------------------------------------------------------------------- 1 | # Build configuration for https://www.tea-ci.org 2 | # Tea CI is a fork of Drone CI with Cygwin/Msys2 support 3 | # Feel free to share Tea CI to more open source developers 4 | # http://docs.tea-ci.org/usage/overview/ 5 | # Please add your project to https://github.com/TeaCI/tea-ci/wiki/Msys2-on-Wine#use-msys2-in-tea-ci 6 | 7 | build: 8 | image: teaci/msys$$arch 9 | pull: true 10 | shell: mingw$$arch 11 | commands: 12 | - if [ $$arch = 32 ]; then target=i686; fi 13 | - if [ $$arch = 64 ]; then target=x86_64; fi 14 | - pacman -S --needed --noconfirm --noprogressbar mingw-w64-${target}-cmake mingw-w64-${target}-ffmpeg mingw-w64-${target}-SDL2 mingw-w64-${target}-openal mingw-w64-${target}-sfml mingw-w64-${target}-extra-cmake-modules mingw-w64-${target}-cairo mingw-w64-${target}-zlib mingw-w64-${target}-libpng nasm mingw-w64-${target}-wxWidgets mingw-w64-${target}-crt-git mingw-w64-${target}-headers-git zip 15 | - git submodule update --init --recursive 16 | - cmake -DENABLE_FFMPEG=ON -DENABLE_SDL=ON -G "MSYS Makefiles" 17 | - make 18 | notify: 19 | irc: 20 | prefix: build 21 | nick: vbam-ci 22 | channel: #vba-m 23 | server: 24 | host: irc.freenode.net 25 | port: 6667 26 | matrix: 27 | arch: 28 | - 64 29 | - 32 30 | 31 | #publish: 32 | # github_release: 33 | # api_key: 4cd466723ff104154a6a206814ddaa159131f2ec 34 | # files: 35 | # - vbam.exe 36 | # - visualboyadvance-m.exe 37 | # checksum: 38 | # - sha256 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Please fill out this form: 2 | 3 | ### Expected behavior 4 | 5 | ### Actual behavior 6 | 7 | ### Steps to reproduce the behavior 8 | 9 | ### Crash bugs 10 | 11 | If this is a crash bug, and you have the time and inclination, please provide a 12 | symblic backtrace. 13 | 14 | Instructions for doing so are 15 | [here](https://github.com/visualboyadvance-m/visualboyadvance-m/blob/master/README.md#reporting-crash-bugs). 16 | 17 | ### ROM details 18 | 19 | Which games are affected by the issue (please state if GBA or GB game): 20 | 21 | Which games, if any, are NOT affected by the issue (please state if GBA or GB game): 22 | 23 | Include screenshots of ROM Information (File > ROM Information): 24 | 25 | If you are using a BIOS file, please say which one. 26 | 27 | ### Option details 28 | 29 | Video driver (simple, opengl): 30 | 31 | Sound driver (directsound, xaudio, openal, SDL): 32 | 33 | ### Build details 34 | 35 | Operating System (Windows, Mac, Linux (state distribution), etc.): 36 | 37 | If using Linux, specify if using xorg or Wayland: 38 | 39 | Version of code (pre-built binary version, or commit ref, or just "master"): 40 | 41 | ### Hardware details: 42 | 43 | If your joystick or gamepad isn't working in Linux, please try to troubleshoot 44 | using the information on this page: 45 | https://wiki.archlinux.org/index.php/Gamepad **BEFORE** filing an issue. We use 46 | SDL for joystick support, any problems will generally be an issue with SDL and 47 | **NOT** the emulator. 48 | 49 | If relevant, the joystick you are using and the drivers you are using for it: 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/wx/builtin-over.h 2 | src/wx/builtin-xrc.h 3 | src/wx/cmd-evtable.h 4 | src/wx/cmdhandlers.h 5 | src/wx/cmdtab.cpp 6 | src/wx/wxvbam.xrs 7 | build/* 8 | build32/* 9 | vsbuild/* 10 | cmake-build* 11 | dependencies/* 12 | vcpkg/* 13 | .vs/* 14 | .idea 15 | *.o 16 | *.so 17 | *.dll 18 | *.exe 19 | .vscode 20 | 21 | # vim swap files 22 | *.sw? 23 | *.un~ 24 | 25 | # mac finder crap 26 | *.DS_Store 27 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies"] 2 | path = dependencies 3 | url = https://github.com/visualboyadvance-m/dependencies.git 4 | -------------------------------------------------------------------------------- /.tx/config: -------------------------------------------------------------------------------- 1 | [main] 2 | host = https://www.transifex.com 3 | 4 | [vba-m.wxvbam] 5 | file_filter = po/wxvbam/.po 6 | source_file = po/wxvbam/wxvbam.pot 7 | source_lang = en 8 | type = PO 9 | 10 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Visual Studio 15 2017", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ 8 | "msvc_x64" 9 | ], 10 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", 11 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", 12 | "cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows", 13 | "ctestCommandArgs": "" 14 | }, { 15 | "name": "x64-Release", 16 | "generator": "Visual Studio 15 2017", 17 | "configurationType": "Release", 18 | "inheritEnvironments": [ 19 | "msvc_x64" 20 | ], 21 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", 22 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", 23 | "cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows", 24 | "ctestCommandArgs": "" 25 | }, { 26 | "name": "x86-Debug", 27 | "generator": "Visual Studio 15 2017", 28 | "configurationType": "Debug", 29 | "inheritEnvironments": [ 30 | "msvc_x86" 31 | ], 32 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", 33 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", 34 | "cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows", 35 | "ctestCommandArgs": "" 36 | }, { 37 | "name": "x86-Release", 38 | "generator": "Visual Studio 15 2017", 39 | "configurationType": "Release", 40 | "inheritEnvironments": [ 41 | "msvc_x86" 42 | ], 43 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", 44 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", 45 | "cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows", 46 | "ctestCommandArgs": "" 47 | } 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /cmake/Architecture.cmake: -------------------------------------------------------------------------------- 1 | if(NOT CMAKE_SYSTEM_PROCESSOR) 2 | if(NOT CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_SYSTEM_PROCESSOR) 3 | set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) 4 | elseif(CMAKE_TOOLCHAIN_FILE MATCHES mxe) 5 | if(CMAKE_TOOLCHAIN_FILE MATCHES "i[3-9]86") 6 | set(CMAKE_SYSTEM_PROCESSOR i686) 7 | else() 8 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 9 | endif() 10 | endif() 11 | endif() 12 | 13 | # turn asm on by default on 32bit x86 14 | # and set WINARCH for windows stuff 15 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|i[3-9]86|[aA][mM][dD]64") 16 | if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4) # 32 bit 17 | if(NOT (MSVC AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)) 18 | set(ASM_DEFAULT ON) 19 | endif() 20 | set(X86_32 ON) 21 | set(WINARCH x86) 22 | else() 23 | set(AMD64 ON) 24 | set(WINARCH x64) 25 | endif() 26 | endif() 27 | -------------------------------------------------------------------------------- /cmake/CMakeASM_NASMInformation.cmake: -------------------------------------------------------------------------------- 1 | 2 | #============================================================================= 3 | # Copyright 2010 Kitware, Inc. 4 | # 5 | # Distributed under the OSI-approved BSD License (the "License"); 6 | # see accompanying file Copyright.txt for details. 7 | # 8 | # This software is distributed WITHOUT ANY WARRANTY; without even the 9 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # See the License for more information. 11 | #============================================================================= 12 | # (To distribute this file outside of CMake, substitute the full 13 | # License text for the above reference.) 14 | 15 | # support for the nasm assembler 16 | 17 | set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS nasm asm) 18 | 19 | if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) 20 | if(WIN32) 21 | if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) 22 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT win64) 23 | else() 24 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT win32) 25 | endif() 26 | elseif(APPLE) 27 | EXECUTE_PROCESS(COMMAND ${CMAKE_ASM_NASM_COMPILER} -v COMMAND awk "{print \$3}" OUTPUT_VARIABLE NASM_VERSION) 28 | IF(NASM_VERSION VERSION_LESS 2.0) 29 | IF(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) 30 | MESSAGE(FATAL_ERROR "Your nasm is too old to support AMD64, please install nasm from Homebrew or MacPorts.") 31 | ENDIF() 32 | SET(CMAKE_ASM_NAMS_OBJECT_FORMAT macho) 33 | ELSE() 34 | if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) 35 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) 36 | else() 37 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho32) 38 | endif() 39 | ENDIF() 40 | else() 41 | if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) 42 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) 43 | else() 44 | SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf32) 45 | endif() 46 | endif() 47 | endif() 48 | 49 | set(CMAKE_ASM_NASM_COMPILE_OBJECT " -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o ") 50 | 51 | # Load the generic ASMInformation file: 52 | set(ASM_DIALECT "_NASM") 53 | include(CMakeASMInformation) 54 | set(ASM_DIALECT) 55 | -------------------------------------------------------------------------------- /cmake/CMakeDetermineASM_NASMCompiler.cmake: -------------------------------------------------------------------------------- 1 | 2 | #============================================================================= 3 | # Copyright 2010 Kitware, Inc. 4 | # 5 | # Distributed under the OSI-approved BSD License (the "License"); 6 | # see accompanying file Copyright.txt for details. 7 | # 8 | # This software is distributed WITHOUT ANY WARRANTY; without even the 9 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # See the License for more information. 11 | #============================================================================= 12 | # (To distribute this file outside of CMake, substitute the full 13 | # License text for the above reference.) 14 | 15 | # Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible 16 | 17 | SET(CMAKE_ASM_NASM_COMPILER_INIT nasm yasm) 18 | 19 | IF(NOT CMAKE_ASM_NASM_COMPILER) 20 | FIND_PROGRAM(CMAKE_ASM_NASM_COMPILER nasm 21 | "$ENV{ProgramFiles}/NASM") 22 | ENDIF(NOT CMAKE_ASM_NASM_COMPILER) 23 | 24 | # Load the generic DetermineASM compiler file with the DIALECT set properly: 25 | SET(ASM_DIALECT "_NASM") 26 | INCLUDE(CMakeDetermineASMCompiler) 27 | SET(ASM_DIALECT) 28 | -------------------------------------------------------------------------------- /cmake/CMakeTestASM_NASMCompiler.cmake: -------------------------------------------------------------------------------- 1 | 2 | #============================================================================= 3 | # Copyright 2010 Kitware, Inc. 4 | # 5 | # Distributed under the OSI-approved BSD License (the "License"); 6 | # see accompanying file Copyright.txt for details. 7 | # 8 | # This software is distributed WITHOUT ANY WARRANTY; without even the 9 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # See the License for more information. 11 | #============================================================================= 12 | # (To distribute this file outside of CMake, substitute the full 13 | # License text for the above reference.) 14 | 15 | # This file is used by EnableLanguage in cmGlobalGenerator to 16 | # determine that the selected ASM_NASM "compiler" works. 17 | # For assembler this can only check whether the compiler has been found, 18 | # because otherwise there would have to be a separate assembler source file 19 | # for each assembler on every architecture. 20 | 21 | SET(ASM_DIALECT "_NASM") 22 | INCLUDE(CMakeTestASMCompiler) 23 | SET(ASM_DIALECT) 24 | -------------------------------------------------------------------------------- /cmake/ChangeLogVersion.cmake: -------------------------------------------------------------------------------- 1 | function(changelog_version version revision version_release) 2 | set(${version} "" CACHE STRING "Latest ChangeLog Version" FORCE) 3 | set(${revision} "" CACHE STRING "Latest ChangeLog Revision" FORCE) 4 | set(${version_release} 0 CACHE STRING "Is this a versioned release without revision" FORCE) 5 | 6 | file(READ CHANGELOG.md changelog_file) 7 | 8 | if(NOT changelog_file) 9 | return() 10 | endif() 11 | 12 | string(REGEX MATCH "\n## +\\[([0-9.]+)(-([^] ]+))?\\] +.* +[0-9][0-9]?/" match_out "${changelog_file}") 13 | 14 | set(changelog_version "${CMAKE_MATCH_1}") 15 | 16 | set(is_version_release 0) 17 | set(changelog_revision "${CMAKE_MATCH_3}") 18 | if(NOT changelog_revision) 19 | set(is_version_release 1) 20 | endif() 21 | 22 | set(${version} "${changelog_version}" CACHE STRING "Latest ChangeLog Version" FORCE) 23 | set(${revision} "${changelog_revision}" CACHE STRING "Latest ChangeLog Revision" FORCE) 24 | set(${version_release} "${is_version_release}" CACHE STRING "Is this a versioned release without revision" FORCE) 25 | endfunction() 26 | -------------------------------------------------------------------------------- /cmake/FindDirectX.cmake: -------------------------------------------------------------------------------- 1 | # -*- cmake -*- 2 | 3 | # mostly taken from emeraldviewer 4 | if (WIN32) 5 | find_path(DIRECTX_INCLUDE_DIR dxdiag.h 6 | "$ENV{DXSDK_DIR}/Include" 7 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Include" 8 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Include" 9 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Include" 10 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Include" 11 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Include" 12 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Include" 13 | "C:/DX90SDK/Include" 14 | "$ENV{PROGRAMFILES}/DX90SDK/Include" 15 | ) 16 | if (DIRECTX_INCLUDE_DIR) 17 | include_directories(${DIRECTX_INCLUDE_DIR}) 18 | if (DIRECTX_FIND_QUIETLY) 19 | message(STATUS "Found DirectX include: ${DIRECTX_INCLUDE_DIR}") 20 | endif (DIRECTX_FIND_QUIETLY) 21 | else (DIRECTX_INCLUDE_DIR) 22 | message(FATAL_ERROR "Could not find DirectX SDK Include") 23 | endif (DIRECTX_INCLUDE_DIR) 24 | 25 | 26 | find_path(DIRECTX_LIBRARY_DIR dxguid.lib 27 | "$ENV{DXSDK_DIR}/Lib/x86" 28 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Lib/x86" 29 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Lib/x86" 30 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Lib/x86" 31 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Lib/x86" 32 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Lib/x86" 33 | "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Lib/x86" 34 | "C:/DX90SDK/Lib" 35 | "$ENV{PROGRAMFILES}/DX90SDK/Lib" 36 | ) 37 | if (DIRECTX_LIBRARY_DIR) 38 | if (DIRECTX_FIND_QUIETLY) 39 | message(STATUS "Found DirectX include: ${DIRECTX_LIBRARY_DIR}") 40 | endif (DIRECTX_FIND_QUIETLY) 41 | else (DIRECTX_LIBRARY_DIR) 42 | message(FATAL_ERROR "Could not find DirectX SDK Libraries") 43 | endif (DIRECTX_LIBRARY_DIR) 44 | 45 | endif (WIN32) 46 | 47 | INCLUDE(FindPackageHandleStandardArgs) 48 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX DEFAULT_MSG DIRECTX_LIBRARY_DIR DIRECTX_INCLUDE_DIR) 49 | -------------------------------------------------------------------------------- /cmake/FindSSP.cmake: -------------------------------------------------------------------------------- 1 | # FindSSP.cmake 2 | # 3 | # Find libssp necessary when using gcc with e.g. -fstack-protector=strong 4 | # 5 | # See: http://wiki.osdev.org/Stack_Smashing_Protector 6 | # 7 | # To use: 8 | # 9 | # put a copy into your /cmake/ 10 | # 11 | # In your main CMakeLists.txt do something like this: 12 | # 13 | # if(WIN32) 14 | # set(SSP_STATIC ON) 15 | # endif() 16 | # 17 | # find_package(SSP) 18 | # 19 | # if(SSP_LIBRARY) 20 | # set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${SSP_LIBRARY}") 21 | # set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${SSP_LIBRARY}") 22 | # endif() 23 | 24 | # only do this when compiling with gcc/g++ 25 | if(NOT CMAKE_COMPILER_IS_GNUCXX) 26 | return() 27 | endif() 28 | 29 | function(FindSSP) 30 | if(NOT CMAKE_CXX_COMPILER AND CMAKE_C_COMPILER) 31 | set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}) 32 | endif() 33 | 34 | foreach(arg ${CMAKE_CXX_COMPILER_ARG1} ${CMAKE_CXX_COMPILER_ARG2} ${CMAKE_CXX_COMPILER_ARG3} ${CMAKE_CXX_COMPILER_ARG4} ${CMAKE_CXX_COMPILER_ARG5} ${CMAKE_CXX_COMPILER_ARG6} ${CMAKE_CXX_COMPILER_ARG7} ${CMAKE_CXX_COMPILER_ARG8} ${CMAKE_CXX_COMPILER_ARG9}) 35 | string(STRIP ${arg} arg) 36 | set(gcc_args "${gcc_args};${arg}") 37 | endforeach() 38 | 39 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-prog-name=gcc OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) 40 | 41 | if(WIN32 AND NOT MSYS) 42 | execute_process(COMMAND where.exe ${GCC_EXECUTABLE} OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) 43 | else() 44 | execute_process(COMMAND sh -c "command -v ${GCC_EXECUTABLE}" OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) 45 | endif() 46 | 47 | get_filename_component(GCC_DIRNAME "${GCC_EXECUTABLE}" DIRECTORY) 48 | 49 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE OUTPUT_STRIP_TRAILING_WHITESPACE) 50 | 51 | get_filename_component(LIBGCC_DIRNAME "${LIBGCC_FILE}" DIRECTORY) 52 | 53 | set(SSP_SEARCH_PATHS ${GCC_DIRNAME} ${LIBGCC_DIRNAME}) 54 | 55 | if(SSP_STATIC) 56 | if(WIN32) 57 | set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) 58 | else() 59 | set(CMAKE_FIND_LIBRARY_SUFFIXES .a) 60 | endif() 61 | endif() 62 | 63 | find_library(SSP_LIBRARY 64 | NAMES ssp libssp 65 | HINTS ${SSP_SEARCH_PATHS} 66 | PATH_SUFFIXES lib64 lib lib/x64 lib/x86 67 | ) 68 | 69 | set(SSP_LIBRARY PARENT_SCOPE) 70 | endfunction() 71 | 72 | FindSSP() 73 | 74 | include(FindPackageHandleStandardArgs) 75 | 76 | find_package_handle_standard_args(SSP REQUIRED_VARS SSP_LIBRARY) 77 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | else() 27 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 28 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 29 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 30 | set(HEAD_HASH "${CMAKE_MATCH_1}") 31 | endif() 32 | endif() 33 | else() 34 | # detached HEAD 35 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 36 | endif() 37 | 38 | if(NOT HEAD_HASH) 39 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 40 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 41 | endif() 42 | -------------------------------------------------------------------------------- /cmake/HostCompile.cmake: -------------------------------------------------------------------------------- 1 | function(host_compile src dst_cmd) 2 | unset(link_flags) 3 | 4 | if(CMAKE_HOST_WIN32) 5 | if(NOT dst MATCHES "\\.[Ee][Xx][Ee]\$") 6 | set(dst "${dst_cmd}.exe") 7 | endif() 8 | 9 | if(CMAKE_COMPILER_IS_GNUCXX) 10 | set(link_flags -Wl,--subsystem,console) 11 | endif() 12 | else() 13 | set(dst "${dst_cmd}") 14 | endif() 15 | 16 | if(NOT MSVC) 17 | # assume cc foo.c -o foo # will work on most hosts 18 | set(compile_command cc ${src} -o ${dst} ${link_flags}) 19 | else() 20 | # special case for Visual Studio 21 | set(compile_command cl ${src} /link "/out:${dst}") 22 | endif() 23 | 24 | execute_process(COMMAND ${compile_command} OUTPUT_VARIABLE compile_out ERROR_VARIABLE compile_out RESULT_VARIABLE compile_result) 25 | 26 | if(NOT compile_result EQUAL 0) 27 | message(FATAL_ERROR "Failed compiling ${src} for the host: ${compile_out}") 28 | endif() 29 | endfunction() 30 | -------------------------------------------------------------------------------- /cmake/LLVMToolchain.cmake: -------------------------------------------------------------------------------- 1 | function(use_llvm_toolchain) 2 | if(CMAKE_C_COMPILER_ID STREQUAL Clang) 3 | set(compiler "${CMAKE_C_COMPILER}") 4 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 5 | set(compiler "${CMAKE_CXX_COMPILER}") 6 | else() 7 | return() 8 | endif() 9 | 10 | foreach(tool ar ranlib ld nm objdump as) 11 | execute_process( 12 | COMMAND "${compiler}" -print-prog-name=llvm-${tool} 13 | OUTPUT_VARIABLE prog_path 14 | OUTPUT_STRIP_TRAILING_WHITESPACE 15 | ) 16 | 17 | # for FreeBSD 18 | if(NOT prog_path MATCHES "^/") 19 | get_filename_component( 20 | abs_path ${prog_path} ABSOLUTE 21 | BASE_DIR /usr/local/llvm-devel/bin 22 | ) 23 | 24 | if(EXISTS ${abs_path}) 25 | set(prog_path ${abs_path}) 26 | endif() 27 | endif() 28 | 29 | if(prog_path MATCHES "^/") 30 | if(tool STREQUAL ld) 31 | set(tool linker) 32 | elseif(tool STREQUAL as) 33 | set(tool asm_compiler) 34 | endif() 35 | 36 | string(TOUPPER ${tool} utool) 37 | 38 | set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE) 39 | set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE) 40 | endif() 41 | endforeach() 42 | endfunction() 43 | 44 | use_llvm_toolchain() 45 | -------------------------------------------------------------------------------- /cmake/PathRun.cmake: -------------------------------------------------------------------------------- 1 | function(make_path_run_wrapper cmd target) 2 | get_filename_component(cmd_resolved "${cmd}" REALPATH) 3 | get_filename_component(base_name "${cmd_resolved}" NAME) 4 | get_filename_component(dir_name "${cmd_resolved}" DIRECTORY) 5 | 6 | set(source "${target}.c") 7 | 8 | file(WRITE "${source}" 9 | " 10 | #include 11 | #include 12 | #include 13 | 14 | #define BUF_SZ 4096 15 | 16 | #ifdef _WIN32 17 | #include 18 | #define PATH_SEP ';' 19 | #define setenv(var, val, dummy) _putenv_s(var, val) 20 | #define execvp my_execvp 21 | #else 22 | #include 23 | #define PATH_SEP ':' 24 | #endif 25 | 26 | char* dir_name = \"${dir_name}\"; 27 | char* base_name = \"${base_name}\"; 28 | 29 | int main(int argc, char** argv) { 30 | size_t dir_len = strlen(dir_name); 31 | char* path = getenv(\"PATH\"); 32 | size_t path_len = strlen(path); 33 | char* new_path = malloc(dir_len + path_len + 2); 34 | char** new_argv = malloc(sizeof(char*) * argc); 35 | char** p; 36 | char buf[BUF_SZ]; 37 | 38 | strcpy(new_path, dir_name); 39 | new_path[dir_len] = PATH_SEP; 40 | strcpy(new_path + dir_len + 1, path); 41 | 42 | setenv(\"PATH\", new_path, 1); 43 | 44 | free(new_path); 45 | 46 | p = new_argv; 47 | *(p++) = base_name; 48 | while (*(++argv)) *(p++) = *argv; 49 | *p = NULL; 50 | 51 | execvp(base_name, new_argv); 52 | 53 | // this is only reached if exec failed 54 | snprintf(buf, BUF_SZ, \"%s: exec failed\", argv[0]); 55 | perror(buf); 56 | 57 | return EXIT_FAILURE; 58 | } 59 | 60 | #ifdef _WIN32 61 | int my_execvp(char* cmd, char** argv) { 62 | int ret = _spawnvp(_P_WAIT, cmd, argv); 63 | if (ret == -1) return ret; 64 | exit(ret); 65 | } 66 | #endif 67 | ") 68 | 69 | include(HostCompile) 70 | host_compile("${source}" "${target}") 71 | endfunction() 72 | -------------------------------------------------------------------------------- /cmake/Set-Toolchain-vcpkg.cmake: -------------------------------------------------------------------------------- 1 | if(VCPKG_TARGET_TRIPLET) 2 | if(NOT DEFINED ENV{VCPKG_ROOT}) 3 | get_filename_component(VCPKG_ROOT ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE) 4 | set(ENV{VCPKG_ROOT} ${VCPKG_ROOT}) 5 | else() 6 | set(VCPKG_ROOT $ENV{VCPKG_ROOT}) 7 | endif() 8 | 9 | if(NOT EXISTS ${VCPKG_ROOT}) 10 | get_filename_component(vcpkg_root_parent ${VCPKG_ROOT}/.. ABSOLUTE) 11 | 12 | execute_process( 13 | COMMAND git clone https://github.com/microsoft/vcpkg.git 14 | RESULT_VARIABLE git_status 15 | WORKING_DIRECTORY ${vcpkg_root_parent} 16 | ) 17 | 18 | if(NOT git_status EQUAL 0) 19 | message(FATAL_ERROR "Error cloning vcpkg, please make sure git for windows is installed correctly, it can be installed from Visual Studio components") 20 | endif() 21 | endif() 22 | 23 | # build vcpkg if not built 24 | if(WIN32) 25 | if(NOT EXISTS ${VCPKG_ROOT}/vcpkg.exe) 26 | execute_process( 27 | COMMAND bootstrap-vcpkg.bat 28 | WORKING_DIRECTORY ${VCPKG_ROOT} 29 | ) 30 | endif() 31 | else() 32 | if(NOT EXISTS ${VCPKG_ROOT}/vcpkg) 33 | execute_process( 34 | COMMAND ./bootstrap-vcpkg.sh 35 | WORKING_DIRECTORY ${VCPKG_ROOT} 36 | ) 37 | endif() 38 | endif() 39 | 40 | foreach(pkg ${VCPKG_DEPS}) 41 | list(APPEND VCPKG_DEPS_QUALIFIED ${pkg}:${VCPKG_TARGET_TRIPLET}) 42 | endforeach() 43 | 44 | # build our deps 45 | if(WIN32) 46 | execute_process( 47 | COMMAND vcpkg install ${VCPKG_DEPS_QUALIFIED} 48 | WORKING_DIRECTORY ${VCPKG_ROOT} 49 | ) 50 | else() 51 | execute_process( 52 | COMMAND ./vcpkg install ${VCPKG_DEPS_QUALIFIED} 53 | WORKING_DIRECTORY ${VCPKG_ROOT} 54 | ) 55 | endif() 56 | 57 | if(WIN32 AND VCPKG_TARGET_TRIPLET MATCHES x64) 58 | set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "visual studio build architecture" FORCE) 59 | endif() 60 | 61 | set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "vcpkg toolchain" FORCE) 62 | include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) 63 | endif() 64 | -------------------------------------------------------------------------------- /cmake/Toolchain-cross-MinGW-w64-i686.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_SYSTEM_NAME Windows) 2 | 3 | set(CROSS_ARCH i686) 4 | set(COMPILER_PREFIX "${CROSS_ARCH}-w64-mingw32") 5 | 6 | unset(CMAKE_RC_COMPILER CACHE) 7 | unset(CMAKE_C_COMPILER CACHE) 8 | unset(CMAKE_CXX_COMPILER CACHE) 9 | unset(PKG_CONFIG_EXECUTABLE CACHE) 10 | 11 | # which compilers to use for C and C++ 12 | find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres) 13 | find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc) 14 | find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++) 15 | 16 | SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/usr /usr/${COMPILER_PREFIX}/sys-root/mingw /usr/local/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX} /home/linuxbrew/.linuxbrew/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX} $ENV{HOME}/.linuxbrew/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX}) 17 | 18 | if(CMAKE_PREFIX_PATH) 19 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH}) 20 | endif() 21 | 22 | # adjust the default behaviour of the FIND_XXX() commands: 23 | # search headers and libraries in the target environment, search 24 | # programs in the host environment too 25 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 27 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 28 | 29 | # pkg-config may be under the prefix 30 | find_program(PKG_CONFIG_EXECUTABLE NAMES ${COMPILER_PREFIX}-pkg-config) 31 | -------------------------------------------------------------------------------- /cmake/Toolchain-cross-MinGW-w64-x86_64.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_SYSTEM_NAME Windows) 2 | 3 | set(CROSS_ARCH x86_64) 4 | set(COMPILER_PREFIX "${CROSS_ARCH}-w64-mingw32") 5 | 6 | unset(CMAKE_RC_COMPILER CACHE) 7 | unset(CMAKE_C_COMPILER CACHE) 8 | unset(CMAKE_CXX_COMPILER CACHE) 9 | unset(PKG_CONFIG_EXECUTABLE CACHE) 10 | 11 | # which compilers to use for C and C++ 12 | find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres) 13 | find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc) 14 | find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++) 15 | 16 | SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/usr /usr/${COMPILER_PREFIX}/sys-root/mingw /usr/local/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX} /home/linuxbrew/.linuxbrew/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX} $ENV{HOME}/.linuxbrew/opt/mingw-w64/toolchain-${CROSS_ARCH}/${COMPILER_PREFIX}) 17 | 18 | if(CMAKE_PREFIX_PATH) 19 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH}) 20 | endif() 21 | 22 | # adjust the default behaviour of the FIND_XXX() commands: 23 | # search headers and libraries in the target environment, search 24 | # programs in the host environment too 25 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 27 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 28 | 29 | # pkg-config may be under the prefix 30 | find_program(PKG_CONFIG_EXECUTABLE NAMES ${COMPILER_PREFIX}-pkg-config) 31 | -------------------------------------------------------------------------------- /cmake/Toolchain-cross-m32.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_C_FLAGS "-m32" CACHE STRING "C compiler flags" FORCE) 2 | SET(CMAKE_CXX_FLAGS "-m32" CACHE STRING "C++ compiler flags" FORCE) 3 | 4 | SET(LIB32 /usr/lib) # Fedora 5 | 6 | IF(EXISTS /usr/lib32) 7 | SET(LIB32 /usr/lib32) # Arch, Solus 8 | ENDIF() 9 | 10 | SET(CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE) 11 | SET(CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE) 12 | 13 | # this is probably unlikely to be needed, but just in case 14 | SET(CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE) 15 | SET(CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE) 16 | SET(CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE) 17 | 18 | # find Wx config script on Fedora for the highest version of 32 bit Wx installed 19 | IF(EXISTS ${LIB32}/wx/config) 20 | FILE(GLOB WX_INSTALLS ${LIB32}/wx/config/*) 21 | 22 | SET(MAX_WX_VERSION 0.0) 23 | FOREACH(WX_INSTALL ${WX_INSTALLS}) 24 | STRING(REGEX MATCH "[0-9]+(\\.[0-9]+)+" WX_VERSION ${WX_INSTALL}) 25 | 26 | IF(WX_VERSION VERSION_GREATER MAX_WX_VERSION) 27 | SET(MAX_WX_VERSION ${WX_VERSION}) 28 | ENDIF() 29 | ENDFOREACH() 30 | 31 | FILE(GLOB WX_INSTALL_CONFIGS "${LIB32}/wx/config/*${MAX_WX_VERSION}*") 32 | LIST(GET WX_INSTALL_CONFIGS 0 WX_INSTALL_CONFIG) 33 | 34 | SET(WX_CONFIG_TRANSFORM_SCRIPT_LINES 35 | "" 36 | ) 37 | FILE(WRITE ${CMAKE_BINARY_DIR}/wx-config-wrapper 38 | "#!/bin/sh 39 | ${WX_INSTALL_CONFIG} \"\$@\" | sed 's!/emul32/!/usr/!g' 40 | ") 41 | EXECUTE_PROCESS(COMMAND chmod +x ${CMAKE_BINARY_DIR}/wx-config-wrapper) 42 | 43 | SET(wxWidgets_CONFIG_EXECUTABLE ${CMAKE_BINARY_DIR}/wx-config-wrapper) 44 | ENDIF() 45 | 46 | # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have 47 | # to include the regular system .pc files as well (at the end), because some 48 | # are not always present in the 32 bit directory 49 | IF(EXISTS ${LIB32}/pkgconfig) 50 | SET(ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig) 51 | ENDIF() 52 | -------------------------------------------------------------------------------- /data/Nintendo - Game Boy Advance (Scene).zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/data/Nintendo - Game Boy Advance (Scene).zip -------------------------------------------------------------------------------- /data/Nintendo - Game Boy Advance.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/data/Nintendo - Game Boy Advance.zip -------------------------------------------------------------------------------- /data/Official No-Intro Nintendo Gameboy Advance Number (Date).zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/data/Official No-Intro Nintendo Gameboy Advance Number (Date).zip -------------------------------------------------------------------------------- /doc/License.txt: -------------------------------------------------------------------------------- 1 | Copyright for all files in trunk/src excluding gb_apu 2 | or when stated otherwise in the source file: 3 | VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator 4 | Copyright (C) 1999-2003 Forgotten 5 | Copyright (C) 2004-2006 Forgotten and the VBA development team 6 | 7 | Copyright for the modifications to the files mentioned above: 8 | VisualBoyAdvance-M GB/GBA emulator 9 | Copyright (C) 2007-2015 VBA-M development team 10 | 11 | 12 | All files excluding gb_apu, modified files from zlib 13 | or when stated otherwise in the source file 14 | are distributed under the GNU GPL v2: 15 | 16 | This program is free software; you can redistribute it and/or modify 17 | it under the terms of the GNU General Public License as published by 18 | the Free Software Foundation; either version 2, or(at your option) 19 | any later version. 20 | 21 | This program is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License for more details. 25 | 26 | You should have received a copy of the GNU General Public License 27 | along with this program; if not, write to the Free Software Foundation, 28 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 29 | -------------------------------------------------------------------------------- /doc/ReadMe.MFC.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/doc/ReadMe.MFC.txt -------------------------------------------------------------------------------- /fex/7z_C/7zAlloc.c: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.c -- Allocation functions 2 | 2010-10-29 : Igor Pavlov : Public domain */ 3 | 4 | #include "7zAlloc.h" 5 | 6 | /* #define _SZ_ALLOC_DEBUG */ 7 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 8 | 9 | #ifdef _SZ_ALLOC_DEBUG 10 | 11 | #ifdef _WIN32 12 | #include 13 | #endif 14 | 15 | #include 16 | int g_allocCount = 0; 17 | int g_allocCountTemp = 0; 18 | 19 | #endif 20 | 21 | void* SzAlloc(void* p, size_t size) 22 | { 23 | (void)p; // unused param 24 | if (size == 0) 25 | return 0; 26 | #ifdef _SZ_ALLOC_DEBUG 27 | fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); 28 | g_allocCount++; 29 | #endif 30 | return malloc(size); 31 | } 32 | 33 | void SzFree(void* p, void* address) 34 | { 35 | (void)p; // unused param 36 | #ifdef _SZ_ALLOC_DEBUG 37 | if (address != 0) { 38 | g_allocCount--; 39 | fprintf(stderr, "\nFree; count = %10d", g_allocCount); 40 | } 41 | #endif 42 | free(address); 43 | } 44 | 45 | void* SzAllocTemp(void* p, size_t size) 46 | { 47 | (void)p; // unused param 48 | if (size == 0) 49 | return 0; 50 | #ifdef _SZ_ALLOC_DEBUG 51 | fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); 52 | g_allocCountTemp++; 53 | #ifdef _WIN32 54 | return HeapAlloc(GetProcessHeap(), 0, size); 55 | #endif 56 | #endif 57 | return malloc(size); 58 | } 59 | 60 | void SzFreeTemp(void* p, void* address) 61 | { 62 | (void)p; // unused param 63 | #ifdef _SZ_ALLOC_DEBUG 64 | if (address != 0) { 65 | g_allocCountTemp--; 66 | fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); 67 | } 68 | #ifdef _WIN32 69 | HeapFree(GetProcessHeap(), 0, address); 70 | return; 71 | #endif 72 | #endif 73 | free(address); 74 | } 75 | -------------------------------------------------------------------------------- /fex/7z_C/7zAlloc.h: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.h -- Allocation functions 2 | 2010-10-29 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_ALLOC_H 5 | #define __7Z_ALLOC_H 6 | 7 | #include 8 | 9 | void* SzAlloc(void* p, size_t size); 10 | void SzFree(void* p, void* address); 11 | 12 | void* SzAllocTemp(void* p, size_t size); 13 | void SzFreeTemp(void* p, void* address); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /fex/7z_C/7zBuf.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf.c -- Byte Buffer 2 | 2008-03-28 3 | Igor Pavlov 4 | Public domain */ 5 | 6 | #include "7zBuf.h" 7 | 8 | void Buf_Init(CBuf* p) 9 | { 10 | p->data = 0; 11 | p->size = 0; 12 | } 13 | 14 | int Buf_Create(CBuf* p, size_t size, ISzAlloc* alloc) 15 | { 16 | p->size = 0; 17 | if (size == 0) { 18 | p->data = 0; 19 | return 1; 20 | } 21 | p->data = (Byte*)alloc->Alloc(alloc, size); 22 | if (p->data != 0) { 23 | p->size = size; 24 | return 1; 25 | } 26 | return 0; 27 | } 28 | 29 | void Buf_Free(CBuf* p, ISzAlloc* alloc) 30 | { 31 | alloc->Free(alloc, p->data); 32 | p->data = 0; 33 | p->size = 0; 34 | } 35 | -------------------------------------------------------------------------------- /fex/7z_C/7zBuf.h: -------------------------------------------------------------------------------- 1 | /* 7zBuf.h -- Byte Buffer 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_BUF_H 5 | #define __7Z_BUF_H 6 | 7 | #include "Types.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct 14 | { 15 | Byte* data; 16 | size_t size; 17 | } CBuf; 18 | 19 | void Buf_Init(CBuf* p); 20 | int Buf_Create(CBuf* p, size_t size, ISzAlloc* alloc); 21 | void Buf_Free(CBuf* p, ISzAlloc* alloc); 22 | 23 | typedef struct 24 | { 25 | Byte* data; 26 | size_t size; 27 | size_t pos; 28 | } CDynBuf; 29 | 30 | void DynBuf_Construct(CDynBuf* p); 31 | void DynBuf_SeekToBeg(CDynBuf* p); 32 | int DynBuf_Write(CDynBuf* p, const Byte* buf, size_t size, ISzAlloc* alloc); 33 | void DynBuf_Free(CDynBuf* p, ISzAlloc* alloc); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /fex/7z_C/7zCrc.c: -------------------------------------------------------------------------------- 1 | /* 7zCrc.c -- CRC32 init 2 | 2010-12-01 : Igor Pavlov : Public domain */ 3 | 4 | #include "7zCrc.h" 5 | #include "CpuArch.h" 6 | 7 | #define kCrcPoly 0xEDB88320 8 | 9 | #ifdef MY_CPU_X86_OR_AMD64 10 | #define CRC_NUM_TABLES 8 11 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void* data, size_t size, const UInt32* table); 12 | #elif defined(MY_CPU_LE) 13 | #define CRC_NUM_TABLES 4 14 | #else 15 | #define CRC_NUM_TABLES 5 16 | #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) 17 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void* data, size_t size, const UInt32* table); 18 | #endif 19 | 20 | #ifndef MY_CPU_BE 21 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void* data, size_t size, const UInt32* table); 22 | #endif 23 | 24 | typedef UInt32(MY_FAST_CALL* CRC_FUNC)(UInt32 v, const void* data, size_t size, const UInt32* table); 25 | 26 | static CRC_FUNC g_CrcUpdate; 27 | UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; 28 | 29 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void* data, size_t size) 30 | { 31 | return g_CrcUpdate(v, data, size, g_CrcTable); 32 | } 33 | 34 | UInt32 MY_FAST_CALL CrcCalc(const void* data, size_t size) 35 | { 36 | return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; 37 | } 38 | 39 | void MY_FAST_CALL CrcGenerateTable() 40 | { 41 | UInt32 i; 42 | for (i = 0; i < 256; i++) { 43 | UInt32 r = i; 44 | unsigned j; 45 | for (j = 0; j < 8; j++) 46 | r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); 47 | g_CrcTable[i] = r; 48 | } 49 | for (; i < 256 * CRC_NUM_TABLES; i++) { 50 | UInt32 r = g_CrcTable[i - 256]; 51 | g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); 52 | } 53 | 54 | #ifdef MY_CPU_LE 55 | 56 | g_CrcUpdate = CrcUpdateT4; 57 | 58 | #if CRC_NUM_TABLES == 8 59 | if (!CPU_Is_InOrder()) 60 | g_CrcUpdate = CrcUpdateT8; 61 | #endif 62 | 63 | #else 64 | { 65 | #ifndef MY_CPU_BE 66 | UInt32 k = 1; 67 | if (*(const Byte*)&k == 1) 68 | g_CrcUpdate = CrcUpdateT4; 69 | else 70 | #endif 71 | { 72 | for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) { 73 | UInt32 x = g_CrcTable[i - 256]; 74 | g_CrcTable[i] = CRC_UINT32_SWAP(x); 75 | } 76 | g_CrcUpdate = CrcUpdateT1_BeT4; 77 | } 78 | } 79 | #endif 80 | } 81 | -------------------------------------------------------------------------------- /fex/7z_C/7zCrc.h: -------------------------------------------------------------------------------- 1 | /* 7zCrc.h -- CRC32 calculation 2 | 2009-11-21 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_CRC_H 5 | #define __7Z_CRC_H 6 | 7 | #include "Types.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | extern UInt32 g_CrcTable[]; 12 | 13 | /* Call CrcGenerateTable one time before other CRC functions */ 14 | void MY_FAST_CALL CrcGenerateTable(void); 15 | 16 | #define CRC_INIT_VAL 0xFFFFFFFF 17 | #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) 18 | #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 19 | 20 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void* data, size_t size); 21 | UInt32 MY_FAST_CALL CrcCalc(const void* data, size_t size); 22 | 23 | EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /fex/7z_C/7zCrcOpt.c: -------------------------------------------------------------------------------- 1 | /* 7zCrcOpt.c -- CRC32 calculation 2 | 2010-12-01 : Igor Pavlov : Public domain */ 3 | 4 | #include "CpuArch.h" 5 | 6 | #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 7 | 8 | #ifndef MY_CPU_BE 9 | 10 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void* data, size_t size, const UInt32* table) 11 | { 12 | const Byte* p = (const Byte*)data; 13 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 14 | v = CRC_UPDATE_BYTE_2(v, *p); 15 | for (; size >= 4; size -= 4, p += 4) { 16 | v ^= *(const UInt32*)p; 17 | v = table[0x300 + (v & 0xFF)] ^ table[0x200 + ((v >> 8) & 0xFF)] ^ table[0x100 + ((v >> 16) & 0xFF)] ^ table[0x000 + ((v >> 24))]; 18 | } 19 | for (; size > 0; size--, p++) 20 | v = CRC_UPDATE_BYTE_2(v, *p); 21 | return v; 22 | } 23 | 24 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void* data, size_t size, const UInt32* table) 25 | { 26 | return CrcUpdateT4(v, data, size, table); 27 | } 28 | 29 | #endif 30 | 31 | #ifndef MY_CPU_LE 32 | 33 | #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) 34 | 35 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void* data, size_t size, const UInt32* table) 36 | { 37 | const Byte* p = (const Byte*)data; 38 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 39 | v = CRC_UPDATE_BYTE_2(v, *p); 40 | v = CRC_UINT32_SWAP(v); 41 | table += 0x100; 42 | for (; size >= 4; size -= 4, p += 4) { 43 | v ^= *(const UInt32*)p; 44 | v = table[0x000 + (v & 0xFF)] ^ table[0x100 + ((v >> 8) & 0xFF)] ^ table[0x200 + ((v >> 16) & 0xFF)] ^ table[0x300 + ((v >> 24))]; 45 | } 46 | table -= 0x100; 47 | v = CRC_UINT32_SWAP(v); 48 | for (; size > 0; size--, p++) 49 | v = CRC_UPDATE_BYTE_2(v, *p); 50 | return v; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /fex/7z_C/Bcj2.h: -------------------------------------------------------------------------------- 1 | /* Bcj2.h -- Converter for x86 code (BCJ2) 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BCJ2_H 5 | #define __BCJ2_H 6 | 7 | #include "Types.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* 14 | Conditions: 15 | outSize <= FullOutputSize, 16 | where FullOutputSize is full size of output stream of x86_2 filter. 17 | 18 | If buf0 overlaps outBuf, there are two required conditions: 19 | 1) (buf0 >= outBuf) 20 | 2) (buf0 + size0 >= outBuf + FullOutputSize). 21 | 22 | Returns: 23 | SZ_OK 24 | SZ_ERROR_DATA - Data error 25 | */ 26 | 27 | int Bcj2_Decode( 28 | const Byte* buf0, SizeT size0, 29 | const Byte* buf1, SizeT size1, 30 | const Byte* buf2, SizeT size2, 31 | const Byte* buf3, SizeT size3, 32 | Byte* outBuf, SizeT outSize); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /fex/7z_C/Bra.h: -------------------------------------------------------------------------------- 1 | /* Bra.h -- Branch converters for executables 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BRA_H 5 | #define __BRA_H 6 | 7 | #include "Types.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* 14 | These functions convert relative addresses to absolute addresses 15 | in CALL instructions to increase the compression ratio. 16 | 17 | In: 18 | data - data buffer 19 | size - size of data 20 | ip - current virtual Instruction Pinter (IP) value 21 | state - state variable for x86 converter 22 | encoding - 0 (for decoding), 1 (for encoding) 23 | 24 | Out: 25 | state - state variable for x86 converter 26 | 27 | Returns: 28 | The number of processed bytes. If you call these functions with multiple calls, 29 | you must start next call with first byte after block of processed bytes. 30 | 31 | Type Endian Alignment LookAhead 32 | 33 | x86 little 1 4 34 | ARMT little 2 2 35 | ARM little 4 0 36 | PPC big 4 0 37 | SPARC big 4 0 38 | IA64 little 16 0 39 | 40 | size must be >= Alignment + LookAhead, if it's not last block. 41 | If (size < Alignment + LookAhead), converter returns 0. 42 | 43 | Example: 44 | 45 | UInt32 ip = 0; 46 | for () 47 | { 48 | ; size must be >= Alignment + LookAhead, if it's not last block 49 | SizeT processed = Convert(data, size, ip, 1); 50 | data += processed; 51 | size -= processed; 52 | ip += processed; 53 | } 54 | */ 55 | 56 | #define x86_Convert_Init(state) \ 57 | { \ 58 | state = 0; \ 59 | } 60 | SizeT x86_Convert(Byte* data, SizeT size, UInt32 ip, UInt32* state, int encoding); 61 | SizeT ARM_Convert(Byte* data, SizeT size, UInt32 ip, int encoding); 62 | SizeT ARMT_Convert(Byte* data, SizeT size, UInt32 ip, int encoding); 63 | SizeT PPC_Convert(Byte* data, SizeT size, UInt32 ip, int encoding); 64 | SizeT SPARC_Convert(Byte* data, SizeT size, UInt32 ip, int encoding); 65 | SizeT IA64_Convert(Byte* data, SizeT size, UInt32 ip, int encoding); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /fex/7z_C/Bra86.c: -------------------------------------------------------------------------------- 1 | /* Bra86.c -- Converter for x86 code (BCJ) 2 | 2008-10-04 : Igor Pavlov : Public domain */ 3 | 4 | #include "Bra.h" 5 | 6 | #define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) 7 | 8 | const Byte kMaskToAllowedStatus[8] = { 1, 1, 1, 0, 1, 0, 0, 0 }; 9 | const Byte kMaskToBitNumber[8] = { 0, 1, 2, 2, 3, 3, 3, 3 }; 10 | 11 | SizeT x86_Convert(Byte* data, SizeT size, UInt32 ip, UInt32* state, int encoding) 12 | { 13 | SizeT bufferPos = 0, prevPosT; 14 | UInt32 prevMask = *state & 0x7; 15 | if (size < 5) 16 | return 0; 17 | ip += 5; 18 | prevPosT = (SizeT)0 - 1; 19 | 20 | for (;;) { 21 | Byte* p = data + bufferPos; 22 | Byte* limit = data + size - 4; 23 | for (; p < limit; p++) 24 | if ((*p & 0xFE) == 0xE8) 25 | break; 26 | bufferPos = (SizeT)(p - data); 27 | if (p >= limit) 28 | break; 29 | prevPosT = bufferPos - prevPosT; 30 | if (prevPosT > 3) 31 | prevMask = 0; 32 | else { 33 | prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; 34 | if (prevMask != 0) { 35 | Byte b = p[4 - kMaskToBitNumber[prevMask]]; 36 | if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b)) { 37 | prevPosT = bufferPos; 38 | prevMask = ((prevMask << 1) & 0x7) | 1; 39 | bufferPos++; 40 | continue; 41 | } 42 | } 43 | } 44 | prevPosT = bufferPos; 45 | 46 | if (Test86MSByte(p[4])) { 47 | UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); 48 | UInt32 dest; 49 | for (;;) { 50 | Byte b; 51 | int index; 52 | if (encoding) 53 | dest = (ip + (UInt32)bufferPos) + src; 54 | else 55 | dest = src - (ip + (UInt32)bufferPos); 56 | if (prevMask == 0) 57 | break; 58 | index = kMaskToBitNumber[prevMask] * 8; 59 | b = (Byte)(dest >> (24 - index)); 60 | if (!Test86MSByte(b)) 61 | break; 62 | src = dest ^ ((1 << (32 - index)) - 1); 63 | } 64 | p[4] = (Byte)(~(((dest >> 24) & 1) - 1)); 65 | p[3] = (Byte)(dest >> 16); 66 | p[2] = (Byte)(dest >> 8); 67 | p[1] = (Byte)dest; 68 | bufferPos += 5; 69 | } else { 70 | prevMask = ((prevMask << 1) & 0x7) | 1; 71 | bufferPos++; 72 | } 73 | } 74 | prevPosT = bufferPos - prevPosT; 75 | *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); 76 | return bufferPos; 77 | } 78 | -------------------------------------------------------------------------------- /fex/7z_C/Lzma2Dec.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Dec.h -- LZMA2 Decoder 2 | 2009-05-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_DEC_H 5 | #define __LZMA2_DEC_H 6 | 7 | #include "LzmaDec.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* ---------- State Interface ---------- */ 14 | 15 | typedef struct 16 | { 17 | CLzmaDec decoder; 18 | UInt32 packSize; 19 | UInt32 unpackSize; 20 | int state; 21 | Byte control; 22 | Bool needInitDic; 23 | Bool needInitState; 24 | Bool needInitProp; 25 | } CLzma2Dec; 26 | 27 | #define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) 28 | #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); 29 | #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); 30 | 31 | SRes Lzma2Dec_AllocateProbs(CLzma2Dec* p, Byte prop, ISzAlloc* alloc); 32 | SRes Lzma2Dec_Allocate(CLzma2Dec* p, Byte prop, ISzAlloc* alloc); 33 | void Lzma2Dec_Init(CLzma2Dec* p); 34 | 35 | /* 36 | finishMode: 37 | It has meaning only if the decoding reaches output limit (*destLen or dicLimit). 38 | LZMA_FINISH_ANY - use smallest number of input bytes 39 | LZMA_FINISH_END - read EndOfStream marker after decoding 40 | 41 | Returns: 42 | SZ_OK 43 | status: 44 | LZMA_STATUS_FINISHED_WITH_MARK 45 | LZMA_STATUS_NOT_FINISHED 46 | LZMA_STATUS_NEEDS_MORE_INPUT 47 | SZ_ERROR_DATA - Data error 48 | */ 49 | 50 | SRes Lzma2Dec_DecodeToDic(CLzma2Dec* p, SizeT dicLimit, 51 | const Byte* src, SizeT* srcLen, ELzmaFinishMode finishMode, ELzmaStatus* status); 52 | 53 | SRes Lzma2Dec_DecodeToBuf(CLzma2Dec* p, Byte* dest, SizeT* destLen, 54 | const Byte* src, SizeT* srcLen, ELzmaFinishMode finishMode, ELzmaStatus* status); 55 | 56 | /* ---------- One Call Interface ---------- */ 57 | 58 | /* 59 | finishMode: 60 | It has meaning only if the decoding reaches output limit (*destLen). 61 | LZMA_FINISH_ANY - use smallest number of input bytes 62 | LZMA_FINISH_END - read EndOfStream marker after decoding 63 | 64 | Returns: 65 | SZ_OK 66 | status: 67 | LZMA_STATUS_FINISHED_WITH_MARK 68 | LZMA_STATUS_NOT_FINISHED 69 | SZ_ERROR_DATA - Data error 70 | SZ_ERROR_MEM - Memory allocation error 71 | SZ_ERROR_UNSUPPORTED - Unsupported properties 72 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). 73 | */ 74 | 75 | SRes Lzma2Decode(Byte* dest, SizeT* destLen, const Byte* src, SizeT* srcLen, 76 | Byte prop, ELzmaFinishMode finishMode, ELzmaStatus* status, ISzAlloc* alloc); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /fex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Do not use this file directly. Always use the top level CMakeLists.txt file 2 | #File extractors so the user doesn't have to extract the rom before playing it 3 | 4 | # Source files definition 5 | SET(SRC_FEX 6 | 7z_C/7zAlloc.c 7 | 7z_C/7zBuf.c 8 | 7z_C/7zCrc.c 9 | 7z_C/7zCrcOpt.c 10 | 7z_C/7zDec.c 11 | 7z_C/7zIn.c 12 | 7z_C/7zStream.c 13 | 7z_C/Bcj2.c 14 | 7z_C/Bra86.c 15 | 7z_C/Bra.c 16 | 7z_C/CpuArch.c 17 | 7z_C/Lzma2Dec.c 18 | 7z_C/LzmaDec.c 19 | 7z_C/Ppmd7.c 20 | 7z_C/Ppmd7Dec.c 21 | fex/Binary_Extractor.cpp 22 | fex/blargg_common.cpp 23 | fex/blargg_errors.cpp 24 | fex/Data_Reader.cpp 25 | fex/fex.cpp 26 | fex/File_Extractor.cpp 27 | fex/Gzip_Extractor.cpp 28 | fex/Gzip_Reader.cpp 29 | fex/Rar_Extractor.cpp 30 | fex/Zip7_Extractor.cpp 31 | fex/Zip_Extractor.cpp 32 | fex/Zlib_Inflater.cpp 33 | ) 34 | 35 | INCLUDE_DIRECTORIES( 36 | . 37 | ${ZLIB_INCLUDE_DIRS} 38 | ) 39 | 40 | ADD_LIBRARY( 41 | fex 42 | STATIC 43 | ${SRC_FEX} 44 | ) 45 | -------------------------------------------------------------------------------- /fex/changes.txt: -------------------------------------------------------------------------------- 1 | File_Extractor Change Log 2 | ------------------------- 3 | - Change that might break code. 4 | + Improvement that is unlikely to break any code. 5 | * Other changes. 6 | 7 | 8 | File_Extractor 1.0.0 (2009-10-12) 9 | -------------------- 10 | - Added fex_stat() which MUST be called before getting current file 11 | information beyond name, like fex_size(). 12 | 13 | - Changed fex_*() functions to always report error via return value, 14 | rather than sometimes via a parameter. This will break user code that 15 | uses fex_data(), fex_open(), fex_open_type(), and fex_identify_file(). 16 | See demos for usage. 17 | 18 | - Deprecated C++ interface. Use fex.h and nothing else to access library 19 | from user code. 20 | 21 | - Removed archive types (fex_zip_type, etc.) from interface. Use 22 | fex_identify_extension() to get particular type. 23 | 24 | - Removed fex_mini.c, unzip.h, and unrarlib.h for now, as maintaining 25 | them was too taxing. If others express desire for them, I can re-add 26 | them. 27 | 28 | - Removed fex_scan_only() and fex_read_once(), as they don't improve 29 | performance anymore. Use fex_read() in place of fex_read_once(). 30 | 31 | - Removed fex_remain(). Use fex_size()-fex_tell() to find number of 32 | bytes remaining. 33 | 34 | - Removed fex_set_user_data() and related functions, as they didn't seem 35 | useful to anyone. 36 | 37 | - Removed fex_type_t structure from interface and added accessors 38 | instead (fex_type_name(), fex_type_extension()). 39 | 40 | + Improved archive file type determination to reject other archive types 41 | not handled by the library, rather than opening them as binary files. 42 | 43 | + Added Doxygen compatibility to fex.h. 44 | 45 | + Added fex_crc32() to quickly get CRC-32 of current file from archive 46 | header, without having to read entire file to calculate it. 47 | 48 | + Added fex_err_code() to get numeric error code, along with other 49 | helpful error-related functions. Also added more documentation on how to 50 | handle library errors in user code. 51 | 52 | + Added fex_init() for use in multi-threaded programs. 53 | 54 | + Added fex_seek_arc() to seek to particular file in archive. 55 | 56 | + Added fex_wname() to get Unicode name of current file. 57 | 58 | + Added support for building as DLL. 59 | 60 | + Added support for wide-character file paths on Windows, enabled with 61 | BLARGG_UTF8_PATHS (thanks to byuu for the idea). This is necessary to 62 | support file paths on non-English Windows systems. 63 | 64 | + Started using unit testing during development. 65 | 66 | + Updated to 7-zip 4.65, unrar_core 3.8.5. 67 | 68 | 69 | File_Extractor 0.4.3 (2008-12-08) 70 | -------------------- 71 | * Limited release 72 | -------------------------------------------------------------------------------- /fex/fex/Binary_Extractor.cpp: -------------------------------------------------------------------------------- 1 | // File_Extractor 1.0.0. http://www.slack.net/~ant/ 2 | 3 | #include "Binary_Extractor.h" 4 | 5 | /* Copyright (C) 2005-2009 Shay Green. This module is free software; you 6 | can redistribute it and/or modify it under the terms of the GNU Lesser 7 | General Public License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. This 9 | module is distributed in the hope that it will be useful, but WITHOUT ANY 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | details. You should have received a copy of the GNU Lesser General Public 13 | License along with this module; if not, write to the Free Software Foundation, 14 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #include "blargg_source.h" 17 | 18 | // TODO: could close file once data has been read into memory 19 | 20 | static File_Extractor* new_binary() 21 | { 22 | return BLARGG_NEW Binary_Extractor; 23 | } 24 | 25 | fex_type_t_ const fex_bin_type [1] = {{ 26 | "", 27 | &new_binary, 28 | "file", 29 | NULL 30 | }}; 31 | 32 | Binary_Extractor::Binary_Extractor() : 33 | File_Extractor( fex_bin_type ) 34 | { } 35 | 36 | Binary_Extractor::~Binary_Extractor() 37 | { 38 | close(); 39 | } 40 | 41 | blargg_err_t Binary_Extractor::open_path_v() 42 | { 43 | set_name( arc_path() ); 44 | return blargg_ok; 45 | } 46 | 47 | blargg_err_t Binary_Extractor::open_v() 48 | { 49 | set_name( arc_path() ); 50 | set_info( arc().remain(), 0, 0 ); 51 | return blargg_ok; 52 | } 53 | 54 | void Binary_Extractor::close_v() 55 | { } 56 | 57 | blargg_err_t Binary_Extractor::next_v() 58 | { 59 | return blargg_ok; 60 | } 61 | 62 | blargg_err_t Binary_Extractor::rewind_v() 63 | { 64 | return open_path_v(); 65 | } 66 | 67 | blargg_err_t Binary_Extractor::stat_v() 68 | { 69 | RETURN_ERR( open_arc_file() ); 70 | RETURN_ERR( arc().seek( 0 ) ); 71 | return open_v(); 72 | } 73 | 74 | blargg_err_t Binary_Extractor::extract_v( void* p, int n ) 75 | { 76 | return arc().read( p, n ); 77 | } 78 | -------------------------------------------------------------------------------- /fex/fex/Binary_Extractor.h: -------------------------------------------------------------------------------- 1 | // Presents a single file as an "archive" of just that file. 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef BINARY_EXTRACTOR_H 5 | #define BINARY_EXTRACTOR_H 6 | 7 | #include "File_Extractor.h" 8 | 9 | class Binary_Extractor : public File_Extractor 10 | { 11 | public: 12 | Binary_Extractor(); 13 | virtual ~Binary_Extractor(); 14 | 15 | protected: 16 | virtual blargg_err_t open_path_v(); 17 | virtual blargg_err_t open_v(); 18 | virtual void close_v(); 19 | 20 | virtual blargg_err_t next_v(); 21 | virtual blargg_err_t rewind_v(); 22 | 23 | virtual blargg_err_t stat_v(); 24 | virtual blargg_err_t extract_v(void *, int); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /fex/fex/Gzip_Extractor.cpp: -------------------------------------------------------------------------------- 1 | // File_Extractor 1.0.0. http://www.slack.net/~ant/ 2 | 3 | #include "Gzip_Extractor.h" 4 | 5 | /* Copyright (C) 2005-2009 Shay Green. This module is free software; you 6 | can redistribute it and/or modify it under the terms of the GNU Lesser 7 | General Public License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. This 9 | module is distributed in the hope that it will be useful, but WITHOUT ANY 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | details. You should have received a copy of the GNU Lesser General Public 13 | License along with this module; if not, write to the Free Software Foundation, 14 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #include "blargg_source.h" 17 | 18 | // TODO: could close file once data has been read into memory 19 | 20 | static blargg_err_t init_gzip_file() 21 | { 22 | get_crc_table(); // initialize zlib's CRC-32 tables 23 | return blargg_ok; 24 | } 25 | 26 | static File_Extractor* new_gzip() 27 | { 28 | return BLARGG_NEW Gzip_Extractor; 29 | } 30 | 31 | fex_type_t_ const fex_gz_type [1] = {{ 32 | ".gz", 33 | &new_gzip, 34 | "gzipped file", 35 | &init_gzip_file 36 | }}; 37 | 38 | Gzip_Extractor::Gzip_Extractor() : 39 | File_Extractor( fex_gz_type ) 40 | { } 41 | 42 | Gzip_Extractor::~Gzip_Extractor() 43 | { 44 | close(); 45 | } 46 | 47 | blargg_err_t Gzip_Extractor::open_path_v() 48 | { 49 | // skip opening file 50 | return open_v(); 51 | } 52 | 53 | blargg_err_t Gzip_Extractor::stat_v() 54 | { 55 | RETURN_ERR( open_arc_file( true ) ); 56 | if ( !gr.opened() || gr.tell() != 0 ) 57 | RETURN_ERR( gr.open( &arc() ) ); 58 | 59 | set_info( gr.remain(), 0, gr.crc32() ); 60 | return blargg_ok; 61 | } 62 | 63 | blargg_err_t Gzip_Extractor::open_v() 64 | { 65 | // Remove .gz suffix 66 | size_t len = strlen( arc_path() ); 67 | if ( fex_has_extension( arc_path(), ".gz" ) ) 68 | len -= 3; 69 | 70 | RETURN_ERR( name.resize( len + 1 ) ); 71 | memcpy( name.begin(), arc_path(), name.size() ); 72 | name [name.size() - 1] = '\0'; 73 | 74 | set_name( name.begin() ); 75 | return blargg_ok; 76 | } 77 | 78 | void Gzip_Extractor::close_v() 79 | { 80 | name.clear(); 81 | gr.close(); 82 | } 83 | 84 | blargg_err_t Gzip_Extractor::next_v() 85 | { 86 | return blargg_ok; 87 | } 88 | 89 | blargg_err_t Gzip_Extractor::rewind_v() 90 | { 91 | set_name( name.begin() ); 92 | return blargg_ok; 93 | } 94 | 95 | blargg_err_t Gzip_Extractor::extract_v( void* p, int n ) 96 | { 97 | return gr.read( p, n ); 98 | } 99 | -------------------------------------------------------------------------------- /fex/fex/Gzip_Extractor.h: -------------------------------------------------------------------------------- 1 | // Presents a gzipped file as an "archive" of just that file. 2 | // Also handles non-gzipped files. 3 | 4 | // File_Extractor 1.0.0 5 | #ifndef GZIP_EXTRACTOR_H 6 | #define GZIP_EXTRACTOR_H 7 | 8 | #include "File_Extractor.h" 9 | #include "Gzip_Reader.h" 10 | 11 | class Gzip_Extractor : public File_Extractor 12 | { 13 | public: 14 | Gzip_Extractor(); 15 | virtual ~Gzip_Extractor(); 16 | 17 | protected: 18 | virtual blargg_err_t open_path_v(); 19 | virtual blargg_err_t open_v(); 20 | virtual void close_v(); 21 | 22 | virtual blargg_err_t next_v(); 23 | virtual blargg_err_t rewind_v(); 24 | 25 | virtual blargg_err_t stat_v(); 26 | virtual blargg_err_t extract_v(void *, int); 27 | 28 | private: 29 | Gzip_Reader gr; 30 | blargg_vector name; 31 | 32 | void set_info_(); 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /fex/fex/Gzip_Reader.cpp: -------------------------------------------------------------------------------- 1 | // File_Extractor 1.0.0. http://www.slack.net/~ant/ 2 | 3 | #include "Gzip_Reader.h" 4 | 5 | #include "blargg_endian.h" 6 | 7 | /* Copyright (C) 2006-2009 Shay Green. This module is free software; you 8 | can redistribute it and/or modify it under the terms of the GNU Lesser 9 | General Public License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. This 11 | module is distributed in the hope that it will be useful, but WITHOUT ANY 12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | details. You should have received a copy of the GNU Lesser General Public 15 | License along with this module; if not, write to the Free Software Foundation, 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17 | 18 | #include "blargg_source.h" 19 | 20 | Gzip_Reader::Gzip_Reader() 21 | { 22 | close(); 23 | } 24 | 25 | Gzip_Reader::~Gzip_Reader() 26 | { } 27 | 28 | static blargg_err_t gzip_reader_read( void* file, void* out, int* count ) 29 | { 30 | return STATIC_CAST(File_Reader*,file)->read_avail( out, count ); 31 | } 32 | 33 | blargg_err_t Gzip_Reader::calc_size() 34 | { 35 | size_ = in->size(); 36 | crc32_ = 0; 37 | if ( inflater.deflated() ) 38 | { 39 | byte trailer [8]; 40 | int old_pos = in->tell(); 41 | RETURN_ERR( in->seek( size_ - sizeof trailer ) ); 42 | RETURN_ERR( in->read( trailer, sizeof trailer ) ); 43 | RETURN_ERR( in->seek( old_pos ) ); 44 | crc32_ = get_le32( trailer + 0 ); 45 | 46 | unsigned n = get_le32( trailer + 4 ); 47 | if ( n > INT_MAX ) 48 | return BLARGG_ERR( BLARGG_ERR_FILE_FEATURE, "gzip larger than 2GB" ); 49 | 50 | size_ = n; 51 | } 52 | return blargg_ok; 53 | } 54 | 55 | blargg_err_t Gzip_Reader::open( File_Reader* new_in ) 56 | { 57 | close(); 58 | 59 | in = new_in; 60 | RETURN_ERR( in->seek( 0 ) ); 61 | RETURN_ERR( inflater.begin( gzip_reader_read, new_in ) ); 62 | RETURN_ERR( inflater.set_mode( inflater.mode_auto ) ); 63 | RETURN_ERR( calc_size() ); 64 | set_remain( size_ ); 65 | 66 | return blargg_ok; 67 | } 68 | 69 | void Gzip_Reader::close() 70 | { 71 | in = NULL; 72 | inflater.end(); 73 | } 74 | 75 | blargg_err_t Gzip_Reader::read_v( void* out, int count ) 76 | { 77 | assert( in ); 78 | int actual = count; 79 | RETURN_ERR( inflater.read( out, &actual ) ); 80 | 81 | if ( actual != count ) 82 | return blargg_err_file_corrupt; 83 | 84 | return blargg_ok; 85 | } 86 | -------------------------------------------------------------------------------- /fex/fex/Gzip_Reader.h: -------------------------------------------------------------------------------- 1 | // Transparently decompresses gzip files, as well as uncompressed 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef GZIP_READER_H 5 | #define GZIP_READER_H 6 | 7 | #include "Data_Reader.h" 8 | #include "Zlib_Inflater.h" 9 | 10 | class Gzip_Reader : public Data_Reader 11 | { 12 | public: 13 | // Keeps pointer to reader until close(). If 14 | blargg_err_t open(File_Reader *); 15 | 16 | // True if file is open 17 | bool opened() const 18 | { 19 | return in != NULL; 20 | } 21 | 22 | // Frees memory 23 | void close(); 24 | 25 | // True if file is compressed 26 | bool deflated() const 27 | { 28 | return inflater.deflated(); 29 | } 30 | 31 | // CRC-32 of data, of 0 if unavailable 32 | unsigned int crc32() const 33 | { 34 | return crc32_; 35 | } 36 | 37 | // Number of bytes read since opening 38 | int tell() const 39 | { 40 | return size_ - remain(); 41 | } 42 | 43 | public: 44 | Gzip_Reader(); 45 | virtual ~Gzip_Reader(); 46 | 47 | protected: 48 | virtual blargg_err_t read_v(void *, int); 49 | 50 | private: 51 | File_Reader *in; 52 | unsigned crc32_; 53 | int size_; 54 | Zlib_Inflater inflater; 55 | 56 | blargg_err_t calc_size(); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /fex/fex/Rar_Extractor.h: -------------------------------------------------------------------------------- 1 | // RAR archive extractor 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef RAR_EXTRACTOR_H 5 | #define RAR_EXTRACTOR_H 6 | 7 | #include "File_Extractor.h" 8 | #include "unrar/unrar.h" 9 | 10 | class Rar_Extractor : public File_Extractor 11 | { 12 | public: 13 | Rar_Extractor(); 14 | virtual ~Rar_Extractor(); 15 | 16 | struct read_callback_t { 17 | const char *err; 18 | int pos; 19 | File_Reader *in; 20 | }; 21 | 22 | protected: 23 | virtual blargg_err_t open_v(); 24 | virtual void close_v(); 25 | 26 | virtual blargg_err_t next_v(); 27 | virtual blargg_err_t rewind_v(); 28 | virtual fex_pos_t tell_arc_v() const; 29 | virtual blargg_err_t seek_arc_v(fex_pos_t); 30 | 31 | virtual blargg_err_t data_v(void const **); 32 | virtual blargg_err_t extract_v(void *, int); 33 | 34 | private: 35 | unrar_t *unrar; 36 | read_callback_t reader; 37 | 38 | blargg_err_t convert_err(unrar_err_t); 39 | blargg_err_t skip_unextractables(); 40 | blargg_err_t next_raw(); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /fex/fex/Zip7_Extractor.h: -------------------------------------------------------------------------------- 1 | // 7-zip archive extractor 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef ZIP7_EXTRACTOR_H 5 | #define ZIP7_EXTRACTOR_H 6 | 7 | #include "File_Extractor.h" 8 | 9 | struct Zip7_Extractor_Impl; 10 | 11 | class Zip7_Extractor : public File_Extractor 12 | { 13 | public: 14 | Zip7_Extractor(); 15 | virtual ~Zip7_Extractor(); 16 | 17 | protected: 18 | virtual blargg_err_t open_v(); 19 | virtual void close_v(); 20 | 21 | virtual blargg_err_t next_v(); 22 | virtual blargg_err_t rewind_v(); 23 | virtual fex_pos_t tell_arc_v() const; 24 | virtual blargg_err_t seek_arc_v(fex_pos_t); 25 | 26 | virtual blargg_err_t data_v(void const **out); 27 | 28 | bool utf16ToUtf8(unsigned char *dest, size_t *destLen, const short *src, size_t srcLen); 29 | 30 | private: 31 | Zip7_Extractor_Impl *impl; 32 | int index; 33 | blargg_vector name8; 34 | blargg_vector name16; 35 | 36 | blargg_err_t zip7_err(int err); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /fex/fex/Zip_Extractor.h: -------------------------------------------------------------------------------- 1 | // ZIP archive extractor. Only supports deflation and store (no compression). 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef ZIP_EXTRACTOR_H 5 | #define ZIP_EXTRACTOR_H 6 | 7 | #include "File_Extractor.h" 8 | #include "Zlib_Inflater.h" 9 | 10 | class Zip_Extractor : public File_Extractor 11 | { 12 | public: 13 | Zip_Extractor(); 14 | virtual ~Zip_Extractor(); 15 | 16 | protected: 17 | virtual blargg_err_t open_path_v(); 18 | virtual blargg_err_t open_v(); 19 | virtual void close_v(); 20 | 21 | virtual void clear_file_v(); 22 | virtual blargg_err_t next_v(); 23 | virtual blargg_err_t rewind_v(); 24 | virtual fex_pos_t tell_arc_v() const; 25 | virtual blargg_err_t seek_arc_v(fex_pos_t); 26 | 27 | virtual blargg_err_t extract_v(void *, int); 28 | 29 | private: 30 | blargg_vector catalog; 31 | int catalog_begin; // offset of first catalog entry in file (to detect corruption) 32 | int catalog_pos; // position of current entry in catalog 33 | int raw_remain; // bytes remaining to be read from zip file for current file 34 | unsigned crc; // ongoing CRC of extracted bytes 35 | unsigned correct_crc; 36 | bool file_deflated; 37 | Zlib_Inflater buf; 38 | 39 | blargg_err_t fill_buf(int offset, int buf_size, int initial_read); 40 | blargg_err_t update_info(bool advance_first); 41 | blargg_err_t first_read(int count); 42 | void reorder_entry_header(int offset); 43 | static blargg_err_t inflater_read(void *data, void *out, int *count); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /fex/fex/Zlib_Inflater.h: -------------------------------------------------------------------------------- 1 | // Simplifies use of zlib for inflating data 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef ZLIB_INFLATER_H 5 | #define ZLIB_INFLATER_H 6 | 7 | #include "Data_Reader.h" 8 | #include "blargg_common.h" 9 | #include "zlib.h" 10 | 11 | class Zlib_Inflater 12 | { 13 | public: 14 | // Reads at most min(*count,bytes_until_eof()) bytes into *out and set *count 15 | // to that number, or returns error if that many can't be read. 16 | typedef blargg_err_t (*callback_t)(void *user_data, void *out, int *count); 17 | 18 | // Begins by setting callback and filling buffer. Default buffer is 16K and 19 | // filled to 4K, or specify buf_size and initial_read for custom buffer size 20 | // and how much to read initially. 21 | blargg_err_t begin(callback_t, void *user_data, int buf_size = 0, int initial_read = 0); 22 | 23 | // Data read into buffer by begin() 24 | const unsigned char *data() const 25 | { 26 | return zbuf.next_in; 27 | } 28 | int filled() const 29 | { 30 | return zbuf.avail_in; 31 | } 32 | 33 | // Begins inflation using specified mode. Using mode_auto selects between 34 | // mode_copy and mode_ungz by examining first two bytes of buffer. Use 35 | // buf_offset to specify where data begins in buffer, in case there is 36 | // header data that should be skipped. 37 | enum mode_t { mode_copy, mode_ungz, mode_raw_deflate, mode_auto }; 38 | blargg_err_t set_mode(mode_t, int buf_offset = 0); 39 | 40 | // True if set_mode() has been called with mode_ungz or mode_raw_deflate 41 | bool deflated() const 42 | { 43 | return deflated_; 44 | } 45 | 46 | // Reads/inflates at most *count_io bytes into *out and sets *count_io to actual 47 | // number of bytes read (less than requested if end of data was reached). 48 | // Buffers source data internally, even in copy mode, so input file can be 49 | // unbuffered without sacrificing performance. 50 | blargg_err_t read(void *out, int *count_io); 51 | 52 | // Total number of bytes read since begin() 53 | int tell() const 54 | { 55 | return zbuf.total_out; 56 | } 57 | 58 | // Ends inflation and frees memory 59 | void end(); 60 | 61 | private: 62 | // noncopyable 63 | Zlib_Inflater(const Zlib_Inflater &); 64 | Zlib_Inflater &operator=(const Zlib_Inflater &); 65 | 66 | // Implementation 67 | public: 68 | Zlib_Inflater(); 69 | ~Zlib_Inflater(); 70 | 71 | private: 72 | z_stream_s zbuf; 73 | blargg_vector buf; 74 | bool deflated_; 75 | callback_t callback; 76 | void *user_data; 77 | 78 | blargg_err_t fill_buf(int count); 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /fex/fex/blargg_common.cpp: -------------------------------------------------------------------------------- 1 | // File_Extractor 1.0.0. http://www.slack.net/~ant/ 2 | 3 | #include "blargg_common.h" 4 | 5 | /* Copyright (C) 2008-2009 Shay Green. This module is free software; you 6 | can redistribute it and/or modify it under the terms of the GNU Lesser 7 | General Public License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. This 9 | module is distributed in the hope that it will be useful, but WITHOUT ANY 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 | details. You should have received a copy of the GNU Lesser General Public 13 | License along with this module; if not, write to the Free Software Foundation, 14 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #include "blargg_source.h" 17 | 18 | void blargg_vector_::init() 19 | { 20 | begin_ = NULL; 21 | size_ = 0; 22 | } 23 | 24 | void blargg_vector_::clear() 25 | { 26 | void* p = begin_; 27 | begin_ = NULL; 28 | size_ = 0; 29 | free( p ); 30 | } 31 | 32 | blargg_err_t blargg_vector_::resize_( size_t n, size_t elem_size ) 33 | { 34 | if ( n != size_ ) 35 | { 36 | if ( n == 0 ) 37 | { 38 | // Simpler to handle explicitly. Realloc will handle a size of 0, 39 | // but then we have to avoid raising an error for a NULL return. 40 | clear(); 41 | } 42 | else 43 | { 44 | void* p = realloc( begin_, n * elem_size ); 45 | CHECK_ALLOC( p ); 46 | begin_ = p; 47 | size_ = n; 48 | } 49 | } 50 | return blargg_ok; 51 | } 52 | -------------------------------------------------------------------------------- /fex/fex/blargg_config.h: -------------------------------------------------------------------------------- 1 | // Library configuration. Modify this file as necessary. 2 | 3 | // File_Extractor 1.0.0 4 | #ifndef BLARGG_CONFIG_H 5 | #define BLARGG_CONFIG_H 6 | 7 | // Uncomment a #define line below to have effect described. 8 | 9 | // Enable RAR archive support. Doing so adds extra licensing restrictions 10 | // to this library (see unrar/readme.txt for more information). 11 | //#define FEX_ENABLE_RAR 1 12 | 13 | // Accept file paths encoded as UTF-8. Currently only affects Windows, 14 | // as Unix/Linux/Mac OS X already use UTF-8 paths. 15 | //#define BLARGG_UTF8_PATHS 1 16 | 17 | // Enable support for as building DLL on Windows. 18 | //#define BLARGG_BUILD_DLL 1 19 | 20 | // Support only the listed archive types. Remove any you don't need. 21 | #define FEX_TYPE_LIST fex_7z_type, fex_gz_type, fex_zip_type, 22 | 23 | // Use standard config.h if present 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /fex/internals.txt: -------------------------------------------------------------------------------- 1 | File_Extractor library internals 2 | -------------------------------- 3 | This describes the implementation and design. 4 | 5 | Contents 6 | -------- 7 | * Framework 8 | * Archive abstraction 9 | * 7-ZIP 10 | * ZIP 11 | * RAR 12 | * GZIP 13 | * Binary 14 | 15 | 16 | Framework 17 | --------- 18 | This library is essentially: 19 | 20 | * Several archive readers 21 | * Wrappers to provide common interface 22 | * File type detection 23 | 24 | The File_Extractor base class implements the common aspects of the 25 | interface and filters out invalid calls. It also provides default 26 | implementations for some operations. Each derived *_Extractor class then 27 | wraps the particular library. 28 | 29 | Then fex.h provides a stable, C-compatible wrapper over File_Extractor, 30 | and does file type identification. 31 | 32 | 33 | Archive abstraction 34 | ------------------- 35 | An extractor is abstracted to these fundamental operations: 36 | 37 | * Open (either from path or custom reader) 38 | * Iterate over each file 39 | * Extract file's data (either gradually, or all at once into memory) 40 | * Seek to particular file in archive 41 | * Close 42 | 43 | The extractor can choose whether to open a file path immediately, or 44 | defer until the first stat() call. When extracting data, it can 45 | implement one or both of normal read and "give me a pointer to the data 46 | already in memory". If it only implements one, File_Extractor will 47 | implement the other in terms of it. 48 | 49 | 50 | 7-ZIP 51 | ----- 52 | A fairly simple wrapper over a slightly-modified LZMA library. 53 | Unfortunately you probably won't be able to drop a later version of the 54 | LZMA library sources in and recompile, as the interface and file 55 | arrangement tends to change with every release. The main change I've 56 | made is to declare functions extern "C" in headers, so C++ code can call 57 | them. 58 | 59 | 60 | ZIP 61 | --- 62 | A complete implementation I wrote. Has nifty optimization that makes all 63 | disk reads begin and end on a multiple of 4K. Also minimizes number of 64 | accesses when initially reading catalog, and extracting file data. 65 | Correctly handles empty zip archives, unlike the popular unzip library 66 | which reports it as a bad archive. 67 | 68 | 69 | RAR 70 | --- 71 | Wrapper over heavily-modified UnRAR extraction library based on the 72 | official UnRAR sources. The library is available separately with 73 | documentation and demos, in case you want to use it without the 74 | File_Extractor front-end (see unrar/changes.txt for more). 75 | 76 | 77 | GZIP 78 | ---- 79 | Uses zlib's built-in parsing. Also works with non-gzipped files, based 80 | on absence of two-byte Gzip header. Defers opening of file until 81 | fex_stat(), speeding mere scanning of filenames. Gzip_Reader and 82 | Zlib_Reader further divide the implementation into more manageable and 83 | reusable components. 84 | 85 | 86 | Binary 87 | ------ 88 | Just a minimal wrapper over C-style FILE. 89 | 90 | -- 91 | Shay Green 92 | -------------------------------------------------------------------------------- /fex/readme.txt: -------------------------------------------------------------------------------- 1 | File_Extractor 1.0.0 2 | -------------------- 3 | File_Extractor is a modular archive scanning and extraction library that 4 | supports several popular compressed file formats. It gives a common 5 | interface to the supported formats, allowing one version of user code. 6 | 7 | Features: 8 | * Simple C interface. 9 | * Supports ZIP, GZIP, 7-Zip (7Z), and RAR[1] archive formats. 10 | * Non-archive files act like archive of that one file, simplifying code. 11 | * Modular design allows removal of support for unneeded archive formats. 12 | * Optionally supports wide-character paths on Windows. 13 | * Archive file type identification can be customized 14 | 15 | [1] RAR support must be enabled before use, due to its special 16 | licensing. 17 | 18 | Author : Shay Green 19 | Website : http://code.google.com/p/file-extractor/ 20 | License : GNU LGPL 2.1 or later for all except unrar 21 | Language: C interface, C++ implementation 22 | 23 | 24 | Getting Started 25 | --------------- 26 | Build the demo by typing "make" at the command-line. If that doesn't 27 | work, manually build a program from demo.c and all *.c and *.cpp files 28 | in fex/, 7z_C/, and zlib/. Run demo with test.zip in the same directory. 29 | 30 | To enable RAR archive support, edit fex/blargg_config.h. 31 | 32 | See fex.h for reference and fex.txt for documentation. 33 | 34 | 35 | Files 36 | ----- 37 | fex.txt Manual 38 | license.txt GNU LGPL 2.1 license 39 | 40 | makefile Builds libfex.a and demo 41 | 42 | demo.c Basic usage 43 | demo_read.c Uses fex_read() to extract data 44 | demo_rewind.c Uses fex_rewind() to re-scan archive 45 | demo_seek.c Uses fex_seek_arc() to go back to files 46 | demo_directory.c Recursively scans directory for archives 47 | demo.zip Test archive used by demos 48 | 49 | fex/ 50 | blargg_config.h Configuration (modify as needed) 51 | fex.h C interface (also usable from C++) 52 | (all other files) Library sources 53 | 54 | zlib/ Zip/Gzip (can use your system's instead) 55 | 7z_C/ 7-Zip 56 | unrar/ RAR 57 | 58 | -- 59 | Shay Green 60 | -------------------------------------------------------------------------------- /po/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(ENABLE_WX) 2 | add_subdirectory(wxvbam) 3 | ENDIF(ENABLE_WX) 4 | 5 | -------------------------------------------------------------------------------- /po/update_pot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate translation template file for the wxWidgets port 3 | wxrc -g ../src/wx/xrc/*.xrc -o wx-xrc-strings.h 4 | 5 | xgettext -k_ -kN_ -o wxvbam/wxvbam.pot ../src/wx/*.cpp ../src/wx/*.h ../src/wx/widgets/*.cpp wx-xrc-strings.h 6 | 7 | rm -r wx-xrc-strings.h 8 | -------------------------------------------------------------------------------- /po/wxvbam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po") 2 | 3 | GETTEXT_CREATE_TRANSLATIONS( 4 | wxvbam.pot 5 | ${po_files} 6 | ) 7 | 8 | ADD_DEPENDENCIES(visualboyadvance-m translations) 9 | -------------------------------------------------------------------------------- /src/AutoBuild.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 3 | // Copyright (C) 1999-2003 Forgotten 4 | // Copyright (C) 2004 Forgotten and the VBA development team 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2, or(at your option) 9 | // any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software Foundation, 18 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | #ifndef __AUTOBUILD_H__ 21 | #define __AUTOBUILD_H__ 22 | #include "version.h" 23 | // change the FALSE to TRUE for autoincrement of build number 24 | #define INCREMENT_VERSION FALSE 25 | #define FILEVER 2, 0, 0, 600 26 | #define PRODUCTVER 2, 0, 0, 600 27 | #define STRFILEVER "2, 0, 0, 600\0" 28 | #define STRPRODUCTVER "2, 0, 0, 600\0" 29 | #endif //__AUTOBUILD_H__ 30 | -------------------------------------------------------------------------------- /src/NLS.h: -------------------------------------------------------------------------------- 1 | #define N_(String) (String) 2 | 3 | #define MSG_UNSUPPORTED_VBA_SGM 1 4 | #define MSG_CANNOT_LOAD_SGM 2 5 | #define MSG_SAVE_GAME_NOT_USING_BIOS 3 6 | #define MSG_SAVE_GAME_USING_BIOS 4 7 | #define MSG_UNSUPPORTED_SAVE_TYPE 5 8 | #define MSG_CANNOT_OPEN_FILE 6 9 | #define MSG_BAD_ZIP_FILE 7 10 | #define MSG_NO_IMAGE_ON_ZIP 8 11 | #define MSG_ERROR_OPENING_IMAGE 9 12 | #define MSG_ERROR_READING_IMAGE 10 13 | #define MSG_UNSUPPORTED_BIOS_FUNCTION 11 14 | #define MSG_INVALID_BIOS_FILE_SIZE 12 15 | #define MSG_INVALID_CHEAT_CODE 13 16 | #define MSG_UNKNOWN_ARM_OPCODE 14 17 | #define MSG_UNKNOWN_THUMB_OPCODE 15 18 | #define MSG_ERROR_CREATING_FILE 16 19 | #define MSG_FAILED_TO_READ_SGM 17 20 | #define MSG_FAILED_TO_READ_RTC 18 21 | #define MSG_UNSUPPORTED_VB_SGM 19 22 | #define MSG_CANNOT_LOAD_SGM_FOR 20 23 | #define MSG_ERROR_OPENING_IMAGE_FROM 21 24 | #define MSG_ERROR_READING_IMAGE_FROM 22 25 | #define MSG_UNSUPPORTED_ROM_SIZE 23 26 | #define MSG_UNSUPPORTED_RAM_SIZE 24 27 | #define MSG_UNKNOWN_CARTRIDGE_TYPE 25 28 | #define MSG_MAXIMUM_NUMBER_OF_CHEATS 26 29 | #define MSG_INVALID_GAMESHARK_CODE 27 30 | #define MSG_INVALID_GAMEGENIE_CODE 28 31 | #define MSG_INVALID_CHEAT_TO_REMOVE 29 32 | #define MSG_INVALID_CHEAT_CODE_ADDRESS 30 33 | #define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31 34 | #define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32 35 | #define MSG_INVALID_GSA_CODE 33 36 | #define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34 37 | #define MSG_UNSUPPORTED_SNAPSHOT_FILE 35 38 | #define MSG_UNSUPPORTED_ARM_MODE 36 39 | #define MSG_UNSUPPORTED_CODE_FILE 37 40 | #define MSG_GBA_CODE_WARNING 38 41 | #define MSG_INVALID_CBA_CODE 39 42 | #define MSG_CBA_CODE_WARNING 40 43 | #define MSG_OUT_OF_MEMORY 41 44 | #define MSG_WRONG_GAMESHARK_CODE 42 45 | #define MSG_UNSUPPORTED_GAMESHARK_CODE 43 46 | -------------------------------------------------------------------------------- /src/Util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H 2 | #define UTIL_H 3 | 4 | #include 5 | #include "System.h" 6 | 7 | #ifdef _WIN32 8 | #define FILE_SEP '\\' 9 | #else // MacOS, Unix 10 | #define FILE_SEP '/' 11 | #endif 12 | 13 | #define FREAD_UNCHECKED(A,B,C,D) (void)(fread(A,B,C,D) + 1) 14 | 15 | enum IMAGE_TYPE { IMAGE_UNKNOWN = -1, IMAGE_GBA = 0, IMAGE_GB = 1 }; 16 | 17 | // save game 18 | typedef struct { 19 | void *address; 20 | int size; 21 | } variable_desc; 22 | 23 | bool FileExists(const char *filename); 24 | 25 | std::string get_xdg_user_config_home(); 26 | std::string get_xdg_user_data_home(); 27 | 28 | void utilReadScreenPixels(uint8_t *dest, int w, int h); 29 | #ifndef __LIBRETRO__ 30 | bool utilWritePNGFile(const char *, int, int, uint8_t *); 31 | bool utilWriteBMPFile(const char *, int, int, uint8_t *); 32 | #endif 33 | void utilApplyIPS(const char *ips, uint8_t **rom, int *size); 34 | bool utilIsGBAImage(const char *); 35 | bool utilIsGBImage(const char *); 36 | bool utilIsGzipFile(const char *); 37 | bool utilIsZipFile(const char *); 38 | void utilStripDoubleExtension(const char *, char *); 39 | IMAGE_TYPE utilFindType(const char *); 40 | uint8_t *utilLoad(const char *, bool (*)(const char *), uint8_t *, int &); 41 | void utilExtract(const char *filepath, const char *filename); 42 | 43 | void utilPutDword(uint8_t *, uint32_t); 44 | void utilPutWord(uint8_t *, uint16_t); 45 | void utilGBAFindSave(const int); 46 | void utilUpdateSystemColorMaps(bool lcd = false); 47 | bool utilFileExists(const char *filename); 48 | 49 | #ifdef __LIBRETRO__ 50 | void utilWriteIntMem(uint8_t *&data, int); 51 | void utilWriteMem(uint8_t *&data, const void *in_data, unsigned size); 52 | void utilWriteDataMem(uint8_t *&data, variable_desc *); 53 | 54 | int utilReadIntMem(const uint8_t *&data); 55 | void utilReadMem(void *buf, const uint8_t *&data, unsigned size); 56 | void utilReadDataMem(const uint8_t *&data, variable_desc *); 57 | #else 58 | gzFile utilGzOpen(const char *file, const char *mode); 59 | gzFile utilMemGzOpen(char *memory, int available, const char *mode); 60 | int utilGzWrite(gzFile file, const voidp buffer, unsigned int len); 61 | int utilGzRead(gzFile file, voidp buffer, unsigned int len); 62 | int utilGzClose(gzFile file); 63 | z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence); 64 | long utilGzMemTell(gzFile file); 65 | void utilWriteData(gzFile, variable_desc *); 66 | void utilReadData(gzFile, variable_desc *); 67 | void utilReadDataSkip(gzFile, variable_desc *); 68 | int utilReadInt(gzFile); 69 | void utilWriteInt(gzFile, int); 70 | #endif 71 | 72 | #endif // UTIL_H 73 | -------------------------------------------------------------------------------- /src/apu/blargg_config.h: -------------------------------------------------------------------------------- 1 | // $package user configuration file. Don't replace when updating library. 2 | 3 | #ifndef BLARGG_CONFIG_H 4 | #define BLARGG_CONFIG_H 5 | 6 | // Uncomment to have Gb_Apu run at 4x normal clock rate (16777216 Hz), useful in 7 | // a Game Boy Advance emulator. 8 | #define GB_APU_OVERCLOCK 4 9 | 10 | #define GB_APU_CUSTOM_STATE 1 11 | 12 | // Uncomment to enable platform-specific (and possibly non-portable) optimizations. 13 | //#define BLARGG_NONPORTABLE 1 14 | 15 | // Uncomment if automatic byte-order determination doesn't work 16 | //#define BLARGG_BIG_ENDIAN 1 17 | 18 | // Uncomment to use zlib for transparent decompression of gzipped files 19 | //#define HAVE_ZLIB_H 20 | 21 | // Uncomment if you get errors in the bool section of blargg_common.h 22 | //#define BLARGG_COMPILER_HAS_BOOL 1 23 | 24 | // Uncomment to disable out-of-memory exceptions 25 | //#include 26 | //#define BLARGG_NEW new (std::nothrow) 27 | 28 | // Use standard config.h if present 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/common/BSD.h: -------------------------------------------------------------------------------- 1 | #ifndef VBAM_BSD_H 2 | #define VBAM_BSD_H 3 | 4 | #define fopen64 fopen 5 | #define fseeko64 fseeko 6 | #define fseek64 fseek 7 | #define ftell64 ftell 8 | #define ftello64 ftello 9 | 10 | #endif // VBAM_BSD_H 11 | 12 | -------------------------------------------------------------------------------- /src/common/Patch.h: -------------------------------------------------------------------------------- 1 | #ifndef PATCH_H 2 | #define PATCH_H 3 | 4 | #include "Types.h" 5 | 6 | bool applyPatch(const char *patchname, uint8_t **rom, int *size); 7 | 8 | #endif // PATCH_H 9 | -------------------------------------------------------------------------------- /src/common/Port.h: -------------------------------------------------------------------------------- 1 | #ifndef PORT_H 2 | #define PORT_H 3 | 4 | #include "Types.h" 5 | 6 | #ifdef __PS3__ 7 | /* PlayStation3 */ 8 | #include 9 | #endif 10 | 11 | #ifdef _XBOX360 12 | /* XBox 360 */ 13 | #include 14 | #endif 15 | 16 | // swaps a 16-bit value 17 | static inline uint16_t swap16(uint16_t v) 18 | { 19 | return (v << 8) | (v >> 8); 20 | } 21 | 22 | // swaps a 32-bit value 23 | static inline uint32_t swap32(uint32_t v) 24 | { 25 | return (v << 24) | ((v << 8) & 0xff0000) | ((v >> 8) & 0xff00) | (v >> 24); 26 | } 27 | 28 | #ifdef WORDS_BIGENDIAN 29 | #if defined(__GNUC__) && defined(__ppc__) 30 | 31 | #define READ16LE(base) \ 32 | ({ \ 33 | unsigned short lhbrxResult; \ 34 | __asm__("lhbrx %0, 0, %1" : "=r"(lhbrxResult) : "r"(base) : "memory"); \ 35 | lhbrxResult; \ 36 | }) 37 | 38 | #define READ32LE(base) \ 39 | ({ \ 40 | unsigned long lwbrxResult; \ 41 | __asm__("lwbrx %0, 0, %1" : "=r"(lwbrxResult) : "r"(base) : "memory"); \ 42 | lwbrxResult; \ 43 | }) 44 | 45 | #define WRITE16LE(base, value) __asm__("sthbrx %0, 0, %1" : : "r"(value), "r"(base) : "memory") 46 | 47 | #define WRITE32LE(base, value) __asm__("stwbrx %0, 0, %1" : : "r"(value), "r"(base) : "memory") 48 | 49 | #else 50 | #define READ16LE(x) swap16(*((uint16_t *)(x))) 51 | #define READ32LE(x) swap32(*((uint32_t *)(x))) 52 | #define WRITE16LE(x, v) *((uint16_t *)x) = swap16((v)) 53 | #define WRITE32LE(x, v) *((uint32_t *)x) = swap32((v)) 54 | #endif 55 | #else 56 | #define READ16LE(x) *((uint16_t *)x) 57 | #define READ32LE(x) *((uint32_t *)x) 58 | #define WRITE16LE(x, v) *((uint16_t *)x) = (v) 59 | #define WRITE32LE(x, v) *((uint32_t *)x) = (v) 60 | #endif 61 | 62 | #endif // PORT_H 63 | -------------------------------------------------------------------------------- /src/common/SoundDriver.h: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 2015 VBA-M development team 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2, or(at your option) 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software Foundation, 16 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | #ifndef __VBA_SOUND_DRIVER_H__ 19 | #define __VBA_SOUND_DRIVER_H__ 20 | 21 | #include // for uint16_t 22 | 23 | /** 24 | * Sound driver abstract interface for the core to use to output sound. 25 | * Subclass this to implement a new sound driver. 26 | */ 27 | class SoundDriver 28 | { 29 | public: 30 | /** 31 | * Destructor. Free the resources allocated by the sound driver. 32 | */ 33 | virtual ~SoundDriver(){}; 34 | 35 | /** 36 | * Initialize the sound driver. 37 | * @param sampleRate In Hertz 38 | */ 39 | virtual bool init(long sampleRate) = 0; 40 | 41 | /** 42 | * Tell the driver that the sound stream has paused 43 | */ 44 | virtual void pause() = 0; 45 | 46 | /** 47 | * Reset the sound driver 48 | */ 49 | virtual void reset() = 0; 50 | 51 | /** 52 | * Tell the driver that the sound stream has resumed 53 | */ 54 | virtual void resume() = 0; 55 | 56 | /** 57 | * Write length bytes of data from the finalWave buffer to the driver output buffer. 58 | */ 59 | virtual void write(uint16_t *finalWave, int length) = 0; 60 | 61 | virtual void setThrottle(unsigned short throttle) = 0; 62 | }; 63 | 64 | #endif // __VBA_SOUND_DRIVER_H__ 65 | -------------------------------------------------------------------------------- /src/common/SoundSDL.h: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 2015 VBA-M development team 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2, or(at your option) 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software Foundation, 16 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | #ifndef __VBA_SOUND_SDL_H__ 19 | #define __VBA_SOUND_SDL_H__ 20 | 21 | #include "ringbuffer.h" 22 | #include "SoundDriver.h" 23 | 24 | #include "SDL.h" 25 | 26 | class SoundSDL : public SoundDriver { 27 | public: 28 | SoundSDL(); 29 | virtual ~SoundSDL(); 30 | 31 | virtual bool init(long sampleRate); 32 | virtual void pause(); 33 | virtual void reset(); 34 | virtual void resume(); 35 | virtual void write(uint16_t *finalWave, int length); 36 | virtual void setThrottle(unsigned short throttle_); 37 | 38 | protected: 39 | static void soundCallback(void* data, uint8_t* stream, int length); 40 | virtual void read(uint16_t* stream, int length); 41 | virtual bool should_wait(); 42 | virtual std::size_t buffer_size(); 43 | virtual void deinit(); 44 | 45 | private: 46 | RingBuffer samples_buf; 47 | 48 | SDL_AudioDeviceID sound_device = 0; 49 | 50 | SDL_mutex* mutex; 51 | SDL_sem* data_available; 52 | SDL_sem* data_read; 53 | SDL_AudioSpec audio_spec; 54 | 55 | unsigned short current_rate; 56 | 57 | bool initialized = false; 58 | 59 | // Defines what delay in seconds we keep in the sound buffer 60 | static const double buftime; 61 | }; 62 | 63 | #endif // __VBA_SOUND_SDL_H__ 64 | -------------------------------------------------------------------------------- /src/common/Types.h: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 2008 VBA-M development team 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2, or(at your option) 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software Foundation, 16 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | #ifndef __VBA_TYPES_H__ 19 | #define __VBA_TYPES_H__ 20 | 21 | #ifdef __LIBRETRO__ 22 | #include 23 | #else 24 | #include 25 | #include "cstdint.h" 26 | #endif 27 | 28 | #endif // __VBA_TYPES_H__ 29 | -------------------------------------------------------------------------------- /src/common/array.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAY_H 2 | #define ARRAY_H 3 | 4 | #include 5 | #include 6 | 7 | template class Array 8 | { 9 | public: 10 | typedef T value_type; 11 | typedef size_t size_type; 12 | typedef ptrdiff_t difference_type; 13 | typedef T &reference; 14 | typedef const T &const_reference; 15 | typedef T *pointer; 16 | typedef const T *const_pointer; 17 | typedef T *iterator; 18 | typedef const T *const_iterator; 19 | typedef std::reverse_iterator reverse_iterator; 20 | typedef std::reverse_iterator const_reverse_iterator; 21 | 22 | private: 23 | pointer m_p; 24 | size_type m_size; 25 | bool dealloc; 26 | 27 | public: 28 | Array(size_type size = 0) 29 | { 30 | m_p = NULL; 31 | dealloc = false; 32 | 33 | if (size) { 34 | m_p = new value_type[size]; 35 | m_size = size; 36 | dealloc = true; 37 | } 38 | } 39 | 40 | void reset(size_t size) 41 | { 42 | if (this->m_p) { 43 | delete[] this->m_p; 44 | this->m_p = NULL; 45 | } 46 | 47 | if (size) { 48 | this->m_p = new value_type[size]; 49 | dealloc = true; 50 | } 51 | this->m_size = size; 52 | } 53 | 54 | ~Array() 55 | { 56 | if (dealloc) delete[] m_p; 57 | } 58 | 59 | size_type size() const 60 | { 61 | return (this->m_size); 62 | } 63 | 64 | operator pointer() 65 | { 66 | return (this->m_p); 67 | } 68 | operator const_pointer() const 69 | { 70 | return (this->m_p); 71 | } 72 | 73 | /// TODO: Add more functions from here: http://en.cppreference.com/w/cpp/container/array 74 | }; 75 | #endif 76 | -------------------------------------------------------------------------------- /src/common/cstdint.h: -------------------------------------------------------------------------------- 1 | #ifndef CSTDINT_H 2 | #define CSTDINT_H 3 | 4 | #if defined(__has_include) 5 | # if __has_include() 6 | # include 7 | // necessary on Mac OS X Lion 10.7 or any clang <= 3.0 8 | # elif __has_include() 9 | # include 10 | # else 11 | // throw error 12 | # include 13 | # endif 14 | #else 15 | # include 16 | #endif 17 | 18 | #endif // CSTDINT_H 19 | -------------------------------------------------------------------------------- /src/common/memgzio.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMGZIO_H 2 | #define MEMGZIO_H 3 | 4 | /* gzio.c -- IO on .gz files 5 | * Copyright (C) 1995-2002 Jean-loup Gailly. 6 | * For conditions of distribution and use, see copyright notice in zlib.h 7 | * 8 | * Compile this file with -DNO_DEFLATE to avoid the compression code. 9 | */ 10 | 11 | /* memgzio.c - IO on .gz files in memory 12 | * Adapted from original gzio.c from zlib library by Forgotten 13 | */ 14 | 15 | #include 16 | 17 | gzFile ZEXPORT memgzopen(char *memory, int available, const char *mode); 18 | int ZEXPORT memgzread(gzFile file, voidp buf, unsigned len); 19 | int ZEXPORT memgzwrite(gzFile file, const voidp buf, unsigned len); 20 | int ZEXPORT memgzclose(gzFile file); 21 | long ZEXPORT memtell(gzFile file); 22 | z_off_t ZEXPORT memgzseek(gzFile file, z_off_t off, int whence); 23 | 24 | // Newer version of zlib dropped gzio support 25 | #ifndef OF /* function prototypes */ 26 | # ifdef STDC 27 | # define OF(args) args 28 | # else 29 | # define OF(args) () 30 | # endif 31 | #endif 32 | 33 | #endif // MEMGZIO_H 34 | -------------------------------------------------------------------------------- /src/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /src/debian/control: -------------------------------------------------------------------------------- 1 | Source: vbam 2 | Section: otherosfs 3 | Priority: optional 4 | Maintainer: Sérgio Benjamim 5 | Build-Depends: debhelper (>= 9), 6 | cmake (>= 2.6.0), 7 | libpng12-dev, 8 | imagemagick, 9 | libopenal-dev, 10 | libsdl2.0-dev, 11 | libwxbase3.0-dev, 12 | libwxgtk3.0-dev, 13 | libcairo2-dev, 14 | libsfml-dev, 15 | nasm [i386 amd64], 16 | liblircclient-dev, 17 | libavcodec-dev, 18 | libavformat-dev, 19 | libswscale-dev, 20 | libavutil-dev, 21 | libgl1-mesa-dev, 22 | zip, 23 | zlib1g-dev 24 | Standards-Version: 3.9.5 25 | Homepage: http://vba-m.com 26 | Vcs-Svn: svn://svn.code.sf.net/p/vbam/code/trunk 27 | Vcs-Browser: http://svn.code.sf.net/p/vbam/code/trunk 28 | 29 | Package: vbam-sdl 30 | Architecture: any 31 | Depends: ${shlibs:Depends}, ${misc:Depends} 32 | Description: Nintendo Game Boy Advance emulator 33 | VisualBoyAdvance-M is a Nintendo Game Boy Emulator with high compatibility 34 | with commercial games. It emulates the Nintendo Game Boy Advance handheld 35 | console, in addition to the original Game Boy handhelds and its Super and 36 | Color variants. 37 | . 38 | This package does not provide a GUI version of VBA-M. 39 | See the vbam-gtk package for the GTK+ version of this program. 40 | See the vbam-wx package for the wxWidgets version of this program. 41 | . 42 | Game Boy, Game Boy Color, Super Game Boy and Game Boy Advance are registered 43 | trademarks of Nintendo of America Inc. VBA-M is not affiliated with or endorsed 44 | by any of the companies mentioned. 45 | 46 | Package: vbam-wx 47 | Architecture: any 48 | Depends: ${shlibs:Depends}, ${misc:Depends} 49 | Description: Nintendo Game Boy Advance emulator (wxWidgets frontend) 50 | VisualBoyAdvance-M is a Nintendo Game Boy Emulator with high compatibility 51 | with commercial games. It emulates the Nintendo Game Boy Advance handheld 52 | console, in addition to the original Game Boy handhelds and its Super and 53 | Color variants. 54 | . 55 | This package provides the wxWidgets GUI version of VBA-M. 56 | . 57 | Game Boy, Game Boy Color, Super Game Boy and Game Boy Advance are registered 58 | trademarks of Nintendo of America Inc. VBA-M is not affiliated with or endorsed 59 | by any of the companies mentioned. 60 | -------------------------------------------------------------------------------- /src/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Copyright (C) 2014, 2015 Sergio Benjamim (sergio-br2) 4 | # Copyright (C) 2009 Fernando Tarlá Cardoso Lemos 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | # Uncomment this to turn on verbose mode 20 | #export DH_VERBOSE=1 21 | 22 | ifeq ($(DH_VERBOSE),1) 23 | EXTRA_CMAKE_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=ON 24 | endif 25 | 26 | #DEB_BUILD_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU) 27 | 28 | #ifneq (,$(filter $(DEB_BUILD_ARCH_CPU),i386 amd64)) 29 | #EXTRA_CMAKE_FLAGS += -DUSE_ASM_SCALERS=ON -DUSE_ASM_CORE=ON 30 | #endif 31 | 32 | CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=/usr \ 33 | -DENABLE_LIRC=ON -DENABLE_LINK=ON \ 34 | -DCMAKE_SKIP_RPATH=ON $(EXTRA_CMAKE_FLAGS) 35 | 36 | %: 37 | dh $@ --buildsystem=cmake --parallel 38 | 39 | override_dh_auto_configure: 40 | dh_auto_configure -- $(CMAKE_EXTRA_FLAGS) 41 | -------------------------------------------------------------------------------- /src/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /src/debian/vbam-gtk.docs: -------------------------------------------------------------------------------- 1 | doc/ReadMe.MFC.txt 2 | doc/DevInfo.txt 3 | doc/ips.htm 4 | -------------------------------------------------------------------------------- /src/debian/vbam-sdl.docs: -------------------------------------------------------------------------------- 1 | doc/ReadMe.MFC.txt 2 | doc/ReadMe.SDL.txt 3 | doc/DevInfo.txt 4 | doc/ips.htm 5 | -------------------------------------------------------------------------------- /src/debian/vbam-sdl.install: -------------------------------------------------------------------------------- 1 | etc 2 | usr/bin/vbam 3 | -------------------------------------------------------------------------------- /src/debian/vbam-sdl.manpages: -------------------------------------------------------------------------------- 1 | debian/vbam.1 2 | -------------------------------------------------------------------------------- /src/debian/vbam-wx.docs: -------------------------------------------------------------------------------- 1 | doc/ReadMe.MFC.txt 2 | doc/DevInfo.txt 3 | doc/ips.htm 4 | -------------------------------------------------------------------------------- /src/debian/vbam-wx.install: -------------------------------------------------------------------------------- 1 | usr/bin/visualboyadvance 2 | usr/share/icons 3 | usr/share/locale/*/*/wxvbam.* 4 | usr/share/applications/wxvbam.desktop 5 | -------------------------------------------------------------------------------- /src/debian/vbam-wx.manpages: -------------------------------------------------------------------------------- 1 | debian/wxvbam.1 2 | -------------------------------------------------------------------------------- /src/debian/vbam-wx.menu: -------------------------------------------------------------------------------- 1 | ?package(vbam-wx):needs="X11" section="Applications/Emulators" title="VisualBoyAdvance-M" command="/usr/bin/visualboyadvance-m" 2 | -------------------------------------------------------------------------------- /src/debian/visualboyadvance-m.6: -------------------------------------------------------------------------------- 1 | .TH visualboyadvance-m 6 "December 10, 2016" 2 | .SH NAME 3 | VisualBoyAdvance-M - A wxWidgets GUI for a high compatibility Gameboy Advance 4 | Emulator integrating the best features from various Visual Boy Advance builds. 5 | .SH SYNOPSIS 6 | .B visualboyadvance-m 7 | .RI [ options ] 8 | .SH DESCRIPTION 9 | .B VisualBoyAdvance-M 10 | is a Nintendo Game Boy Emulator with high compatibility with 11 | commercial games. 12 | .P 13 | It emulates the Nintendo Game Boy Advance hand held console, in 14 | addition to the original Game Boy hand held systems and its Super and Color 15 | variants. 16 | .P 17 | VBA-M is a continued development of the now inactive VisualBoy 18 | Advance project, with many improvements from various builds of VBA. 19 | .P 20 | This application is the wxWidgets GUI version of VisualBoyAdvance-M. 21 | .SH OPTIONS 22 | .TP 23 | .BI "\-h, \-\-help 24 | Show help message 25 | .TP 26 | .B \-\-verbose 27 | Generate verbose log messages 28 | .TP 29 | .B \-\-save-xrc= 30 | Save built-in XRC file and exit 31 | .TP 32 | .B \-\-save-over= 33 | Save built-in vba-over.ini and exit 34 | .TP 35 | .B \-\-print-cfg-path 36 | Print configuration path and exit 37 | .TP 38 | .B \-f, \-\-fullscreen 39 | Start in full-screen mode 40 | .TP 41 | .B \-s, \-\-delete-shared-state 42 | Delete shared link state first, if it exists 43 | .TP 44 | .B \-o, \-\-list-options 45 | List all settable options and exit 46 | .SH AUTHOR 47 | This manual page was written by Jeremy Newton (Mystro256). 48 | This man page is licensed as GPLv2 or later. 49 | -------------------------------------------------------------------------------- /src/filters/hq/asm/macros.mac: -------------------------------------------------------------------------------- 1 | %ifidn __OUTPUT_FORMAT__,elf 2 | section .note.GNU-stack noalloc noexec nowrite progbits 3 | %endif 4 | %ifidn __OUTPUT_FORMAT__,elf32 5 | section .note.GNU-stack noalloc noexec nowrite progbits 6 | %endif 7 | %ifidn __OUTPUT_FORMAT__,elf64 8 | section .note.GNU-stack noalloc noexec nowrite progbits 9 | %endif 10 | 11 | %ifdef __AMD64__ 12 | bits 64 13 | %else 14 | bits 32 15 | %endif 16 | 17 | %ifdef MACHO 18 | section .text align=16 19 | section .data align=4 20 | section .bss align=4 21 | %endif 22 | 23 | %ifdef ELF 24 | 25 | %imacro newsym 1 26 | GLOBAL %1 27 | %1: 28 | %endmacro 29 | %imacro newsym 2+ 30 | GLOBAL %1 31 | %1: %2 32 | %endmacro 33 | %define EXTSYM EXTERN 34 | 35 | section .note.GNU-stack noalloc noexec nowrite progbits 36 | 37 | %else 38 | 39 | %imacro newsym 1 40 | GLOBAL _%1 41 | _%1: 42 | %1: 43 | %endmacro 44 | %imacro newsym 2+ 45 | GLOBAL _%1 46 | _%1: 47 | %1: %2 48 | %endmacro 49 | %imacro EXTSYM 1-* 50 | %rep %0 51 | EXTERN _%1 52 | %define %1 _%1 53 | %rotate 1 54 | %endrep 55 | %endmacro 56 | %endif 57 | 58 | %macro ALIGN32 0 59 | times ($$-$) & 1Fh nop ; Long word alignment 60 | %endmacro 61 | %macro ALIGN16 0 62 | times ($$-$) & 1Fh nop ; Long word alignment 63 | %endmacro 64 | -------------------------------------------------------------------------------- /src/filters/hq/c/hq_implementation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | VisualBoyAdvance - a Game Boy & Game Boy Advance emulator 3 | 4 | Copyright (C) 2008 VBA-M development team 5 | 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | hq filter by Maxim Stepin ( http://hiend3d.com ) 22 | */ 23 | 24 | 25 | #include "hq_shared.h" 26 | 27 | 28 | #define _16BIT 29 | #define _HQ3X 30 | // hq3x, 16bit 31 | #include "hq_base.h" 32 | #undef _HQ3X 33 | 34 | #define _HQ4X 35 | // hq4x, 16bit 36 | #include "hq_base.h" 37 | #undef _HQ4X 38 | #undef _16BIT 39 | 40 | 41 | #define _32BIT 42 | #define _HQ3X 43 | // hq3x, 32bit 44 | #include "hq_base.h" 45 | #undef _HQ3X 46 | 47 | #define _HQ4X 48 | // hq4x, 32bit 49 | #include "hq_base.h" 50 | #undef _HQ4X 51 | #undef _32BIT 52 | 53 | 54 | 55 | #undef GMASK 56 | #undef RBMASK 57 | #undef GSHIFT1MASK 58 | #undef RBSHIFT1MASK 59 | #undef GSHIFT2MASK 60 | #undef RBSHIFT2MASK 61 | #undef GSHIFT3MASK 62 | #undef RBSHIFT3MASK 63 | #undef GSHIFT4MASK 64 | #undef RBSHIFT4MASK 65 | -------------------------------------------------------------------------------- /src/filters/interframe.hpp: -------------------------------------------------------------------------------- 1 | /// Interframe blending filters 2 | 3 | #ifndef INTERFRAME_HPP 4 | #define INTERFRAME_HPP 5 | 6 | extern int RGB_LOW_BITS_MASK; 7 | 8 | void InterframeFilterInit(); 9 | 10 | // call ifc to ignore previous frame / when starting new 11 | void InterframeCleanup(); 12 | 13 | // all 4 are MMX-accelerated if enabled 14 | void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 15 | void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 16 | void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 17 | void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 18 | 19 | #ifdef MMX 20 | static void SmartIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 21 | static void SmartIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 22 | static void MotionBlurIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 23 | static void MotionBlurIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); 24 | #endif 25 | 26 | //Options for if start is 0 27 | void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); 28 | void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); 29 | void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); 30 | void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); 31 | #endif //INTERFRAME_HPP 32 | -------------------------------------------------------------------------------- /src/filters/xBRZ/config.h: -------------------------------------------------------------------------------- 1 | // **************************************************************************** 2 | // * This file is part of the HqMAME project. It is distributed under * 3 | // * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * 4 | // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * 5 | // * * 6 | // * Additionally and as a special exception, the author gives permission * 7 | // * to link the code of this program with the MAME library (or with modified * 8 | // * versions of MAME that use the same license as MAME), and distribute * 9 | // * linked combinations including the two. You must obey the GNU General * 10 | // * Public License in all respects for all of the code used other than MAME. * 11 | // * If you modify this file, you may extend this exception to your version * 12 | // * of the file, but you are not obligated to do so. If you do not wish to * 13 | // * do so, delete this exception statement from your version. * 14 | // **************************************************************************** 15 | 16 | #ifndef XBRZ_CONFIG_HEADER_284578425345 17 | #define XBRZ_CONFIG_HEADER_284578425345 18 | 19 | // do NOT include any headers here! used by xBRZ_dll!!! 20 | 21 | namespace xbrz 22 | { 23 | struct ScalerCfg { 24 | ScalerCfg() 25 | : luminanceWeight(1), equalColorTolerance(30), dominantDirectionThreshold(3.6), 26 | steepDirectionThreshold(2.2), newTestAttribute(0) 27 | { 28 | } 29 | 30 | double luminanceWeight; 31 | double equalColorTolerance; 32 | double dominantDirectionThreshold; 33 | double steepDirectionThreshold; 34 | double newTestAttribute; // unused; test new parameters 35 | }; 36 | } 37 | 38 | #endif -------------------------------------------------------------------------------- /src/filters/xBRZ/xbrz.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/filters/xBRZ/xbrz.cpp -------------------------------------------------------------------------------- /src/filters/xbrzfilter.cpp: -------------------------------------------------------------------------------- 1 | #include "../System.h" 2 | 3 | #include "xBRZ/xbrz.h" 4 | 5 | void xbrz2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height) 6 | { 7 | xbrz::scale(2, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB); 8 | } 9 | 10 | void xbrz3x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height) 11 | { 12 | xbrz::scale(3, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB); 13 | } 14 | 15 | void xbrz4x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height) 16 | { 17 | xbrz::scale(4, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB); 18 | } 19 | 20 | void xbrz5x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height) 21 | { 22 | xbrz::scale(5, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB); 23 | } 24 | 25 | void xbrz6x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height) 26 | { 27 | xbrz::scale(6, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB); 28 | } 29 | -------------------------------------------------------------------------------- /src/gb/gb.h: -------------------------------------------------------------------------------- 1 | #ifndef GB_H 2 | #define GB_H 3 | 4 | #define gbWidth 160 5 | #define gbHeight 144 6 | #define sgbWidth 256 7 | #define sgbHeight 224 8 | 9 | const int GB_C_FLAG = 0x10; 10 | const int GB_H_FLAG = 0x20; 11 | const int GB_N_FLAG = 0x40; 12 | const int GB_Z_FLAG = 0x80; 13 | 14 | typedef union { 15 | struct { 16 | #ifdef WORDS_BIGENDIAN 17 | uint8_t B1, B0; 18 | #else 19 | uint8_t B0, B1; 20 | #endif 21 | } B; 22 | uint16_t W; 23 | } gbRegister; 24 | 25 | extern gbRegister AF, BC, DE, HL, SP, PC; 26 | extern uint16_t IFF; 27 | int gbDis(char*, uint16_t); 28 | 29 | bool gbLoadRom(const char*); 30 | bool gbUpdateSizes(); 31 | void gbEmulate(int); 32 | void gbWriteMemory(uint16_t, uint8_t); 33 | void gbDrawLine(); 34 | bool gbIsGameboyRom(const char*); 35 | void gbGetHardwareType(); 36 | void gbReset(); 37 | void gbCleanUp(); 38 | void gbCPUInit(const char*, bool); 39 | #ifdef __LIBRETRO__ 40 | unsigned int gbWriteSaveState(uint8_t*, unsigned); 41 | bool gbReadSaveState(const uint8_t*, unsigned); 42 | #else 43 | bool gbWriteSaveState(const char*); 44 | bool gbReadSaveState(const char*); 45 | #endif 46 | bool gbWriteBatteryFile(const char*); 47 | bool gbWriteBatteryFile(const char*, bool); 48 | bool gbReadBatteryFile(const char*); 49 | bool gbWriteMemSaveState(char*, int, long&); 50 | bool gbReadMemSaveState(char*, int); 51 | void gbSgbRenderBorder(); 52 | bool gbWritePNGFile(const char*); 53 | bool gbWriteBMPFile(const char*); 54 | bool gbReadGSASnapshot(const char*); 55 | 56 | bool gbLoadRomData(const char* data, unsigned size); 57 | 58 | // Allows invalid vram/palette access needed for Colorizer hacked games in GBC/GBA hardware 59 | void setColorizerHack(bool value); 60 | bool allowColorizerHack(void); 61 | 62 | extern int gbHardware; 63 | extern int gbRomType; // gets type from header 0x147 64 | extern int gbBattery; // enabled when gbRamSize != 0 65 | extern int gbRTCPresent; // gbROM has RTC support 66 | 67 | extern struct EmulatedSystem GBSystem; 68 | 69 | #endif // GB_H 70 | -------------------------------------------------------------------------------- /src/gb/gbCheats.h: -------------------------------------------------------------------------------- 1 | #ifndef GBCHEATS_H 2 | #define GBCHEATS_H 3 | 4 | #include "../System.h" 5 | #include "../common/ConfigManager.h" 6 | 7 | struct gbXxCheat { 8 | char cheatDesc[100]; 9 | char cheatCode[20]; 10 | }; 11 | 12 | struct gbCheat { 13 | char cheatCode[20]; 14 | char cheatDesc[32]; 15 | uint16_t address; 16 | int code; 17 | uint8_t compare; 18 | uint8_t value; 19 | bool enabled; 20 | }; 21 | 22 | #ifndef __LIBRETRO__ 23 | void gbCheatsSaveGame(gzFile); 24 | void gbCheatsReadGame(gzFile, int); 25 | void gbCheatsReadGameSkip(gzFile, int); 26 | #endif 27 | void gbCheatsSaveCheatList(const char*); 28 | bool gbCheatsLoadCheatList(const char*); 29 | bool gbCheatReadGSCodeFile(const char*); 30 | 31 | bool gbAddGsCheat(const char*, const char*); 32 | bool gbAddGgCheat(const char*, const char*); 33 | void gbCheatRemove(int); 34 | void gbCheatRemoveAll(); 35 | void gbCheatEnable(int); 36 | void gbCheatDisable(int); 37 | uint8_t gbCheatRead(uint16_t); 38 | void gbCheatWrite(bool); 39 | bool gbVerifyGsCode(const char* code); 40 | bool gbVerifyGgCode(const char* code); 41 | 42 | extern int gbCheatNumber; 43 | extern gbCheat gbCheatList[MAX_CHEATS]; 44 | extern bool gbCheatMap[0x10000]; 45 | 46 | #endif // GBCHEATS_H 47 | -------------------------------------------------------------------------------- /src/gb/gbGlobals.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../common/Types.h" 3 | 4 | uint8_t* gbMemoryMap[16]; 5 | 6 | int gbRomSizeMask = 0; 7 | int gbRomSize = 0; 8 | int gbRamSizeMask = 0; 9 | int gbRamSize = 0; 10 | int gbTAMA5ramSize = 0; 11 | 12 | uint8_t* gbMemory = NULL; 13 | uint8_t* gbVram = NULL; 14 | uint8_t* gbRom = NULL; 15 | uint8_t* gbRam = NULL; 16 | uint8_t* gbWram = NULL; 17 | uint16_t* gbLineBuffer = NULL; 18 | uint8_t* gbTAMA5ram = NULL; 19 | 20 | uint16_t gbPalette[128]; 21 | uint8_t gbBgp[4] = { 0, 1, 2, 3 }; 22 | uint8_t gbObp0[4] = { 0, 1, 2, 3 }; 23 | uint8_t gbObp1[4] = { 0, 1, 2, 3 }; 24 | int gbWindowLine = -1; 25 | 26 | bool genericflashcardEnable = false; 27 | int gbCgbMode = 0; 28 | 29 | uint16_t gbColorFilter[32768]; 30 | int gbColorOption = 0; 31 | int gbPaletteOption = 0; 32 | int gbEmulatorType = 0; 33 | int gbBorderOn = 0; 34 | int gbBorderAutomatic = 0; 35 | int gbBorderLineSkip = 160; 36 | int gbBorderRowSkip = 0; 37 | int gbBorderColumnSkip = 0; 38 | int gbDmaTicks = 0; 39 | 40 | uint8_t (*gbSerialFunction)(uint8_t) = NULL; 41 | -------------------------------------------------------------------------------- /src/gb/gbGlobals.h: -------------------------------------------------------------------------------- 1 | #ifndef GBGLOBALS_H 2 | #define GBGLOBALS_H 3 | 4 | #include "../common/Types.h" 5 | 6 | extern int gbRomSizeMask; 7 | extern int gbRomSize; 8 | extern int gbRamSize; 9 | extern int gbRamSizeMask; 10 | extern int gbTAMA5ramSize; 11 | 12 | extern uint8_t* bios; 13 | 14 | extern uint8_t* gbRom; 15 | extern uint8_t* gbRam; 16 | extern uint8_t* gbVram; 17 | extern uint8_t* gbWram; 18 | extern uint8_t* gbMemory; 19 | extern uint16_t* gbLineBuffer; 20 | extern uint8_t* gbTAMA5ram; 21 | 22 | extern uint8_t* gbMemoryMap[16]; 23 | 24 | extern int gbFrameSkip; 25 | extern uint16_t gbColorFilter[32768]; 26 | extern int gbColorOption; 27 | extern int gbPaletteOption; 28 | extern int gbEmulatorType; 29 | extern int gbBorderOn; 30 | extern int gbBorderAutomatic; 31 | extern int gbCgbMode; 32 | extern int gbSgbMode; 33 | extern int gbWindowLine; 34 | extern int gbSpeed; 35 | extern uint8_t gbBgp[4]; 36 | extern uint8_t gbObp0[4]; 37 | extern uint8_t gbObp1[4]; 38 | extern uint16_t gbPalette[128]; 39 | extern bool gbScreenOn; 40 | extern bool gbDrawWindow; 41 | extern uint8_t gbSCYLine[300]; 42 | // gbSCXLine is used for the emulation (bug) of the SX change 43 | // found in the Artic Zone game. 44 | extern uint8_t gbSCXLine[300]; 45 | // gbBgpLine is used for the emulation of the 46 | // Prehistorik Man's title screen scroller. 47 | extern uint8_t gbBgpLine[300]; 48 | extern uint8_t gbObp0Line[300]; 49 | extern uint8_t gbObp1Line[300]; 50 | // gbSpritesTicks is used for the emulation of Parodius' Laser Beam. 51 | extern uint8_t gbSpritesTicks[300]; 52 | 53 | extern uint8_t register_LCDC; 54 | extern uint8_t register_LY; 55 | extern uint8_t register_SCY; 56 | extern uint8_t register_SCX; 57 | extern uint8_t register_WY; 58 | extern uint8_t register_WX; 59 | extern uint8_t register_VBK; 60 | extern uint8_t oldRegister_WY; 61 | 62 | extern int emulating; 63 | extern bool genericflashcardEnable; 64 | 65 | extern int gbBorderLineSkip; 66 | extern int gbBorderRowSkip; 67 | extern int gbBorderColumnSkip; 68 | extern int gbDmaTicks; 69 | 70 | extern void gbRenderLine(); 71 | extern void gbDrawSprites(bool); 72 | 73 | extern uint8_t (*gbSerialFunction)(uint8_t); 74 | 75 | #endif // GBGLOBALS_H 76 | -------------------------------------------------------------------------------- /src/gb/gbPrinter.h: -------------------------------------------------------------------------------- 1 | #ifndef GBPRINTER_H 2 | #define GBPRINTER_H 3 | 4 | #include "../System.h" 5 | 6 | uint8_t gbPrinterSend(uint8_t b); 7 | 8 | #endif // GBPRINTER_H 9 | -------------------------------------------------------------------------------- /src/gb/gbSGB.h: -------------------------------------------------------------------------------- 1 | #ifndef GBSGB_H 2 | #define GBSGB_H 3 | 4 | void gbSgbInit(); 5 | void gbSgbShutdown(); 6 | void gbSgbCommand(); 7 | void gbSgbResetPacketState(); 8 | void gbSgbReset(); 9 | void gbSgbDoBitTransfer(uint8_t); 10 | void gbSgbRenderBorder(); 11 | #ifdef __LIBRETRO__ 12 | void gbSgbSaveGame(uint8_t*&); 13 | void gbSgbReadGame(const uint8_t*&); 14 | #else 15 | void gbSgbSaveGame(gzFile); 16 | void gbSgbReadGame(gzFile, int version); 17 | #endif 18 | 19 | extern uint8_t gbSgbATF[20 * 18]; 20 | extern int gbSgbMode; 21 | extern int gbSgbMask; 22 | extern int gbSgbMultiplayer; 23 | extern uint8_t gbSgbNextController; 24 | extern int gbSgbPacketTimeout; 25 | extern uint8_t gbSgbReadingController; 26 | extern int gbSgbFourPlayers; 27 | 28 | #endif // GBSGB_H 29 | -------------------------------------------------------------------------------- /src/gb/gbSound.h: -------------------------------------------------------------------------------- 1 | #ifndef GBSOUND_H 2 | #define GBSOUND_H 3 | 4 | // GB sound emulation 5 | 6 | // See Sound.h for sound setup/options 7 | 8 | //// GB sound options 9 | 10 | void gbSoundSetSampleRate(long sampleRate); 11 | 12 | // Manages declicking mode. When enabled, clicks are reduced. Note that clicks 13 | // are normal for GB and GBC sound hardware. 14 | void gbSoundSetDeclicking(bool enable); 15 | bool gbSoundGetDeclicking(); 16 | 17 | // Effects configuration 18 | struct gb_effects_config_t { 19 | bool enabled; // false = disable all effects 20 | 21 | float echo; // 0.0 = none, 1.0 = lots 22 | float stereo; // 0.0 = channels in center, 1.0 = channels on left/right 23 | bool surround; // true = put some channels in back 24 | }; 25 | 26 | // Changes effects configuration 27 | void gbSoundConfigEffects(gb_effects_config_t const&); 28 | extern gb_effects_config_t gb_effects_config; // current configuration 29 | 30 | //// GB sound emulation 31 | 32 | // GB sound registers 33 | #define NR10 0xff10 34 | #define NR11 0xff11 35 | #define NR12 0xff12 36 | #define NR13 0xff13 37 | #define NR14 0xff14 38 | #define NR21 0xff16 39 | #define NR22 0xff17 40 | #define NR23 0xff18 41 | #define NR24 0xff19 42 | #define NR30 0xff1a 43 | #define NR31 0xff1b 44 | #define NR32 0xff1c 45 | #define NR33 0xff1d 46 | #define NR34 0xff1e 47 | #define NR41 0xff20 48 | #define NR42 0xff21 49 | #define NR43 0xff22 50 | #define NR44 0xff23 51 | #define NR50 0xff24 52 | #define NR51 0xff25 53 | #define NR52 0xff26 54 | 55 | // Resets emulated sound hardware 56 | void gbSoundReset(); 57 | 58 | // Emulates write to sound hardware 59 | void gbSoundEvent(int st, uint16_t address, int data); 60 | #define SOUND_EVENT gbSoundEvent 61 | 62 | // Emulates read from sound hardware 63 | uint8_t gbSoundRead(int st, uint16_t address); 64 | 65 | // Notifies emulator that SOUND_CLOCK_TICKS clocks have passed 66 | void gbSoundTick(int st); 67 | extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to gbSoundTick() 68 | extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick() will be called 69 | 70 | // Saves/loads emulator state 71 | #ifdef __LIBRETRO__ 72 | void gbSoundSaveGame(uint8_t*&); 73 | void gbSoundReadGame(const uint8_t*&); 74 | #else 75 | void gbSoundSaveGame(gzFile out); 76 | void gbSoundReadGame(int version, gzFile in); 77 | #endif 78 | 79 | #endif // GBSOUND_H 80 | -------------------------------------------------------------------------------- /src/gba/CheatSearch.h: -------------------------------------------------------------------------------- 1 | #ifndef CHEATSEARCH_H 2 | #define CHEATSEARCH_H 3 | 4 | #include "../System.h" 5 | 6 | struct CheatSearchBlock { 7 | int size; 8 | uint32_t offset; 9 | uint8_t* bits; 10 | uint8_t* data; 11 | uint8_t* saved; 12 | }; 13 | 14 | struct CheatSearchData { 15 | int count; 16 | CheatSearchBlock* blocks; 17 | }; 18 | 19 | enum { SEARCH_EQ, 20 | SEARCH_NE, 21 | SEARCH_LT, 22 | SEARCH_LE, 23 | SEARCH_GT, 24 | SEARCH_GE }; 25 | 26 | enum { BITS_8, 27 | BITS_16, 28 | BITS_32 }; 29 | 30 | #define SET_BIT(bits, off) (bits)[(off) >> 3] |= (1 << ((off)&7)) 31 | 32 | #define CLEAR_BIT(bits, off) (bits)[(off) >> 3] &= ~(1 << ((off)&7)) 33 | 34 | #define IS_BIT_SET(bits, off) (bits)[(off) >> 3] & (1 << ((off)&7)) 35 | 36 | extern CheatSearchData cheatSearchData; 37 | 38 | void cheatSearchCleanup(CheatSearchData* cs); 39 | void cheatSearchStart(const CheatSearchData* cs); 40 | void cheatSearch(const CheatSearchData* cs, int compare, int size, bool isSigned); 41 | void cheatSearchValue(const CheatSearchData* cs, int compare, int size, bool isSigned, uint32_t value); 42 | int cheatSearchGetCount(const CheatSearchData* cs, int size); 43 | void cheatSearchUpdateValues(const CheatSearchData* cs); 44 | int32_t cheatSearchSignedRead(uint8_t* data, int off, int size); 45 | uint32_t cheatSearchRead(uint8_t* data, int off, int size); 46 | 47 | #endif // CHEATSEARCH_H 48 | -------------------------------------------------------------------------------- /src/gba/Cheats.h: -------------------------------------------------------------------------------- 1 | #ifndef CHEATS_H 2 | #define CHEATS_H 3 | 4 | #include "../common/ConfigManager.h" 5 | 6 | struct CheatsData { 7 | int code; 8 | int size; 9 | int status; 10 | bool enabled; 11 | uint32_t rawaddress; 12 | uint32_t address; 13 | uint32_t value; 14 | uint32_t oldValue; 15 | char codestring[20]; 16 | char desc[32]; 17 | }; 18 | 19 | void cheatsAdd(const char* codeStr, const char* desc, uint32_t rawaddress, uint32_t address, uint32_t value, 20 | int code, int size); 21 | void cheatsAddCheatCode(const char* code, const char* desc); 22 | void cheatsAddGSACode(const char* code, const char* desc, bool v3); 23 | void cheatsAddCBACode(const char* code, const char* desc); 24 | bool cheatsImportGSACodeFile(const char* name, int game, bool v3); 25 | void cheatsDelete(int number, bool restore); 26 | void cheatsDeleteAll(bool restore); 27 | void cheatsEnable(int number); 28 | void cheatsDisable(int number); 29 | #ifndef __LIBRETRO__ 30 | void cheatsSaveGame(gzFile file); 31 | void cheatsReadGame(gzFile file, int version); 32 | void cheatsReadGameSkip(gzFile file, int version); 33 | void cheatsSaveCheatList(const char* file); 34 | bool cheatsLoadCheatList(const char* file); 35 | #endif 36 | #ifdef BKPT_SUPPORT 37 | void cheatsWriteMemory(uint32_t address, uint32_t value); 38 | void cheatsWriteHalfWord(uint32_t address, uint16_t value); 39 | void cheatsWriteByte(uint32_t address, uint8_t value); 40 | #endif 41 | int cheatsCheckKeys(uint32_t keys, uint32_t extended); 42 | 43 | extern int cheatsNumber; 44 | extern CheatsData cheatsList[MAX_CHEATS]; 45 | 46 | #endif // CHEATS_H 47 | -------------------------------------------------------------------------------- /src/gba/EEprom.h: -------------------------------------------------------------------------------- 1 | #ifndef EEPROM_H 2 | #define EEPROM_H 3 | 4 | #include "../common/Types.h" 5 | 6 | #ifdef __LIBRETRO__ 7 | extern void eepromSaveGame(uint8_t*& data); 8 | extern void eepromReadGame(const uint8_t*& data); 9 | #else // !__LIBRETRO__ 10 | extern void eepromSaveGame(gzFile _gzFile); 11 | extern void eepromReadGame(gzFile _gzFile, int version); 12 | extern void eepromReadGameSkip(gzFile _gzFile, int version); 13 | #endif 14 | extern uint8_t eepromData[0x2000]; 15 | extern int eepromRead(uint32_t address); 16 | extern void eepromWrite(uint32_t address, uint8_t value); 17 | extern void eepromInit(); 18 | extern void eepromReset(); 19 | extern bool eepromInUse; 20 | extern int eepromSize; 21 | 22 | #define EEPROM_IDLE 0 23 | #define EEPROM_READADDRESS 1 24 | #define EEPROM_READDATA 2 25 | #define EEPROM_READDATA2 3 26 | #define EEPROM_WRITEDATA 4 27 | 28 | #endif // EEPROM_H 29 | -------------------------------------------------------------------------------- /src/gba/Flash.h: -------------------------------------------------------------------------------- 1 | #ifndef FLASH_H 2 | #define FLASH_H 3 | 4 | #include "../common/Types.h" 5 | 6 | #define FLASH_128K_SZ 0x20000 7 | 8 | #ifdef __LIBRETRO__ 9 | extern void flashSaveGame(uint8_t*& data); 10 | extern void flashReadGame(const uint8_t*& data); 11 | #else 12 | extern void flashSaveGame(gzFile _gzFile); 13 | extern void flashReadGame(gzFile _gzFile, int version); 14 | extern void flashReadGameSkip(gzFile _gzFile, int version); 15 | #endif 16 | extern uint8_t flashSaveMemory[FLASH_128K_SZ]; 17 | extern uint8_t flashRead(uint32_t address); 18 | extern void flashWrite(uint32_t address, uint8_t byte); 19 | extern void flashDelayedWrite(uint32_t address, uint8_t byte); 20 | extern void flashSaveDecide(uint32_t address, uint8_t byte); 21 | extern void flashReset(); 22 | extern void flashSetSize(int size); 23 | extern void flashInit(); 24 | 25 | extern int flashSize; 26 | 27 | #endif // FLASH_H 28 | -------------------------------------------------------------------------------- /src/gba/GBASockClient.cpp: -------------------------------------------------------------------------------- 1 | #ifndef NO_LINK 2 | 3 | #include "GBASockClient.h" 4 | 5 | // Currently only for Joybus communications 6 | 7 | GBASockClient::GBASockClient(sf::IpAddress _server_addr) 8 | { 9 | if (_server_addr == sf::IpAddress::None) 10 | server_addr = sf::IpAddress::getPublicAddress(); 11 | else 12 | server_addr = _server_addr; 13 | 14 | client.connect(server_addr, 0xd6ba); 15 | client.setBlocking(false); 16 | 17 | clock_client.connect(server_addr, 0xc10c); 18 | clock_client.setBlocking(false); 19 | 20 | clock_sync = 0; 21 | is_disconnected = false; 22 | } 23 | 24 | GBASockClient::~GBASockClient() 25 | { 26 | client.disconnect(); 27 | clock_client.disconnect(); 28 | } 29 | 30 | uint32_t clock_sync_ticks = 0; 31 | 32 | void GBASockClient::Send(std::vector data) 33 | { 34 | char* plain_data = new char[data.size()]; 35 | std::copy(data.begin(), data.end(), plain_data); 36 | 37 | client.send(plain_data, data.size()); 38 | 39 | delete[] plain_data; 40 | } 41 | 42 | // Returns cmd for convenience 43 | char GBASockClient::ReceiveCmd(char* data_in, bool block) 44 | { 45 | if (IsDisconnected()) 46 | return data_in[0]; 47 | 48 | std::size_t num_received = 0; 49 | if (block || clock_sync == 0) { 50 | sf::SocketSelector Selector; 51 | Selector.add(client); 52 | Selector.wait(sf::seconds(6)); 53 | } 54 | if (client.receive(data_in, 5, num_received) == sf::Socket::Disconnected) 55 | Disconnect(); 56 | 57 | return data_in[0]; 58 | } 59 | 60 | void GBASockClient::ReceiveClock(bool block) 61 | { 62 | (void)block; // unused param 63 | if (IsDisconnected()) 64 | return; 65 | 66 | char sync_ticks[4] = { 0, 0, 0, 0 }; 67 | std::size_t num_received = 0; 68 | if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected) 69 | Disconnect(); 70 | 71 | if (num_received == 4) { 72 | clock_sync_ticks = 0; 73 | for (int i = 0; i < 4; i++) 74 | clock_sync_ticks |= (uint8_t)(sync_ticks[i]) << ((3 - i) * 8); 75 | clock_sync += clock_sync_ticks; 76 | } 77 | } 78 | 79 | void GBASockClient::ClockSync(uint32_t ticks) 80 | { 81 | if (clock_sync > (int32_t)ticks) 82 | clock_sync -= (int32_t)ticks; 83 | else 84 | clock_sync = 0; 85 | } 86 | 87 | void GBASockClient::Disconnect() 88 | { 89 | is_disconnected = true; 90 | client.disconnect(); 91 | clock_client.disconnect(); 92 | } 93 | 94 | bool GBASockClient::IsDisconnected() 95 | { 96 | return is_disconnected; 97 | } 98 | #endif // NO_LINK 99 | -------------------------------------------------------------------------------- /src/gba/GBASockClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common/Types.h" 4 | 5 | #include 6 | 7 | class GBASockClient { 8 | public: 9 | GBASockClient(sf::IpAddress _server_addr); 10 | ~GBASockClient(); 11 | 12 | bool Connect(sf::IpAddress server_addr); 13 | void Send(std::vector data); 14 | char ReceiveCmd(char* data_in, bool block); 15 | void ReceiveClock(bool block); 16 | 17 | void ClockSync(uint32_t ticks); 18 | void Disconnect(); 19 | bool IsDisconnected(); 20 | 21 | private: 22 | sf::IpAddress server_addr; 23 | sf::TcpSocket client; 24 | sf::TcpSocket clock_client; 25 | 26 | int32_t clock_sync; 27 | bool is_disconnected; 28 | }; 29 | -------------------------------------------------------------------------------- /src/gba/RTC.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_H 2 | #define RTC_H 3 | 4 | uint16_t rtcRead(uint32_t address); 5 | void rtcUpdateTime(int ticks); 6 | bool rtcWrite(uint32_t address, uint16_t value); 7 | void rtcEnable(bool); 8 | void rtcEnableRumble(bool e); 9 | bool rtcIsEnabled(); 10 | void rtcReset(); 11 | 12 | #ifdef __LIBRETRO__ 13 | void rtcReadGame(const uint8_t*& data); 14 | void rtcSaveGame(uint8_t*& data); 15 | #else 16 | void rtcReadGame(gzFile gzFile); 17 | void rtcSaveGame(gzFile gzFile); 18 | #endif 19 | 20 | #endif // RTC_H 21 | -------------------------------------------------------------------------------- /src/gba/Sound.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUND_H 2 | #define SOUND_H 3 | 4 | // Sound emulation setup/options and GBA sound emulation 5 | 6 | #include "../System.h" 7 | 8 | //// Setup/options (these affect GBA and GB sound) 9 | 10 | // Initializes sound and returns true if successful. Sets sound quality to 11 | // current value in soundQuality global. 12 | bool soundInit(); 13 | 14 | // sets the Sound throttle 15 | void soundSetThrottle(unsigned short throttle); 16 | 17 | // Manages sound volume, where 1.0 is normal 18 | void soundSetVolume(float); 19 | float soundGetVolume(); 20 | 21 | // Manages muting bitmask. The bits control the following channels: 22 | // 0x001 Pulse 1 23 | // 0x002 Pulse 2 24 | // 0x004 Wave 25 | // 0x008 Noise 26 | // 0x100 PCM 1 27 | // 0x200 PCM 2 28 | void soundSetEnable(int mask); 29 | int soundGetEnable(); 30 | 31 | // Pauses/resumes system sound output 32 | void soundPause(); 33 | void soundResume(); 34 | extern bool soundPaused; // current paused state 35 | 36 | // Cleans up sound. Afterwards, soundInit() can be called again. 37 | void soundShutdown(); 38 | 39 | //// GBA sound options 40 | 41 | long soundGetSampleRate(); 42 | void soundSetSampleRate(long sampleRate); 43 | 44 | // Sound settings 45 | extern bool soundInterpolation; // 1 if PCM should have low-pass filtering 46 | extern float soundFiltering; // 0.0 = none, 1.0 = max 47 | 48 | //// GBA sound emulation 49 | 50 | // GBA sound registers 51 | #define SGCNT0_H 0x82 52 | #define SOUNDBIAS 0x88 53 | #define FIFOA_L 0xa0 54 | #define FIFOA_H 0xa2 55 | #define FIFOB_L 0xa4 56 | #define FIFOB_H 0xa6 57 | 58 | // Resets emulated sound hardware 59 | void soundReset(); 60 | 61 | // Emulates write to sound hardware 62 | void soundEvent8(uint32_t addr, uint8_t data); 63 | void soundEvent16(uint32_t addr, uint16_t data); // TODO: error-prone to overload like this 64 | 65 | // Notifies emulator that a timer has overflowed 66 | void soundTimerOverflow(int which); 67 | 68 | // Notifies emulator that PCM rate may have changed 69 | void interp_rate(); 70 | 71 | // Notifies emulator that SOUND_CLOCK_TICKS clocks have passed 72 | void psoundTickfn(); 73 | extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to soundTick() 74 | 75 | // 2018-12-10 - counts up from 0 since last psoundTickfn() was called 76 | extern int soundTicks; 77 | 78 | // Saves/loads emulator state 79 | #ifdef __LIBRETRO__ 80 | void soundSaveGame(uint8_t*&); 81 | void soundReadGame(const uint8_t*& in); 82 | #else 83 | void soundSaveGame(gzFile); 84 | void soundReadGame(gzFile, int version); 85 | #endif 86 | 87 | class Multi_Buffer; 88 | 89 | void flush_samples(Multi_Buffer* buffer); 90 | 91 | #endif // SOUND_H 92 | -------------------------------------------------------------------------------- /src/gba/Sram.cpp: -------------------------------------------------------------------------------- 1 | #include "Sram.h" 2 | #include "Flash.h" 3 | #include "GBA.h" 4 | #include "Globals.h" 5 | 6 | uint8_t sramRead(uint32_t address) 7 | { 8 | return flashSaveMemory[address & 0xFFFF]; 9 | } 10 | void sramDelayedWrite(uint32_t address, uint8_t byte) 11 | { 12 | saveType = GBA_SAVE_SRAM; 13 | cpuSaveGameFunc = sramWrite; 14 | sramWrite(address, byte); 15 | } 16 | 17 | void sramWrite(uint32_t address, uint8_t byte) 18 | { 19 | flashSaveMemory[address & 0xFFFF] = byte; 20 | systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; 21 | } 22 | -------------------------------------------------------------------------------- /src/gba/Sram.h: -------------------------------------------------------------------------------- 1 | #ifndef SRAM_H 2 | #define SRAM_H 3 | 4 | #include "../common/Types.h" 5 | 6 | uint8_t sramRead(uint32_t address); 7 | void sramWrite(uint32_t address, uint8_t byte); 8 | void sramDelayedWrite(uint32_t address, uint8_t byte); 9 | 10 | #endif // SRAM_H 11 | -------------------------------------------------------------------------------- /src/gba/agbprint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../System.h" 5 | #include "../common/Port.h" 6 | #include "GBA.h" 7 | #include "Globals.h" 8 | 9 | #define debuggerWriteHalfWord(addr, value) \ 10 | WRITE16LE((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value)) 11 | 12 | #define debuggerReadHalfWord(addr) \ 13 | READ16LE(((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])) 14 | 15 | static bool agbPrintEnabled = false; 16 | static bool agbPrintProtect = false; 17 | 18 | bool agbPrintWrite(uint32_t address, uint16_t value) 19 | { 20 | if (agbPrintEnabled) { 21 | if (address == 0x9fe2ffe) { // protect 22 | agbPrintProtect = (value != 0); 23 | debuggerWriteHalfWord(address, value); 24 | return true; 25 | } else { 26 | if (agbPrintProtect && ((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure 27 | || (address >= 0x8fd0000 && address <= 0x8fdffff) 28 | || (address >= 0x9fd0000 && address <= 0x9fdffff))) { 29 | debuggerWriteHalfWord(address, value); 30 | return true; 31 | } 32 | } 33 | } 34 | return false; 35 | } 36 | 37 | void agbPrintReset() 38 | { 39 | agbPrintProtect = false; 40 | } 41 | 42 | void agbPrintEnable(bool enable) 43 | { 44 | agbPrintEnabled = enable; 45 | } 46 | 47 | bool agbPrintIsEnabled() 48 | { 49 | return agbPrintEnabled; 50 | } 51 | 52 | void agbPrintFlush() 53 | { 54 | uint16_t get = debuggerReadHalfWord(0x9fe20fc); 55 | uint16_t put = debuggerReadHalfWord(0x9fe20fe); 56 | 57 | uint32_t address = (debuggerReadHalfWord(0x9fe20fa) << 16); 58 | if (address != 0xfd0000 && address != 0x1fd0000) { 59 | #ifdef BKPT_SUPPORT 60 | dbgOutput("Did you forget to call AGBPrintInit?\n", 0); 61 | #endif 62 | // get rid of the text otherwise we will continue to be called 63 | debuggerWriteHalfWord(0x9fe20fc, put); 64 | return; 65 | } 66 | 67 | uint8_t* data = &rom[address]; 68 | 69 | while (get != put) { 70 | char c = data[get++]; 71 | #ifdef BKPT_SUPPORT 72 | char s[2]; 73 | s[0] = c; 74 | s[1] = 0; 75 | if (systemVerbose & VERBOSE_AGBPRINT) 76 | dbgOutput(s, 0); 77 | #endif 78 | if (c == '\n') 79 | break; 80 | } 81 | debuggerWriteHalfWord(0x9fe20fc, get); 82 | } 83 | -------------------------------------------------------------------------------- /src/gba/agbprint.h: -------------------------------------------------------------------------------- 1 | #ifndef AGBPRINT_H 2 | #define AGBPRINT_H 3 | 4 | void agbPrintEnable(bool enable); 5 | bool agbPrintIsEnabled(); 6 | void agbPrintReset(); 7 | bool agbPrintWrite(uint32_t address, uint16_t value); 8 | void agbPrintFlush(); 9 | 10 | #endif // AGBPRINT_H 11 | -------------------------------------------------------------------------------- /src/gba/armdis.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* Arm/Thumb command set disassembler */ 3 | /************************************************************************/ 4 | 5 | #ifndef __ARMDIS_H__ 6 | #define __ARMDIS_H__ 7 | 8 | #define DIS_VIEW_ADDRESS 1 9 | #define DIS_VIEW_CODE 2 10 | 11 | int disThumb(uint32_t offset, char* dest, unsigned dest_sz, int flags); 12 | int disArm(uint32_t offset, char* dest, unsigned dest_sz, int flags); 13 | 14 | #endif // __ARMDIS_H__ 15 | -------------------------------------------------------------------------------- /src/gba/bios.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_H 2 | #define BIOS_H 3 | 4 | extern void BIOS_ArcTan(); 5 | extern void BIOS_ArcTan2(); 6 | extern void BIOS_BitUnPack(); 7 | extern void BIOS_GetBiosChecksum(); 8 | extern void BIOS_BgAffineSet(); 9 | extern void BIOS_CpuSet(); 10 | extern void BIOS_CpuFastSet(); 11 | extern void BIOS_Diff8bitUnFilterWram(); 12 | extern void BIOS_Diff8bitUnFilterVram(); 13 | extern void BIOS_Diff16bitUnFilter(); 14 | extern void BIOS_Div(); 15 | extern void BIOS_DivARM(); 16 | extern void BIOS_HuffUnComp(); 17 | extern void BIOS_LZ77UnCompVram(); 18 | extern void BIOS_LZ77UnCompWram(); 19 | extern void BIOS_ObjAffineSet(); 20 | extern void BIOS_RegisterRamReset(); 21 | extern void BIOS_RegisterRamReset(uint32_t); 22 | extern void BIOS_RLUnCompVram(); 23 | extern void BIOS_RLUnCompWram(); 24 | extern void BIOS_SoftReset(); 25 | extern void BIOS_Sqrt(); 26 | extern void BIOS_MidiKey2Freq(); 27 | extern void BIOS_SndDriverJmpTableCopy(); 28 | extern void BIOS_SndDriverInit(); 29 | extern void BIOS_SndDriverMode(); 30 | extern void BIOS_SndDriverMain(); 31 | extern void BIOS_SndDriverVSync(); 32 | extern void BIOS_SndDriverVSyncOff(); 33 | extern void BIOS_SndChannelClear(); 34 | 35 | #endif // BIOS_H 36 | -------------------------------------------------------------------------------- /src/gba/debugger-expr-lex.c: -------------------------------------------------------------------------------- 1 | #include "debugger-expr-lex.cpp" -------------------------------------------------------------------------------- /src/gba/debugger-expr.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include 4 | #include "debugger-expr-yacc.hpp" 5 | 6 | #ifdef _MSC_VER 7 | #define YY_NO_UNISTD_H 8 | #include 9 | #define isatty _isatty 10 | #endif 11 | 12 | extern YYSTYPE dexp_lval; 13 | 14 | char *dexprString; 15 | int dexprCol; 16 | 17 | #define YY_INPUT(buf,result,max_size) \ 18 | { \ 19 | int c = *dexprString++; \ 20 | dexprCol++;\ 21 | result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ 22 | } 23 | 24 | %} 25 | 26 | %option nomain 27 | %option noyywrap 28 | 29 | HEX [0-9a-fA-F] 30 | 31 | %% 32 | r(0?[0-9]|1[0-5]) dexp_lval.number=atoi((char *)(dexp_text+1)); return TOK_REGISTER; 33 | [sS][pP] dexp_lval.number = 13; return TOK_REGISTER; 34 | [lL][rR] dexp_lval.number = 14; return TOK_REGISTER; 35 | [pP][cC] dexp_lval.number = 15; return TOK_REGISTER; 36 | [bB]"[" return TOK_BBRACKET; 37 | [hH]"[" return TOK_HBRACKET; 38 | [wW]"[" return TOK_WBRACKET; 39 | "]" return TOK_RBRACKET; 40 | "[" return TOK_LBRACKET; 41 | [1-9][0-9]* dexp_lval.number=atoi(dexp_text); return TOK_NUMBER; 42 | 0{HEX}* sscanf(dexp_text, "%x", &dexp_lval.number); return TOK_NUMBER; 43 | 0[xX]{HEX}+ sscanf((char *)(dexp_text + 2), "%x", &dexp_lval.number); return TOK_NUMBER; 44 | "$"{HEX}+ sscanf((char *)(dexp_text + 1), "%x", &dexp_lval.number); return TOK_NUMBER; 45 | "+" return TOK_PLUS; 46 | "-" return TOK_MINUS; 47 | "/" return TOK_DIVIDE; 48 | "*" return TOK_MULTIPLY; 49 | "<<" return TOK_LSHIFT; 50 | ">>" return TOK_RSHIFT; 51 | "(" return TOK_LPAREN; 52 | ")" return TOK_RPAREN; 53 | "|" return TOK_OR; 54 | "&" return TOK_AND; 55 | "^" return TOK_XOR; 56 | "!" return TOK_NEGATE; 57 | "~" return TOK_NEGATE; 58 | " " ; 59 | . printf("Unrecognised token: %s\n", dexp_text); 60 | [A-Za-z_][A-Za-z0-9_]* dexp_lval.string=dexp_text; return TOK_ID; 61 | 62 | %% 63 | 64 | void dexp_flush() 65 | { 66 | dexp__flush_buffer(YY_CURRENT_BUFFER); 67 | } 68 | -------------------------------------------------------------------------------- /src/gba/ereader.h: -------------------------------------------------------------------------------- 1 | extern unsigned char* DotCodeData; 2 | extern char filebuffer[]; 3 | 4 | int OpenDotCodeFile(void); 5 | int CheckEReaderRegion(void); 6 | int LoadDotCodeData(int size, uint32_t* DCdata, unsigned long MEM1, unsigned long MEM2); 7 | void EReaderWriteMemory(uint32_t address, uint32_t value); 8 | 9 | void BIOS_EReader_ScanCard(int swi_num); 10 | -------------------------------------------------------------------------------- /src/gba/gbafilter.h: -------------------------------------------------------------------------------- 1 | #include "../System.h" 2 | 3 | void gbafilter_pal(uint16_t* buf, int count); 4 | void gbafilter_pal32(uint32_t* buf, int count); 5 | void gbafilter_pad(uint8_t* buf, int count); 6 | -------------------------------------------------------------------------------- /src/gba/remote.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOTE_H 2 | #define REMOTE_H 3 | 4 | #include "GBA.h" 5 | 6 | #define BitSet(array, bit) ((uint8_t*)(array))[(bit) >> 3] |= (1 << ((bit)&7)) 7 | 8 | #define BitClear(array, bit) ((uint8_t*)(array))[(bit) >> 3] &= ~(1 << ((bit)&7)) 9 | 10 | #define BitGet(array, bit) ((uint8_t)((array)[(bit) >> 3]) & (uint8_t)(1 << ((bit)&7))) 11 | 12 | #define BreakSet(array, addr, flag) \ 13 | ((uint8_t*)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf)) 14 | 15 | #define BreakClear(array, addr, flag) \ 16 | ((uint8_t*)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf)) 17 | 18 | // check 19 | #define BreakThumbCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8) 20 | 21 | #define BreakARMCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4) 22 | 23 | #define BreakReadCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2) 24 | 25 | #define BreakWriteCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1) 26 | 27 | #define BreakCheck(array, addr, flag) \ 28 | ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf)) 29 | 30 | extern bool debugger; 31 | 32 | extern bool dexp_eval(char*, uint32_t*); 33 | extern void dexp_setVar(char*, uint32_t); 34 | extern void dexp_listVars(); 35 | extern void dexp_saveVars(char*); 36 | extern void dexp_loadVars(char*); 37 | 38 | void debuggerOutput(const char* s, uint32_t addr); 39 | 40 | bool debuggerBreakOnExecution(uint32_t address, uint8_t state); 41 | bool debuggerBreakOnWrite(uint32_t address, uint32_t value, int size); 42 | void debuggerBreakOnWrite(uint32_t address, uint32_t oldvalue, uint32_t value, int size, int t); 43 | bool debuggerBreakOnRead(uint32_t address, int size); 44 | 45 | struct regBreak { 46 | // uint8_t regNum; /No longer needed 47 | // bit 0 = equal 48 | // bit 1 = greater 49 | // bit 2 = smaller 50 | // bit 3 = signed 51 | uint8_t flags; 52 | uint32_t intVal; 53 | struct regBreak* next; 54 | }; 55 | extern uint8_t lowRegBreakCounter[4]; //(r0-r3) 56 | extern uint8_t medRegBreakCounter[4]; //(r4-r7) 57 | extern uint8_t highRegBreakCounter[4]; //(r8-r11) 58 | extern uint8_t statusRegBreakCounter[4]; //(r12-r15) 59 | 60 | extern bool enableRegBreak; 61 | extern regBreak* breakRegList[16]; 62 | extern void breakReg_check(int i); 63 | 64 | struct regBreak* getFromBreakRegList(uint8_t regnum, int location); 65 | 66 | void clearBreakRegList(); 67 | void clearParticularRegListBreaks(int reg); 68 | void deleteFromBreakRegList(uint8_t regnum, int location); 69 | 70 | void addBreakRegToList(uint8_t regnum, uint8_t flags, uint32_t value); 71 | void printBreakRegList(bool verbose); 72 | 73 | void remoteStubMain(); 74 | void remoteStubSignal(int sig, int number); 75 | void remoteOutput(const char* s, uint32_t addr); 76 | void remoteSetProtocol(int p); 77 | void remoteSetPort(int port); 78 | 79 | #endif // REMOTE_H 80 | -------------------------------------------------------------------------------- /src/libretro/Makefile.common: -------------------------------------------------------------------------------- 1 | LIBRETRO_COMMON := $(CORE_DIR)/libretro/libretro-common 2 | INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMMON)/include 3 | VBA_DEFINES := -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_DEBUGGER 4 | VBA_DEFINES += -DNO_PNG 5 | 6 | ifeq ($(TILED_RENDERING), 1) 7 | VBA_DEFINES += -DTILED_RENDERING 8 | endif 9 | 10 | ifeq ($(FRONTEND_SUPPORTS_RGB565),1) 11 | VBA_DEFINES += -DFRONTEND_SUPPORTS_RGB565 12 | endif 13 | 14 | ifeq ($(NO_LINK),1) 15 | VBA_DEFINES += -DNO_LINK 16 | endif 17 | 18 | SOURCES_CXX := 19 | SOURCES_CXX += \ 20 | $(CORE_DIR)/libretro/libretro.cpp \ 21 | $(CORE_DIR)/libretro/UtilRetro.cpp \ 22 | $(CORE_DIR)/libretro/SoundRetro.cpp 23 | 24 | SOURCES_CXX += \ 25 | $(CORE_DIR)/apu/Gb_Oscs.cpp \ 26 | $(CORE_DIR)/apu/Gb_Apu_State.cpp \ 27 | $(CORE_DIR)/apu/Blip_Buffer.cpp \ 28 | $(CORE_DIR)/apu/Multi_Buffer.cpp \ 29 | $(CORE_DIR)/apu/Effects_Buffer.cpp \ 30 | $(CORE_DIR)/apu/Gb_Apu.cpp 31 | 32 | SOURCES_CXX += \ 33 | $(CORE_DIR)/gba/GBA-thumb.cpp \ 34 | $(CORE_DIR)/gba/Sound.cpp \ 35 | $(CORE_DIR)/gba/Mode1.cpp \ 36 | $(CORE_DIR)/gba/CheatSearch.cpp \ 37 | $(CORE_DIR)/gba/Globals.cpp \ 38 | $(CORE_DIR)/gba/agbprint.cpp \ 39 | $(CORE_DIR)/gba/Mode4.cpp \ 40 | $(CORE_DIR)/gba/Mode3.cpp \ 41 | $(CORE_DIR)/gba/Mode5.cpp \ 42 | $(CORE_DIR)/gba/Mode2.cpp \ 43 | $(CORE_DIR)/gba/ereader.cpp \ 44 | $(CORE_DIR)/gba/GBA-arm.cpp \ 45 | $(CORE_DIR)/gba/bios.cpp \ 46 | $(CORE_DIR)/gba/Mode0.cpp \ 47 | $(CORE_DIR)/gba/Flash.cpp \ 48 | $(CORE_DIR)/gba/GBAGfx.cpp \ 49 | $(CORE_DIR)/gba/Cheats.cpp \ 50 | $(CORE_DIR)/gba/GBA.cpp \ 51 | $(CORE_DIR)/gba/EEprom.cpp \ 52 | $(CORE_DIR)/gba/RTC.cpp \ 53 | $(CORE_DIR)/gba/Sram.cpp 54 | 55 | SOURCES_CXX += \ 56 | $(CORE_DIR)/gb/gbCheats.cpp \ 57 | $(CORE_DIR)/gb/GB.cpp \ 58 | $(CORE_DIR)/gb/gbGfx.cpp \ 59 | $(CORE_DIR)/gb/gbGlobals.cpp \ 60 | $(CORE_DIR)/gb/gbMemory.cpp \ 61 | $(CORE_DIR)/gb/gbSGB.cpp \ 62 | $(CORE_DIR)/gb/gbSound.cpp 63 | 64 | # Filters 65 | SOURCES_CXX += \ 66 | $(CORE_DIR)/filters/interframe.cpp \ 67 | $(CORE_DIR)/gba/gbafilter.cpp 68 | -------------------------------------------------------------------------------- /src/libretro/SoundRetro.cpp: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 2008 VBA-M development team 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2, or(at your option) 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software Foundation, 16 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | #include "SoundRetro.h" 19 | #include "libretro.h" 20 | 21 | extern retro_audio_sample_batch_t audio_batch_cb; 22 | 23 | SoundRetro::SoundRetro() 24 | { 25 | } 26 | 27 | void SoundRetro::write(uint16_t* finalWave, int length) 28 | { 29 | const int16_t* wave = (const int16_t*)finalWave; 30 | int frames = length >> 1; 31 | audio_batch_cb(wave, frames); 32 | } 33 | 34 | bool SoundRetro::init(long sampleRate) 35 | { 36 | (void)sampleRate; // unused param 37 | return true; 38 | } 39 | 40 | SoundRetro::~SoundRetro() 41 | { 42 | } 43 | 44 | void SoundRetro::pause() 45 | { 46 | } 47 | 48 | void SoundRetro::resume() 49 | { 50 | } 51 | 52 | void SoundRetro::reset() 53 | { 54 | } 55 | 56 | void SoundRetro::setThrottle(unsigned short throttle) 57 | { 58 | (void)throttle; // unused param 59 | } 60 | -------------------------------------------------------------------------------- /src/libretro/SoundRetro.h: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 2008 VBA-M development team 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2, or(at your option) 7 | // any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software Foundation, 16 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | #ifndef __VBA_SOUND_RETRO_H__ 19 | #define __VBA_SOUND_RETRO_H__ 20 | 21 | #include "../common/SoundDriver.h" 22 | 23 | class SoundRetro : public SoundDriver { 24 | public: 25 | SoundRetro(); 26 | virtual ~SoundRetro(); 27 | 28 | virtual bool init(long sampleRate); 29 | virtual void pause(); 30 | virtual void reset(); 31 | virtual void resume(); 32 | virtual void write(uint16_t* finalWave, int length); 33 | virtual void setThrottle(unsigned short throttle); 34 | }; 35 | 36 | #endif // __VBA_SOUND_RETRO_H__ 37 | -------------------------------------------------------------------------------- /src/libretro/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | CORE_DIR := $(LOCAL_PATH)/../.. 3 | LIBRETRO_DIR := $(CORE_DIR)/libretro 4 | 5 | FRONTEND_SUPPORTS_RGB565 := 1 6 | TILED_RENDERING := 1 7 | NO_LINK := 1 8 | 9 | include $(LIBRETRO_DIR)/Makefile.common 10 | 11 | COREFLAGS := -DHAVE_STDINT_H $(VBA_DEFINES) $(INCFLAGS) 12 | 13 | VBAM_VERSION := $(shell sed -En 's/.*\[([0-9]+[^]]+).*/\1/p; T; q' ../../CHANGELOG.md 2>/dev/null) 14 | COREFLAGS += -DVBAM_VERSION=\"$(VBAM_VERSION)\" 15 | TAG_COMMIT := $(shell git rev-list -n 1 v$(VBAM_VERSION) --abbrev-commit 2>/dev/null) 16 | CURRENT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) 17 | 18 | ifneq ($(CURRENT_COMMIT),$(TAG_COMMIT)) 19 | COREFLAGS += -DGIT_COMMIT=\"$(CURRENT_COMMIT)\" 20 | endif 21 | 22 | ifeq ($(NO_LINK), 1) 23 | COREFLAGS += -DNO_LINK 24 | endif 25 | 26 | include $(CLEAR_VARS) 27 | LOCAL_MODULE := retro 28 | LOCAL_SRC_FILES := $(SOURCES_CXX) 29 | LOCAL_CXXFLAGS := $(COREFLAGS) 30 | LOCAL_LDFLAGS := -Wl,-version-script=$(LIBRETRO_DIR)/link.T 31 | include $(BUILD_SHARED_LIBRARY) 32 | -------------------------------------------------------------------------------- /src/libretro/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | APP_STL := c++_static 3 | -------------------------------------------------------------------------------- /src/libretro/libretro-common/include/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 29 | #define INLINE __inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /src/libretro/link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | -------------------------------------------------------------------------------- /src/libretro/vbam_libretro.info: -------------------------------------------------------------------------------- 1 | display_name = "Nintendo - Game Boy Advance (VBA-M)" 2 | authors = "Forgotten|VBA-M Team" 3 | supported_extensions = "gb|gbc|gba" 4 | corename = "VBA-M" 5 | manufacturer = "Nintendo" 6 | categories = "Emulator" 7 | systemname = "Game Boy/Game Boy Color/Game Boy Advance" 8 | database = "Nintendo - Game Boy|Nintendo - Game Boy Color|Nintendo - Game Boy Advance|Nintendo - Game Boy Advance (e-Cards)" 9 | license = "GPLv2" 10 | permissions = "" 11 | display_version = "2.1.0" 12 | supports_no_game = "false" 13 | firmware_count = 3 14 | firmware0_desc = "gba_bios.bin (Game Boy Advance BIOS)" 15 | firmware0_path = "gba_bios.bin" 16 | firmware0_opt = "true" 17 | firmware1_desc = "gb_bios.bin (Game Boy BIOS)" 18 | firmware1_path = "gb_bios.bin" 19 | firmware1_opt = "true" 20 | firmware2_desc = "gbc_bios.bin (Game Boy Color BIOS)" 21 | firmware2_path = "gbc_bios.bin" 22 | firmware2_opt = "true" 23 | notes = "(!) gba_bios.bin (md5): a860e8c0b6d573d191e4ec7db1b1e4f6|(!) gb_bios.bin (md5): 32fbbd84168d3482956eb3c5051637f5|(!) gbc_bios.bin (md5): dbfce9db9deaa2567f6a84fde55f9680" 24 | -------------------------------------------------------------------------------- /src/sdl/debugger.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 3 | // Copyright (C) 1999-2003 Forgotten 4 | // Copyright (C) 2004 Forgotten and the VBA development team 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2, or(at your option) 9 | // any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software Foundation, 18 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | extern void debuggerMain(); 21 | extern void debuggerOutput(const char*, uint32_t); 22 | extern void debuggerSignal(int, int); 23 | -------------------------------------------------------------------------------- /src/sdl/expr.cpp.h: -------------------------------------------------------------------------------- 1 | /* A Bison parser, made by GNU Bison 2.3. */ 2 | 3 | /* Skeleton interface for Bison's Yacc-like parsers in C 4 | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 | Free Software Foundation, Inc. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2, or (at your option) 11 | any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 | Boston, MA 02110-1301, USA. */ 22 | 23 | /* As a special exception, you may create a larger work that contains 24 | part or all of the Bison parser skeleton and distribute that work 25 | under terms of your choice, so long as that work isn't itself a 26 | parser generator using the skeleton or a modified version thereof 27 | as a parser skeleton. Alternatively, if you modify or redistribute 28 | the parser skeleton itself, you may (at your option) remove this 29 | special exception, which will cause the skeleton and the resulting 30 | Bison output files to be licensed under the GNU General Public 31 | License without this special exception. 32 | 33 | This special exception was added by the Free Software Foundation in 34 | version 2.2 of Bison. */ 35 | 36 | /* Tokens. */ 37 | #ifndef YYTOKENTYPE 38 | #define YYTOKENTYPE 39 | /* Put the tokens into the symbol table, so that GDB and other debuggers 40 | know about them. */ 41 | enum yytokentype { 42 | TOKEN_IDENTIFIER = 258, 43 | TOKEN_DOT = 259, 44 | TOKEN_STAR = 260, 45 | TOKEN_ARROW = 261, 46 | TOKEN_ADDR = 262, 47 | TOKEN_SIZEOF = 263, 48 | TOKEN_NUMBER = 264 49 | }; 50 | #endif 51 | /* Tokens. */ 52 | #define TOKEN_IDENTIFIER 258 53 | #define TOKEN_DOT 259 54 | #define TOKEN_STAR 260 55 | #define TOKEN_ARROW 261 56 | #define TOKEN_ADDR 262 57 | #define TOKEN_SIZEOF 263 58 | #define TOKEN_NUMBER 264 59 | 60 | #if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED 61 | typedef int YYSTYPE; 62 | #define yystype YYSTYPE /* obsolescent; will be withdrawn */ 63 | #define YYSTYPE_IS_DECLARED 1 64 | #define YYSTYPE_IS_TRIVIAL 1 65 | #endif 66 | 67 | extern YYSTYPE yylval; 68 | -------------------------------------------------------------------------------- /src/sdl/expr.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include "expr.cpp.h" 3 | 4 | #ifndef __GNUC__ 5 | #include 6 | #define isatty _isatty 7 | #define fileno _fileno 8 | #endif 9 | 10 | char *exprString; 11 | int exprCol; 12 | 13 | #define YY_INPUT(buf,result,max_size) \ 14 | { \ 15 | int c = *exprString++; \ 16 | exprCol++;\ 17 | result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ 18 | } 19 | %} 20 | 21 | %option nomain 22 | %option noyywrap 23 | %option nounput 24 | 25 | SIZEOF "sizeof" 26 | ID [a-zA-Z_][a-zA-Z0-9_]* 27 | NUM [0-9]+ 28 | DOT "." 29 | ARROW "->" 30 | STAR "*" 31 | ADDR "&" 32 | 33 | %% 34 | 35 | {SIZEOF} { 36 | return TOKEN_SIZEOF; 37 | } 38 | 39 | {ID} { 40 | return TOKEN_IDENTIFIER; 41 | } 42 | 43 | {NUM} { 44 | return TOKEN_NUMBER; 45 | } 46 | 47 | {DOT} { 48 | return TOKEN_DOT; 49 | } 50 | 51 | {ARROW} { 52 | return TOKEN_ARROW; 53 | } 54 | 55 | {ADDR} { 56 | return TOKEN_ADDR; 57 | } 58 | 59 | {STAR} { 60 | return TOKEN_STAR; 61 | } 62 | 63 | [ \t\n]+ 64 | 65 | . return *yytext; 66 | 67 | %% 68 | 69 | void exprCleanBuffer() 70 | { 71 | yy_delete_buffer(YY_CURRENT_BUFFER); 72 | yy_init = 1; 73 | } 74 | -------------------------------------------------------------------------------- /src/sdl/expr.ypp: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../System.h" 8 | #include "../gba/elf.h" 9 | #include "exprNode.h" 10 | 11 | extern int yyerror(const char *); 12 | extern int yylex(); 13 | extern char *yytext; 14 | 15 | 16 | //#define YYERROR_VERBOSE 1 17 | //#define YYDEBUG 1 18 | 19 | Node *result = NULL; 20 | %} 21 | 22 | %token TOKEN_IDENTIFIER TOKEN_DOT TOKEN_STAR TOKEN_ARROW TOKEN_ADDR 23 | %token TOKEN_SIZEOF TOKEN_NUMBER 24 | %left TOKEN_DOT TOKEN_ARROW '[' 25 | %expect 6 26 | %% 27 | 28 | final: expression { result = $1; } 29 | ; 30 | 31 | expression: 32 | simple_expression { $$ = $1; } | 33 | '(' expression ')' { $$ = $2; } | 34 | expression TOKEN_DOT ident { $$ = exprNodeDot($1, $3); } | 35 | expression TOKEN_ARROW ident { $$ = exprNodeArrow($1, $3); } | 36 | expression '[' number ']' { $$ = exprNodeArray($1, $3); } 37 | ; 38 | simple_expression: 39 | ident { $$ = $1; } | 40 | TOKEN_STAR expression { $$ = exprNodeStar($2); } | 41 | TOKEN_ADDR expression { $$ = exprNodeAddr($2); } | 42 | TOKEN_SIZEOF '(' expression ')' { $$ = exprNodeSizeof($3); } 43 | ; 44 | 45 | number: 46 | TOKEN_NUMBER { $$ = exprNodeNumber(); } 47 | ; 48 | 49 | ident: 50 | TOKEN_IDENTIFIER {$$ = exprNodeIdentifier(); } 51 | ; 52 | 53 | %% 54 | 55 | int yyerror(const char *s) 56 | { 57 | return 0; 58 | } 59 | 60 | #ifndef SDL 61 | extern FILE *yyin; 62 | int main(int argc, char **argv) 63 | { 64 | // yydebug = 1; 65 | ++argv, --argc; 66 | if(argc > 0) 67 | yyin = fopen(argv[0], "r"); 68 | else 69 | yyin = stdin; 70 | if(!yyparse()) 71 | result->print(); 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /src/sdl/exprNode.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 3 | // Copyright (C) 1999-2003 Forgotten 4 | // Copyright (C) 2004 Forgotten and the VBA development team 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2, or(at your option) 9 | // any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software Foundation, 18 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | struct Node { 21 | Type* type; 22 | uint32_t location; 23 | uint32_t objLocation; 24 | LocationType locType; 25 | int value; 26 | int index; 27 | const char* name; 28 | Node* expression; 29 | Member* member; 30 | void (*print)(Node*); 31 | bool (*resolve)(Node*, Function* f, CompileUnit* u); 32 | }; 33 | 34 | extern void exprNodeCleanUp(); 35 | 36 | extern Node* exprNodeIdentifier(); 37 | extern void exprNodeIdentifierPrint(Node*); 38 | extern bool exprNodeIdentifierResolve(Node*, Function*, CompileUnit*); 39 | 40 | extern Node* exprNodeNumber(); 41 | extern void exprNodeNumberPrint(Node*); 42 | extern bool exprNodeNumberResolve(Node*, Function*, CompileUnit*); 43 | 44 | extern Node* exprNodeStar(Node*); 45 | extern void exprNodeStarPrint(Node*); 46 | extern bool exprNodeStarResolve(Node*, Function*, CompileUnit*); 47 | 48 | extern Node* exprNodeDot(Node*, Node*); 49 | extern void exprNodeDotPrint(Node*); 50 | extern bool exprNodeDotResolve(Node*, Function*, CompileUnit*); 51 | 52 | extern Node* exprNodeArrow(Node*, Node*); 53 | extern void exprNodeArrowPrint(Node*); 54 | extern bool exprNodeArrowResolve(Node*, Function*, CompileUnit*); 55 | 56 | extern Node* exprNodeAddr(Node*); 57 | extern void exprNodeAddrPrint(Node*); 58 | extern bool exprNodeAddrResolve(Node*, Function*, CompileUnit*); 59 | 60 | extern Node* exprNodeSizeof(Node*); 61 | extern void exprNodeSizeofPrint(Node*); 62 | extern bool exprNodeSizeofResolve(Node*, Function*, CompileUnit*); 63 | 64 | extern Node* exprNodeArray(Node*, Node*); 65 | extern void exprNodeArrayPrint(Node*); 66 | extern bool exprNodeArrayResolve(Node*, Function*, CompileUnit*); 67 | 68 | #define YYSTYPE struct Node* 69 | -------------------------------------------------------------------------------- /src/sdl/filters.h: -------------------------------------------------------------------------------- 1 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 2 | // Copyright (C) 1999-2003 Forgotten 3 | // Copyright (C) 2004-2015 Forgotten and the VBA development team 4 | 5 | // This program is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2, or(at your option) 8 | // any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | #ifndef VBA_SDL_FILTERS_H 20 | #define VBA_SDL_FILTERS_H 21 | 22 | #include "../common/Types.h" 23 | #include "../System.h" 24 | 25 | // 26 | // Screen filters 27 | // 28 | 29 | // List of available filters 30 | enum Filter { 31 | kStretch1x, 32 | kStretch2x, 33 | k2xSaI, 34 | kSuper2xSaI, 35 | kSuperEagle, 36 | kPixelate, 37 | kAdMame2x, 38 | kBilinear, 39 | kBilinearPlus, 40 | kScanlines, 41 | kScanlinesTV, 42 | klq2x, 43 | khq2x, 44 | xbrz2x, 45 | kStretch3x, 46 | khq3x, 47 | xbrz3x, 48 | kStretch4x, 49 | khq4x, 50 | xbrz4x, 51 | xbrz5x, 52 | xbrz6x, 53 | kInvalidFilter 54 | }; 55 | 56 | // Function pointer type for a filter function 57 | typedef void (*FilterFunc)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int); 58 | 59 | // Initialize a filter and get the corresponding filter function pointer 60 | FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth); 61 | 62 | // Get the enlarge factor of a filter 63 | int getFilterEnlargeFactor(const int f); 64 | 65 | // Get the display name for a filter 66 | char* getFilterName(const int f); 67 | 68 | // 69 | // Interframe filters 70 | // 71 | 72 | // List of available IFB filters 73 | enum IFBFilter { kIFBNone, 74 | kIBMotionBlur, 75 | kIBSmart, 76 | kInvalidIFBFilter }; 77 | 78 | // Function pointer type for an IFB filter function 79 | typedef void (*IFBFilterFunc)(uint8_t*, uint32_t, int, int); 80 | 81 | // Initialize an IFB filter and get the corresponding filter function pointer 82 | IFBFilterFunc initIFBFilter(const int f, const int colorDepth); 83 | 84 | // Get the display name for an IFB filter 85 | char* getIFBFilterName(const IFBFilter f); 86 | 87 | #endif // VBA_SDL_FILTERS_H 88 | -------------------------------------------------------------------------------- /src/sdl/text.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 3 | // Copyright (C) 1999-2003 Forgotten 4 | // Copyright (C) 2004 Forgotten and the VBA development team 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2, or(at your option) 9 | // any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software Foundation, 18 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | extern void drawText(uint8_t*, int, int, int, const char*, bool); 21 | -------------------------------------------------------------------------------- /src/snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: visualboyadvance-m 2 | version: 2.1.0 3 | summary: Nintendo Game Boy Advance Emulator 4 | description: | 5 | An open-source Nintendo Game Boy, Super Game Boy, Game Boy Advance Emulators. 6 | 7 | confinement: devmode 8 | 9 | parts: 10 | vbam: 11 | source: https://github.com/visualboyadvance-m/visualboyadvance-m/archive/v2.1.0.tar.gz 12 | plugin: cmake 13 | build-packages: 14 | - g++ 15 | - gcc 16 | - make 17 | - cmake 18 | - libwxgtk3.0-dev 19 | - libsdl2-dev 20 | - libsfml-dev 21 | - libgtk2.0-dev 22 | configflags: 23 | - -DCMAKE_INSTALL_PREFIX=/ 24 | 25 | apps: 26 | visualboyadvance-m: 27 | command: visualboyadvance-m 28 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. 3 | // Copyright (C) 1999-2003 Forgotten 4 | // Copyright (C) 2004 Forgotten and the VBA development team 5 | 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2, or(at your option) 9 | // any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software Foundation, 18 | // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | #define VBA_NAME "VisualBoyAdvance-M" 21 | #define VBA_CURRENT_VERSION "@VERSION@" 22 | 23 | #define VBA_FEATURE_STRING "" 24 | 25 | #define _STRINGIFY(N) #N 26 | 27 | #if @VERSION_RELEASE@ 28 | #define VBA_SUBVERSION_STRING "" 29 | #else 30 | #define VBA_SUBVERSION_STRING "-" "@REVISION@" 31 | #endif 32 | 33 | #if defined(_MSC_VER) 34 | #define VBA_COMPILER "msvc" 35 | #define VBA_COMPILER_DETAIL _STRINGIFY(_MSC_VER) 36 | #else 37 | #define VBA_COMPILER "" 38 | #define VBA_COMPILER_DETAIL "" 39 | #endif 40 | 41 | #define VBA_VERSION_STRING VBA_CURRENT_VERSION VBA_SUBVERSION_STRING VBA_FEATURE_STRING VBA_COMPILER 42 | #define VBA_NAME_AND_VERSION VBA_NAME " " VBA_VERSION_STRING 43 | #define VBA_NAME_AND_SUBVERSION VBA_NAME_AND_VERSION VBA_SUBVERSION_STRING 44 | 45 | #define VERSION VBA_CURRENT_VERSION VBA_SUBVERSION_STRING 46 | -------------------------------------------------------------------------------- /src/vita/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/wx/copy-events.cmake: -------------------------------------------------------------------------------- 1 | # Create cmdtab.cpp, cmdhandlers.h, cmd-evtable.h from cmdevents.cpp 2 | 3 | IF(NOT OUTDIR) 4 | SET(OUTDIR ".") 5 | ENDIF(NOT OUTDIR) 6 | 7 | SET(CMDTAB "${OUTDIR}/cmdtab.cpp") 8 | SET(EVPROTO "${OUTDIR}/cmdhandlers.h") 9 | SET(EVTABLE "${OUTDIR}/cmd-evtable.h") 10 | 11 | FILE(READ cmdevents.cpp MW) 12 | STRING(REGEX MATCHALL "\nEVT_HANDLER([^\")]|\"[^\"]*\")*\\)" MW "${MW}") 13 | 14 | # cmdtab.cpp is a table of cmd-id-name/cmd-name pairs 15 | # sorted for binary searching 16 | FILE(WRITE "${CMDTAB}" "// Generated from cmdevents.cpp; do not edit\n#include \"wxvbam.h\"\n\nstruct cmditem cmdtab[] = {\n") 17 | SET(EVLINES ) 18 | FOREACH(EV ${MW}) 19 | # stripping the wxID_ makes it look better, but it's still all-caps 20 | STRING(REGEX REPLACE "^[^\"]*\\((wxID_|)([^,]*),[^\"]*(\"[^\"]*\")[^,)]*(,[^)]*|).*" 21 | " new_cmditem(wxT(\"\\2\"), wxTRANSLATE(\\3), XRCID(\"\\1\\2\")\\4 )" 22 | EV "${EV}") 23 | STRING(REGEX REPLACE "XRCID\\(\"(wxID_[^\"]*)\"\\)" "\\1" EV ${EV}) 24 | LIST(APPEND EVLINES "${EV},\n") 25 | ENDFOREACH(EV) 26 | LIST(SORT EVLINES) 27 | STRING(REGEX REPLACE ",\n\$" "\n" EVLINES "${EVLINES}") 28 | FILE(APPEND "${CMDTAB}" ${EVLINES}) 29 | FILE(APPEND "${CMDTAB}" "};\nconst int ncmds = sizeof(cmdtab) / sizeof(cmdtab[0]);\n") 30 | 31 | # cmdhandlers.h contains prototypes for all handlers 32 | FILE(WRITE "${EVPROTO}" "// Generated from cmdevents.cpp; do not edit\n") 33 | FOREACH(EV ${MW}) 34 | STRING(REGEX REPLACE "^[^\"]*\\(" "void On" P1 "${EV}") 35 | STRING(REGEX REPLACE ",.*" "(wxCommandEvent&);\n" P1 "${P1}") 36 | FILE(APPEND "${EVPROTO}" "${P1}") 37 | IF(EV MATCHES "EVT_HANDLER_MASK") 38 | STRING(REGEX REPLACE "^[^\"]*\\(" "void Do" P1 "${EV}") 39 | STRING(REGEX REPLACE ",.*" "();\n" P1 "${P1}") 40 | FILE(APPEND "${EVPROTO}" "${P1}") 41 | ENDIF(EV MATCHES "EVT_HANDLER_MASK") 42 | ENDFOREACH(EV) 43 | 44 | # cmd-evtable.h has the event table entries for all handlers 45 | FILE(WRITE "${EVTABLE}" "// Generated from cmdevents.cpp; do not edit\n") 46 | FOREACH(EV ${MW}) 47 | FILE(APPEND "${EVTABLE}" "EVT_MENU(") 48 | STRING(REGEX REPLACE "[^\"]*\\(" "" EV "${EV}") 49 | STRING(REGEX REPLACE ",.*" "" EV "${EV}") 50 | IF("${EV}" MATCHES "wx.*") 51 | FILE(APPEND "${EVTABLE}" "${EV}") 52 | ELSE("${EV}" MATCHES "wx.*") 53 | FILE(APPEND "${EVTABLE}" "XRCID(\"${EV}\")") 54 | ENDIF("${EV}" MATCHES "wx.*") 55 | FILE(APPEND "${EVTABLE}" ", MainFrame::On${EV})\n") 56 | ENDFOREACH(EV) 57 | -------------------------------------------------------------------------------- /src/wx/drawing.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_DRAWING_H 2 | #define GAME_DRAWING_H 3 | 4 | #include "wxvbam.h" 5 | 6 | class BasicDrawingPanel : public DrawingPanel { 7 | public: 8 | BasicDrawingPanel(wxWindow* parent, int _width, int _height); 9 | 10 | protected: 11 | void DrawArea(wxWindowDC& dc); 12 | virtual void DrawImage(wxWindowDC& dc, wxImage* im); 13 | }; 14 | 15 | // wx <= 2.8 may not be compiled with opengl support 16 | #if !wxCHECK_VERSION(2, 9, 0) && !wxUSE_GLCANVAS 17 | #define NO_OGL 18 | #endif 19 | 20 | #ifndef NO_OGL 21 | #include 22 | 23 | // shuffled parms for 2.9 indicates non-auto glcontext 24 | // before 2.9, wxMAC does not have this (but wxGTK & wxMSW do) 25 | #if !wxCHECK_VERSION(2, 9, 0) && defined(__WXMAC__) 26 | #define wxglc(a, b, c, d, e, f) wxGLCanvas(a, b, d, e, f, wxEmptyString, c) 27 | #define wxGL_IMPLICIT_CONTEXT 28 | #else 29 | #define wxglc wxGLCanvas 30 | #endif 31 | 32 | class GLDrawingPanel : public DrawingPanelBase, public wxGLCanvas { 33 | public: 34 | GLDrawingPanel(wxWindow* parent, int _width, int _height); 35 | virtual ~GLDrawingPanel(); 36 | 37 | protected: 38 | void DrawArea(wxWindowDC& dc); 39 | void OnSize(wxSizeEvent& ev); 40 | void AdjustViewport(); 41 | #ifndef wxGL_IMPLICIT_CONTEXT 42 | wxGLContext* ctx; 43 | #endif 44 | void DrawingPanelInit(); 45 | GLuint texid, vlist; 46 | int texsize; 47 | }; 48 | #endif 49 | 50 | #if defined(__WXMSW__) && !defined(NO_D3D) 51 | class DXDrawingPanel : public DrawingPanel { 52 | public: 53 | DXDrawingPanel(wxWindow* parent, int _width, int _height); 54 | 55 | protected: 56 | void DrawArea(wxWindowDC&); 57 | }; 58 | #endif 59 | 60 | #if defined(__WXMAC__) 61 | class Quartz2DDrawingPanel : public BasicDrawingPanel { 62 | public: 63 | Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height); 64 | virtual void DrawImage(wxWindowDC& dc, wxImage* im); 65 | }; 66 | #endif 67 | 68 | #endif /* GAME_DRAWING_H */ 69 | -------------------------------------------------------------------------------- /src/wx/icons/VBA.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/VBA.ico -------------------------------------------------------------------------------- /src/wx/icons/sizes/128x128/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/128x128/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/16x16/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/16x16/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/22x22/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/22x22/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/24x24/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/24x24/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/256x256/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/256x256/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/32x32/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/32x32/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/48x48/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/48x48/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/64x64/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/64x64/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/sizes/96x96/apps/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/sizes/96x96/apps/vbam.png -------------------------------------------------------------------------------- /src/wx/icons/vbam.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/vbam.icns -------------------------------------------------------------------------------- /src/wx/icons/vbam.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/vbam.ico -------------------------------------------------------------------------------- /src/wx/icons/vbam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/icons/vbam.png -------------------------------------------------------------------------------- /src/wx/link-static.cmake: -------------------------------------------------------------------------------- 1 | set(link_cmd_file CMakeFiles/visualboyadvance-m.dir/link.txt) 2 | 3 | if(EXISTS ${link_cmd_file}) 4 | file(READ ${link_cmd_file} link_cmd) 5 | 6 | string(REGEX REPLACE "-l(z|expat|X[^ ]+|xcb[^ ]*) " "-Wl,--whole-archive -l\\1 -Wl,--no-whole-archive " link_cmd ${link_cmd}) 7 | 8 | file(WRITE ${link_cmd_file} ${link_cmd}) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/wx/mac-translations.cmake: -------------------------------------------------------------------------------- 1 | # install localizations 2 | file(GLOB gmos "po/wxvbam/*.gmo") 3 | 4 | foreach(gmo ${gmos}) 5 | # strip path 6 | string(REGEX REPLACE "^.*/" "" gmo ${gmo}) 7 | 8 | string(REPLACE ".gmo" "" lang ${gmo}) 9 | 10 | file(MAKE_DIRECTORY "visualboyadvance-m.app/Contents/Resources/${lang}.lproj") 11 | file(COPY "po/wxvbam/${gmo}" DESTINATION "visualboyadvance-m.app/Contents/Resources/${lang}.lproj") 12 | file(RENAME "visualboyadvance-m.app/Contents/Resources/${lang}.lproj/${gmo}" "visualboyadvance-m.app/Contents/Resources/${lang}.lproj/wxvbam.mo") 13 | endforeach() 14 | -------------------------------------------------------------------------------- /src/wx/msys-link-static.cmake: -------------------------------------------------------------------------------- 1 | set(link_cmd_file CMakeFiles/visualboyadvance-m.dir/linklibs.rsp) 2 | 3 | if(EXISTS ${link_cmd_file}) 4 | file(READ ${link_cmd_file} link_libs) 5 | 6 | string(REPLACE "-Wl,-Bdynamic" "" link_libs ${link_libs}) 7 | 8 | file(WRITE ${link_cmd_file} ${link_libs}) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/wx/openal.h: -------------------------------------------------------------------------------- 1 | // on win32 and mac, pointer typedefs only happen with AL_NO_PROTOTYPES 2 | // on mac, ALC_NO_PROTOTYPES as well 3 | 4 | #define AL_NO_PROTOTYPES 1 5 | 6 | // on mac, alc pointer typedefs ony happen for ALC if ALC_NO_PROTOTYPES 7 | // unfortunately, there is a bug in the system headers (use of ALCvoid when 8 | // void should be used; shame on Apple for introducing this error, and shame 9 | // on Creative for making a typedef to void in the first place) 10 | //#define ALC_NO_PROTOTYPES 1 11 | 12 | #include 13 | #include 14 | 15 | // since the ALC typedefs are broken on Mac: 16 | 17 | #ifdef __WXMAC__ 18 | typedef ALCcontext*(ALC_APIENTRY* LPALCCREATECONTEXT)(ALCdevice* device, const ALCint* attrlist); 19 | typedef ALCboolean(ALC_APIENTRY* LPALCMAKECONTEXTCURRENT)(ALCcontext* context); 20 | typedef void(ALC_APIENTRY* LPALCDESTROYCONTEXT)(ALCcontext* context); 21 | typedef ALCdevice*(ALC_APIENTRY* LPALCOPENDEVICE)(const ALCchar* devicename); 22 | typedef ALCboolean(ALC_APIENTRY* LPALCCLOSEDEVICE)(ALCdevice* device); 23 | typedef ALCboolean(ALC_APIENTRY* LPALCISEXTENSIONPRESENT)(ALCdevice* device, 24 | const ALCchar* extname); 25 | typedef const ALCchar*(ALC_APIENTRY* LPALCGETSTRING)(ALCdevice* device, ALCenum param); 26 | #endif 27 | -------------------------------------------------------------------------------- /src/wx/pre-build.cmd: -------------------------------------------------------------------------------- 1 | cd ..\..\src\wx 2 | ..\..\dependencies\AStyle\bin\astyle --recursive -n --style=allman --indent=tab=4 --align-pointer=type --align-reference=name --break-blocks --pad-oper --pad-header --unpad-paren --delete-empty-lines --break-closing-brackets --keep-one-line-blocks --keep-one-line-statements --convert-tabs --remove-comment-prefix --mode=c *.cpp *.h 3 | cmake -P copy-events.cmake 4 | ..\..\dependencies\wxrc xrc\*.xrc -o wxvbam.xrs 5 | ..\..\dependencies\bin2c wxvbam.xrs builtin-xrc.h builtin_xrs 6 | ..\..\dependencies\bin2c ../vba-over.ini builtin-over.h builtin_over 7 | ..\..\dependencies\SubWCRev\SubWCRev.exe ..\..\.. ..\..\..\dependencies\SubWCRev\svnrev_template.h ..\svnrev.h 8 | exit 0 9 | -------------------------------------------------------------------------------- /src/wx/rpi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //--------------------------------------------------------------------------------------------------------------------------- 4 | // hq2x plugin example - Steve Snake 2004. 5 | // This plugin uses (modified) code by Maxim Stepin - see "hq2x16.asm" for info 6 | // The original code and description of the algorithm can be found at: 7 | // http://www.hiend3d.com/hq2x.html 8 | // Modified by suanyuan 9 | //--------------------------------------------------------------------------------------------------------------------------- 10 | #if defined(_WIN32) 11 | #include 12 | #else 13 | #define HMODULE void* 14 | #endif 15 | 16 | //--------------------------------------------------------------------------------------------------------------------------- 17 | typedef struct { 18 | unsigned long Size; 19 | unsigned long Flags; 20 | void* SrcPtr; 21 | unsigned long SrcPitch; 22 | unsigned long SrcW; 23 | unsigned long SrcH; 24 | void* DstPtr; 25 | unsigned long DstPitch; 26 | unsigned long DstW; 27 | unsigned long DstH; 28 | unsigned long OutW; 29 | unsigned long OutH; 30 | } RENDER_PLUGIN_OUTP; 31 | 32 | //--------------------------------------------------------------------------------------------------------------------------- 33 | 34 | typedef void (*RENDPLUG_Output)(RENDER_PLUGIN_OUTP*); 35 | 36 | //--------------------------------------------------------------------------------------------------------------------------- 37 | 38 | typedef struct { 39 | char Name[60]; 40 | unsigned long Flags; 41 | HMODULE Handle; 42 | RENDPLUG_Output Output; 43 | } RENDER_PLUGIN_INFO; 44 | 45 | //--------------------------------------------------------------------------------------------------------------------------- 46 | 47 | typedef RENDER_PLUGIN_INFO* (*RENDPLUG_GetInfo)(void); 48 | 49 | //--------------------------------------------------------------------------------------------------------------------------- 50 | 51 | #define RPI_VERSION 0x02 52 | 53 | #define RPI_MMX_USED 0x000000100 54 | #define RPI_MMX_REQD 0x000000200 55 | #define RPI_555_SUPP 0x000000400 56 | #define RPI_565_SUPP 0x000000800 57 | #define RPI_888_SUPP 0x000001000 58 | 59 | #define RPI_DST_WIDE 0x000008000 60 | 61 | #define RPI_OUT_SCL1 0x000010000 62 | #define RPI_OUT_SCL2 0x000020000 63 | #define RPI_OUT_SCL3 0x000030000 64 | #define RPI_OUT_SCL4 0x000040000 65 | 66 | #define RPI_OUT_SCLMSK 0x0000f0000 67 | #define RPI_OUT_SCLSH 16 68 | 69 | //--------------------------------------------------------------------------------------------------------------------------- 70 | 71 | int rpiScaleFactor(); 72 | bool rpiInit(const char* sPluginName); 73 | void rpiFilter(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* deltaPtr, uint8_t* dstPtr, uint32_t dstPitch, int width, 74 | int height); 75 | void rpiCleanup(); 76 | -------------------------------------------------------------------------------- /src/wx/strutils.cpp: -------------------------------------------------------------------------------- 1 | #include "strutils.h" 2 | 3 | // From: https://stackoverflow.com/a/7408245/262458 4 | // 5 | // modified to ignore empty tokens 6 | wxArrayString str_split(const wxString& text, const wxString& sep) { 7 | wxArrayString tokens; 8 | size_t start = 0, end = 0; 9 | 10 | while ((end = text.find(sep, start)) != std::string::npos) { 11 | wxString token = text.substr(start, end - start); 12 | 13 | if (token.length()) 14 | tokens.Add(token); 15 | 16 | start = end + 1; 17 | } 18 | 19 | tokens.Add(text.substr(start)); 20 | 21 | return tokens; 22 | } 23 | 24 | size_t vec_find(wxArrayString& opts, const wxString& val) { 25 | return opts.Index(val); 26 | } 27 | -------------------------------------------------------------------------------- /src/wx/strutils.h: -------------------------------------------------------------------------------- 1 | #ifndef STRUTILS_H 2 | #define STRUTILS_H 3 | 4 | #include 5 | #include 6 | 7 | // From: https://stackoverflow.com/a/7408245/262458 8 | wxArrayString str_split(const wxString& text, const wxString& sep); 9 | 10 | // From: https://stackoverflow.com/a/15099743/262458 11 | size_t vec_find(wxArrayString& opts, const wxString& val); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/wx/wayland.cpp: -------------------------------------------------------------------------------- 1 | #ifdef __WXGTK__ 2 | #include 3 | #ifdef GDK_WINDOWING_WAYLAND 4 | #include 5 | bool IsItWayland() { return GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default()); } 6 | #else 7 | bool IsItWayland() { return false; } 8 | #endif 9 | #else 10 | bool IsItWayland() { return false; } 11 | #endif 12 | -------------------------------------------------------------------------------- /src/wx/wayland.h: -------------------------------------------------------------------------------- 1 | bool IsItWayland(); 2 | -------------------------------------------------------------------------------- /src/wx/widgets/wx/webupdatedef.h: -------------------------------------------------------------------------------- 1 | // dummy webupdatedef.h for checklistctrl 2 | #ifndef WXDLLIMPEXP_WEBUPDATE 3 | // this will never be part of a DLL 4 | #define WXDLLIMPEXP_WEBUPDATE 5 | // why would I include it and not enable it? 6 | #define wxUSE_CHECKEDLISTCTRL 1 7 | // enable customizations: 8 | // - include wx/settings.h (bugfix; always enabled) 9 | // - make a dynamic class so it can be subclass in xrc 10 | // - only make col0 checkable 11 | // - use "native" checkbox (also requires CLC_USE_SYSICONS) 12 | #define CLC_VBAM_USAGE 1 13 | #define CLC_USE_SYSICONS 1 14 | #endif 15 | -------------------------------------------------------------------------------- /src/wx/wxvbam.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wxvbam.desktop 5 | CC-BY-SA-3.0 6 | GPL-2.0 7 | VisualBoyAdvance-M 8 | WX GUI for VisualBoyAdvance-M, a high compatibility Gameboy Advance Emulator 9 | 10 |

11 | VisualBoyAdvance-M is a Nintendo Game Boy Emulator with high compatibility with 12 | commercial games. It emulates the Nintendo Game Boy Advance hand held console, 13 | in addition to the original Game Boy hand held systems and its Super and Color 14 | variants. VBA-M is a continued development of the now inactive VisualBoy 15 | Advance project, with many improvements from various developments of VBA. 16 |

17 |
18 | http://vba-m.com/ 19 | https://github.com/visualboyadvance-m/visualboyadvance-m/issues 20 | alexjnewt_at_hotmail.com 21 |
22 | -------------------------------------------------------------------------------- /src/wx/wxvbam.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=VBA-M 5 | GenericName=Game Boy Advance Emulator 6 | Comment=Nintendo Game Boy Advance Emulator 7 | Exec=visualboyadvance-m %f 8 | Icon=vbam 9 | Categories=Game;Emulator; 10 | Keywords=emulator;Nintendo;gameboy;Game Boy;Game Boy Color;Game Boy Advance; 11 | MimeType=application/x-gameboy-rom;application/x-gameboy-advance-rom;application/x-dmg-rom;application/x-agb-rom;application/x-gb-rom;application/x-gba-rom; 12 | -------------------------------------------------------------------------------- /src/wx/wxvbam.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/vbam-libretro/379dd97301458a51fb69dd93ba21b64f81e01ef2/src/wx/wxvbam.rc -------------------------------------------------------------------------------- /src/wx/xrc/CheatList.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Cheat List 5 | 6 | wxVERTICAL 7 | 8 | 9 | 10 | 11 | Open cheat list 12 | 13 | 14 | 15 | Save cheat list 16 | 17 | 18 | 19 | 20 | Add new cheat 21 | 22 | 23 | 24 | Delete selected cheat 25 | 26 | 27 | 28 | 29 | Delete all cheats 30 | 31 | 32 | 33 | 34 | 35 | Toggle all Cheats 36 | 37 | 38 | wxEXPAND 39 | 40 | 41 | 42 | 43 | 44 | 45 | wxALL|wxEXPAND 46 | 5 47 | 200,100d 48 | 49 | 50 | wxALL|wxEXPAND 51 | 5 52 | 53 | 54 | 55 | 1 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/wx/xrc/CodeSelect.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | wxVERTICAL 6 | 7 | 8 | 9 | 10 | 11 | wxALL|wxEXPAND 12 | 5 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | wxALL|wxEXPAND 24 | 5 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/wx/xrc/ExportSPS.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | wxVERTICAL 6 | 7 | 8 | 9 | 10 | 11 | 12 | wxALL 13 | 5 14 | 15 | 16 | 17 | wxEXPAND|wxALL 18 | 5 19 | 20 | 21 | 22 | 23 | 24 | wxALL 25 | 5 26 | 27 | 28 | 29 | wxALL|wxEXPAND 30 | 5 31 | 32 | 33 | 34 | 35 | 36 | wxALL 37 | 5 38 | 39 | 40 | 41 | 42 | 43 | 44 | wxALL|wxEXPAND 45 | 5 46 | 200,100 47 | 48 | 2 49 | 1 50 | 2 51 | 52 | 53 | wxEXPAND 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | wxALL|wxEXPAND 65 | 5 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/wx/xrc/GBPrinter.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | wxVERTICAL 6 | 7 | 8 | 9 | 10 | 11 | 320,288 12 | 13 | 14 | wxALL|wxALIGN_CENTRE 15 | 5 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | wxALL|wxALIGN_CENTRE_VERTICAL 24 | 5 25 | 26 | 27 | 28 | 29 | 1x 30 | 2x 31 | 3x 32 | 4x 33 | 34 | 1 35 | 36 | wxALL|wxEXPAND 37 | 5 38 | 39 | wxHORIZONTAL 40 | 41 | wxALIGN_CENTRE_HORIZONTAL 42 | 43 | 44 | 45 | wxHORIZONTAL 46 | 47 | 48 | wxALL 49 | 5 50 | 51 | 52 | 53 | wxALL 54 | 5 55 | 56 | 57 | 58 | 59 | 60 | wxALL 61 | 5 62 | 63 | 64 | 65 | 66 | 67 | wxALL 68 | 5 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/wx/xrc/JoypadConfig.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Joypad Configuration 5 | 6 | wxVERTICAL 7 | 8 | 9 | 10 | 11 | 0,0 12 | 13 | 14 | 15 | 16 | 17 | 0,0 18 | 19 | 20 | 21 | 22 | 23 | 0,0 24 | 25 | 26 | 27 | 28 | 29 | 0,0 30 | 31 | 32 | 33 | 34 | 35 | 36 | wxALL|wxEXPAND 37 | 5 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/wx/xrc/LinkConfig.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Link configuration 5 | 6 | wxVERTICAL 7 | 8 | 9 | 10 | 11 | 12 | 13 | wxALL|wxALIGN_CENTRE_VERTICAL 14 | 5 15 | 16 | 17 | 18 | 0 19 | 9999999 20 | 21 | 22 | wxALL|wxEXPAND 23 | 5 24 | 25 | wxHORIZONTAL 26 | 27 | wxALL|wxEXPAND 28 | 5 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | wxALL|wxEXPAND 40 | 5 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/wx/xrc/MainFrame.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 2 7 | -3,-1 8 | 9 | 10 | wxHORIZONTAL 11 | 12 | 13 | #000000 14 | 15 | 16 | 17 | wxEXPAND 18 | 160,144 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/wx/xrc/MainIcon.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | vbam.xpm 4 | 5 | -------------------------------------------------------------------------------- /src/wx/xrc/MemSelRegion.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | wxVERTICAL 6 | 7 | 8 | 9 | 10 | 11 | 12 | wxALL|wxALIGN_CENTRE_VERTICAL 13 | 5 14 | 15 | 16 | 17 | wxALL|wxEXPAND 18 | 5 19 | 20 | 21 | 22 | 23 | 24 | wxALL|wxALIGN_CENTRE_VERTICAL 25 | 5 26 | 27 | 28 | 29 | wxALL|wxEXPAND 30 | 5 31 | 32 | 2 33 | 34 | wxEXPAND 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | wxALL|wxEXPAND 46 | 5 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /todo.md: -------------------------------------------------------------------------------- 1 | # The Visualboyadvance-M todo list for those that care 2 | 3 | - [x] remove silly type defs, Come on... It's 2016 4 | - [ ] Fix the updater in the wxwidgets interface, some people have been reporting issues of timing out with not internet. 5 | - [ ] Fix the libretro interface 6 | - [ ] Next will be removing the majority of the interface code and going straight libretro (Will make it easier to maintain one interface that's platform independent. 7 | - [ ] add OnSize handler for GLDrawingPanel in wx back to reset the GL viewport, and set viewport on init as well 8 | - [x] fix wx accels that are a game key with a modifier, e.g. ALT+ENTER when ENTER is a game key 9 | - [ ] add an option to the video config dialog to choose native or non-native fullscreen for Mac (and check if the OS supports it) 10 | - [ ] fix SFML cmake stuff so that static linking works on Mac 11 | - [ ] update FindSDL2.cmake to use sdl2-config if available and pkg-config is not, get PR merged upstream 12 | - [ ] optimize all options defaults for modern hardware 13 | - [ ] fix filter options in wx to apply to both fullscreen and window mode 14 | - [ ] update homebrew wxmac formula to also make static libs, this will allow static linking of wx, not really as necessary anymore but would still be nice 15 | - [ ] submit Mac homebrew formula, and make sure everything for "make install" works on Mac 16 | - [ ] update Mac .app plist stuffs 17 | - [ ] make full set of quality icons 18 | - [ ] update cmake code to allow building fully-redistributable binaries with msys2 on windows, possibly with an installer 19 | - [ ] write a ./quickbuild script that installs all deps and builds the project, for mac, msys2, and some linux dists 20 | - [ ] use SDL2 input introspection to automatically create a sane set of default control bindings 21 | - [ ] fix the literally hundreds of fucking warnings, and start using -Wall 22 | - [ ] set up automatic builds for all platforms 23 | - [ ] see what code we can steal from other emu folks, e.g. filters etc. 24 | - [ ] update config handling, to switch to XDG on linux etc. 25 | - [ ] add simple 'mute audio' option for wx interface 26 | - [ ] HiDPI support on Windows 27 | - [ ] ./installdeps for more platforms 28 | - [ ] console-mode Wx app on Windows in debug mode 29 | - [ ] fix keyboard game input on msys2 builds 30 | - [ ] fix the -D\*DIR defines to have the correct paths on various platforms 31 | 32 | # Coding Guidelines (for those that want to help out and send a pull request.) 33 | 34 | Coding guidelines, well I've switched to webkit's style meaning we use spaces and not hard tabs 35 | C has 8 spaces to an indent and c++ 4 spaces for an indent as well. This makes for cleaner code to read and to maintain. 36 | -------------------------------------------------------------------------------- /tools/linux/builder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | export BUILD_ROOT="${BUILD_ROOT:=$HOME/vbam-build-linux}" 6 | 7 | . "$(dirname "$0")/../builder/unix.sh" 8 | 9 | table_line_append DIST_EXTRA_LIBS shared-mime-info '-Wl,--start-group -lmount -lblkid -luuid -Wl,--end-group' 10 | 11 | table_line_append DIST_EXTRA_LDFLAGS ffmpeg -lunwind 12 | 13 | table_insert_before DISTS autoconf ' 14 | libunwind http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.2.tar.gz lib/libunwind.a 15 | ' 16 | 17 | table_insert_before DISTS glib ' 18 | libcap https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.25.tar.xz lib/libcap.a 19 | libudev https://github.com/systemd/systemd/archive/v237.tar.gz lib/libudev.a 20 | util-linux https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.xz lib/libmount.a 21 | ' 22 | 23 | table_line_append DIST_PATCHES libcap 'https://604802.bugs.gentoo.org/attachment.cgi?id=460354' 24 | 25 | table_line_append DIST_EXTRA_LDFLAGS util-linux '-lintl -liconv' 26 | 27 | table_line_append DIST_PATCHES libudev " \ 28 | https://gist.githubusercontent.com/rkitover/b639097f5c0304c5c4c66d19159fb9a2/raw/7c7bb75747c99fda2ed309c3337338279eff1527/systemd-237-static-libudev.patch \ 29 | " 30 | 31 | table_line_append DIST_EXTRA_LDFLAGS libudev '-Wl,--allow-multiple-definition -Wl,--start-group -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -Wl,--end-group' 32 | 33 | table_line_append DIST_ARGS libudev '-Dlink-udev-shared=false' 34 | 35 | table_line_append DIST_MAKE_ARGS libudev 'src/udev/libudev.a' 36 | 37 | table_line_append DIST_INSTALL_OVERRIDES libudev " \ 38 | mkdir -p \"\$BUILD_ROOT/root/lib/pkgconfig\"; \ 39 | mkdir -p \"\$BUILD_ROOT/root/include\"; \ 40 | cp -a src/udev/libudev.a \"\$BUILD_ROOT/root/lib\"; \ 41 | cp -a src/libudev/libudev.pc \"\$BUILD_ROOT/root/pkgconfig\"; \ 42 | cp -a ../src/libudev/libudev.h \"\$BUILD_ROOT/root/include\"; \ 43 | " 44 | 45 | builder "$@" 46 | -------------------------------------------------------------------------------- /tools/unix/builder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | export BUILD_ROOT="$HOME/vbam-build-unix" 6 | 7 | . "$(dirname "$0")/../builder/core.sh" 8 | 9 | table_line_append DIST_ARGS glib '--disable-libmount' 10 | 11 | builder "$@" 12 | -------------------------------------------------------------------------------- /tools/win/cygwin-cross-builder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # turn on real symlinks on cygwin 6 | if [ "$(uname -o 2>/dev/null || :)" = Cygwin ]; then 7 | new_cygwin= replaced= 8 | for part in $CYGWIN; do 9 | case "$part" in 10 | winsymlinks:*) 11 | new_cygwin="$new_cygwin winsymlinks:native" 12 | replaced=1 13 | ;; 14 | *) 15 | new_cygwin="$new_cygwin $part" 16 | ;; 17 | esac 18 | done 19 | 20 | if [ -n "$replaced" ]; then 21 | export CYGWIN=$new_cygwin 22 | else 23 | export CYGWIN="winsymlinks:native $new_cygwin" 24 | fi 25 | fi 26 | 27 | export REQUIRED_CMAKE_ARGS="-DGETTEXT_MSGFMT_EXECUTABLE:FILEPATH=\"\$BUILD_ROOT/host/bin/msgfmt\" -DGETTEXT_MSGMERGE_EXECUTABLE=\"\$BUILD_ROOT/host/bin/msgmerge\"" 28 | 29 | . "${0%/*}/../builder/mingw-cross.sh" 30 | 31 | table_line_append DIST_MAKE_ARGS unzip 'CFLAGS="$CFLAGS -DNO_LCHMOD"' 32 | 33 | # FIXME: problems with autopoint that need to be sorted 34 | table_line_remove DISTS flex 35 | 36 | table_line_append DIST_PRE_BUILD pkgconfig ":; \ 37 | sed -i.bak ' \ 38 | s/platform_win32=yes/platform_win32=no/; \ 39 | s/#define G_PLATFORM_WIN32//; \ 40 | s/PLATFORMDEP=gwin32\\.lo/PLATFORMDEP=/ \ 41 | ' glib/configure; \ 42 | " 43 | 44 | table_line_append DIST_PRE_BUILD c2man ":; \ 45 | sed -i.bak '/test -d c:\\//,/^fi\$/d' Configure; \ 46 | " 47 | 48 | table_line_replace DIST_CONFIGURE_TYPES freetype-target cmake 49 | table_line_remove DIST_ARGS freetype-target 50 | table_line_append DIST_POST_BUILD freetype-target ":; \ 51 | sed ' \ 52 | s,%prefix%,$BUILD_ROOT/root,g; \ 53 | s,%exec_prefix%,$BUILD_ROOT/root,g; \ 54 | s,%libdir%,$BUILD_ROOT/root/lib,g; \ 55 | s,%includedir%,$BUILD_ROOT/root/include,g; \ 56 | s,%ft_version%,20.0.14,g; \ 57 | s|%REQUIRES_PRIVATE%|zlib, bzip2, libpng|; \ 58 | s,%LIBS_PRIVATE%,-lpng -lz -lbz2 -llzma -lharfbuzz,; \ 59 | s/-lfreetype/-lfreetype -lpng -lz -lbz2 -llzma/; \ 60 | ' ../builds/unix/freetype2.in > "$BUILD_ROOT"/root/lib/pkgconfig/freetype2.pc; \ 61 | " 62 | 63 | table_line_append DIST_EXTRA_LIBS fontconfig-target '-lpng -lz -lbz2 -llzma' 64 | 65 | builder "$@" 66 | -------------------------------------------------------------------------------- /tools/win/linux-cross-builder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | . "${0%/*}/../builder/mingw-cross.sh" 6 | 7 | builder "$@" 8 | -------------------------------------------------------------------------------- /tools/win/mac-cross-builder: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | 3 | set -e 4 | 5 | export TAR=tar 6 | 7 | . "${0%/*}/../builder/mingw-cross.sh" 8 | 9 | host_env_hook() { 10 | cat <