├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── COPYING ├── Makefile ├── Makefile.common ├── Makefile.libretro ├── README-JP.MD ├── README.MD ├── develop.txt ├── doc └── kero_src.txt ├── fmgen ├── fmg_wrap.cpp ├── fmg_wrap.h ├── fmgen.cpp ├── fmgen.h ├── fmgeninl.h ├── fmtimer.cpp ├── fmtimer.h ├── misc.h ├── opm.cpp ├── opm.h ├── opna.cpp ├── opna.h ├── psg.cpp ├── psg.h └── readme.txt ├── game_notes.md ├── kaiseki.txt ├── libretro-common ├── compat │ ├── compat_posix_string.c │ ├── compat_snprintf.c │ ├── compat_strcasestr.c │ ├── compat_strl.c │ └── fopen_utf8.c ├── encodings │ └── encoding_utf.c ├── file │ ├── file_path.c │ ├── file_path_io.c │ └── retro_dirent.c ├── include │ ├── boolean.h │ ├── compat │ │ ├── fopen_utf8.h │ │ ├── msvc.h │ │ ├── msvc │ │ │ └── stdint.h │ │ ├── posix_string.h │ │ ├── strcasestr.h │ │ └── strl.h │ ├── encodings │ │ └── utf.h │ ├── file │ │ └── file_path.h │ ├── libretro.h │ ├── libretro_gskit_ps2.h │ ├── memalign.h │ ├── retro_assert.h │ ├── retro_common.h │ ├── retro_common_api.h │ ├── retro_dirent.h │ ├── retro_environment.h │ ├── retro_inline.h │ ├── retro_miscellaneous.h │ ├── streams │ │ ├── file_stream.h │ │ ├── file_stream_transforms.h │ │ └── memory_stream.h │ ├── string │ │ └── stdstring.h │ ├── time │ │ └── rtime.h │ └── vfs │ │ ├── vfs.h │ │ └── vfs_implementation.h ├── streams │ ├── file_stream.c │ └── file_stream_transforms.c ├── string │ └── stdstring.c ├── time │ └── rtime.c └── vfs │ └── vfs_implementation.c ├── libretro.c ├── libretro ├── cdrom.h ├── common.h ├── compiler.h ├── dosio.c ├── dosio.h ├── dswin.c ├── dswin.h ├── fake.c ├── jni │ ├── Android.mk │ └── Application.mk ├── joystick.c ├── joystick.h ├── keyboard.c ├── keyboard.h ├── menu_str_sjis.txt ├── mmsystem.h ├── mouse.c ├── mouse.h ├── peace.c ├── peace.h ├── prop.c ├── prop.h ├── state.c ├── state.h ├── state_inline.h ├── status.h ├── timer.c ├── timer.h ├── windraw.c ├── windraw.h ├── winui.c ├── winui.h └── winx68k.h ├── libretro_core_options.h ├── libretro_core_options_intl.h ├── link.T ├── m68000 ├── c68k │ ├── c68k.c │ ├── c68k.h │ ├── c68k_op0.inc │ ├── c68k_op1.inc │ ├── c68k_op2.inc │ ├── c68k_op3.inc │ ├── c68k_op4.inc │ ├── c68k_op5.inc │ ├── c68k_op6.inc │ ├── c68k_op7.inc │ ├── c68k_op8.inc │ ├── c68k_op9.inc │ ├── c68k_opA.inc │ ├── c68k_opB.inc │ ├── c68k_opC.inc │ ├── c68k_opD.inc │ ├── c68k_opE.inc │ ├── c68k_opF.inc │ ├── c68kexec.c │ └── core.h ├── cyclone.h ├── cyclone.s ├── m68000.c ├── m68000.h └── musashi │ ├── m68k.h │ ├── m68kconf.h │ ├── m68kcpu.c │ ├── m68kcpu.h │ ├── m68kfpu.c │ ├── m68kmmu.h │ ├── m68kops.c │ ├── m68kops.h │ └── softfloat │ ├── README.txt │ ├── mamesf.h │ ├── milieu.h │ ├── softfloat-macros │ ├── softfloat-specialize │ ├── softfloat.c │ └── softfloat.h ├── readme.txt ├── version.txt └── x68k ├── adpcm.c ├── adpcm.h ├── bg.c ├── bg.h ├── crtc.c ├── crtc.h ├── disk_d88.c ├── disk_d88.h ├── disk_dim.c ├── disk_dim.h ├── disk_xdf.c ├── disk_xdf.h ├── dmac.c ├── dmac.h ├── fdc.c ├── fdc.h ├── fdd.c ├── fdd.h ├── gvram.c ├── gvram.h ├── ioc.c ├── ioc.h ├── irqh.c ├── irqh.h ├── mem_wrap.c ├── mercury.c ├── mercury.h ├── mfp.c ├── mfp.h ├── midi.c ├── midi.h ├── palette.c ├── palette.h ├── pia.c ├── pia.h ├── rtc.c ├── rtc.h ├── sasi.c ├── sasi.h ├── scc.c ├── scc.h ├── scsi.c ├── scsi.h ├── sram.c ├── sram.h ├── sysport.c ├── sysport.h ├── tvram.c ├── tvram.h └── x68kmemory.h /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: PX68K CI 2 | on: [push, pull_request] 3 | jobs: 4 | linux-c68k: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v4 8 | - name: build with c68k 9 | run: make -j$(getconf _NPROCESSORS_ONLN) C68K=1 10 | 11 | linux-musashi: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: build with musashi 16 | run: make -j$(getconf _NPROCESSORS_ONLN) C68K=0 17 | 18 | windows-c68k: 19 | runs-on: windows-latest 20 | steps: 21 | - uses: msys2/setup-msys2@v2 22 | with: 23 | update: true 24 | install: >- 25 | base-devel 26 | gcc 27 | git 28 | make 29 | zip 30 | mingw-w64-x86_64-toolchain 31 | mingw-w64-x86_64-ntldd 32 | mingw-w64-x86_64-zlib 33 | mingw-w64-x86_64-pkg-config 34 | - uses: actions/checkout@v4 35 | - name: windows build with c68k 36 | shell: msys2 {0} 37 | run: make -j8 C68K=1 38 | 39 | windows-musashi: 40 | runs-on: windows-latest 41 | steps: 42 | - uses: msys2/setup-msys2@v2 43 | with: 44 | update: true 45 | install: >- 46 | base-devel 47 | gcc 48 | git 49 | make 50 | zip 51 | mingw-w64-x86_64-toolchain 52 | mingw-w64-x86_64-ntldd 53 | mingw-w64-x86_64-zlib 54 | mingw-w64-x86_64-pkg-config 55 | - uses: actions/checkout@v4 56 | - name: windows build with c68k 57 | shell: msys2 {0} 58 | run: make -j8 C68K=0 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | px68k-android/assets 2 | px68k-android/bin 3 | px68k-android/gen 4 | px68k-android/libs 5 | px68k-android/obj 6 | px68k-android/.classpath 7 | px68k-android/.project 8 | px68k-android/.settings 9 | px68k-ios/px68k-ios.xcodeproj/project.xcworkspace 10 | px68k-ios/px68k-ios.xcodeproj/xcuserdata 11 | *.o 12 | *.so 13 | *.dll 14 | libretro/libs 15 | libretro/obj 16 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # DESCRIPTION: GitLab CI/CD for libRetro (NOT FOR GitLab-proper) 2 | 3 | ############################################################################## 4 | ################################# BOILERPLATE ################################ 5 | ############################################################################## 6 | 7 | # Core definitions 8 | .core-defs: 9 | variables: 10 | JNI_PATH: libretro 11 | MAKEFILE: Makefile.libretro 12 | CORENAME: px68k 13 | 14 | # Inclusion templates, required for the build to work 15 | include: 16 | ################################## DESKTOPS ################################ 17 | # Windows 64-bit 18 | - project: 'libretro-infrastructure/ci-templates' 19 | file: '/windows-x64-mingw.yml' 20 | 21 | # Windows 32-bit 22 | - project: 'libretro-infrastructure/ci-templates' 23 | file: '/windows-i686-mingw.yml' 24 | 25 | # Linux 64-bit 26 | - project: 'libretro-infrastructure/ci-templates' 27 | file: '/linux-x64.yml' 28 | 29 | # MacOS 64-bit 30 | - project: 'libretro-infrastructure/ci-templates' 31 | file: '/osx-x64.yml' 32 | 33 | # MacOS ARM 64-bit 34 | - project: 'libretro-infrastructure/ci-templates' 35 | file: '/osx-arm64.yml' 36 | 37 | ################################## CELLULAR ################################ 38 | # Android 39 | - project: 'libretro-infrastructure/ci-templates' 40 | file: '/android-jni.yml' 41 | 42 | # iOS 43 | - project: 'libretro-infrastructure/ci-templates' 44 | file: '/ios-arm64.yml' 45 | 46 | # iOS (armv7) 47 | - project: 'libretro-infrastructure/ci-templates' 48 | file: '/ios9.yml' 49 | 50 | ################################## CONSOLES ################################ 51 | # PlayStation Vita 52 | - project: 'libretro-infrastructure/ci-templates' 53 | file: '/vita-static.yml' 54 | 55 | # Nintendo Switch 56 | - project: 'libretro-infrastructure/ci-templates' 57 | file: '/libnx-static.yml' 58 | 59 | # tvOS (AppleTV) 60 | - project: 'libretro-infrastructure/ci-templates' 61 | file: '/tvos-arm64.yml' 62 | 63 | #################################### MISC ################################## 64 | 65 | # Stages for building 66 | stages: 67 | - build-prepare 68 | - build-shared 69 | - build-static 70 | 71 | ############################################################################## 72 | #################################### STAGES ################################## 73 | ############################################################################## 74 | # 75 | ################################### DESKTOPS ################################# 76 | # Windows 64-bit 77 | libretro-build-windows-x64: 78 | extends: 79 | - .libretro-windows-x64-mingw-make-default 80 | - .core-defs 81 | 82 | # Windows 32-bit 83 | libretro-build-windows-i686: 84 | extends: 85 | - .libretro-windows-i686-mingw-make-default 86 | - .core-defs 87 | 88 | # Linux 64-bit 89 | libretro-build-linux-x64: 90 | extends: 91 | - .libretro-linux-x64-make-default 92 | - .core-defs 93 | 94 | # MacOS 64-bit 95 | libretro-build-osx-x64: 96 | extends: 97 | - .libretro-osx-x64-make-default 98 | - .core-defs 99 | 100 | # MacOS ARM 64-bit 101 | libretro-build-osx-arm64: 102 | extends: 103 | - .libretro-osx-arm64-make-default 104 | - .core-defs 105 | 106 | ################################### CELLULAR ################################# 107 | # Android ARMv7a 108 | android-armeabi-v7a: 109 | extends: 110 | - .libretro-android-jni-armeabi-v7a 111 | - .core-defs 112 | 113 | # Android ARMv8a 114 | android-arm64-v8a: 115 | extends: 116 | - .libretro-android-jni-arm64-v8a 117 | - .core-defs 118 | 119 | # Android 64-bit x86 120 | android-x86_64: 121 | extends: 122 | - .libretro-android-jni-x86_64 123 | - .core-defs 124 | 125 | # Android 32-bit x86 126 | android-x86: 127 | extends: 128 | - .libretro-android-jni-x86 129 | - .core-defs 130 | 131 | # iOS 132 | libretro-build-ios-arm64: 133 | extends: 134 | - .libretro-ios-arm64-make-default 135 | - .core-defs 136 | 137 | # iOS (armv7) [iOS 9 and up] 138 | libretro-build-ios9: 139 | extends: 140 | - .libretro-ios9-make-default 141 | - .core-defs 142 | 143 | # tvOS 144 | libretro-build-tvos-arm64: 145 | extends: 146 | - .libretro-tvos-arm64-make-default 147 | - .core-defs 148 | 149 | ################################### CONSOLES ################################# 150 | # PlayStation Vita 151 | libretro-build-vita: 152 | extends: 153 | - .libretro-vita-static-retroarch-master 154 | - .core-defs 155 | 156 | # Nintendo Switch 157 | libretro-build-libnx-aarch64: 158 | extends: 159 | - .libretro-libnx-static-retroarch-master 160 | - .core-defs 161 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | os: linux 3 | dist: trusty 4 | sudo: required 5 | addons: 6 | apt: 7 | packages: 8 | - g++-7 9 | sources: 10 | - ubuntu-toolchain-r-test 11 | env: 12 | global: 13 | - CORE=px68k 14 | - COMPILER_NAME=gcc CXX=g++-7 CC=gcc-7 15 | matrix: 16 | - PLATFORM=linux_x64 17 | before_script: 18 | - pwd 19 | - mkdir -p ~/bin 20 | - ln -s /usr/bin/gcc-7 ~/bin/gcc 21 | - ln -s /usr/bin/g++-7 ~/bin/g++ 22 | - ln -s /usr/bin/cpp-7 ~/bin/cpp 23 | - export PATH=~/bin:$PATH 24 | - ls -l ~/bin 25 | - echo $PATH 26 | - g++-7 --version 27 | - g++ --version 28 | script: 29 | - cd ~/ 30 | - git clone --depth=50 https://github.com/libretro/libretro-super 31 | - cd libretro-super/travis 32 | - ./build.sh 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.libretro 2 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common 2 | 3 | SOURCES_S := 4 | SOURCES_C := 5 | SOURCES_CXX := 6 | 7 | INCFLAGS := -I$(CORE_DIR) -I$(CORE_DIR)/libretro-common/include -I$(CORE_DIR)/libretro 8 | INCFLAGS += -I$(CORE_DIR)/x68k \ 9 | -I$(CORE_DIR)/fmgen \ 10 | -I$(CORE_DIR)/libretro \ 11 | -I$(CORE_DIR)/m68000 12 | 13 | SOURCES_C += \ 14 | $(CORE_DIR)/m68000/m68000.c 15 | 16 | ifeq ($(CYCLONE),1) 17 | FLAGS += -DHAVE_CYCLONE 18 | SOURCES_S += \ 19 | $(CORE_DIR)/m68000/cyclone.s 20 | else 21 | ifeq ($(C68K),1) 22 | FLAGS += -DHAVE_C68K -DC68K_NO_JUMP_TABLE 23 | SOURCES_C += \ 24 | $(CORE_DIR)/m68000/c68k/c68k.c \ 25 | $(CORE_DIR)/m68000/c68k/c68kexec.c 26 | else 27 | FLAGS += -DHAVE_MUSASHI 28 | SOURCES_C += \ 29 | $(CORE_DIR)/m68000/musashi/m68kcpu.c \ 30 | $(CORE_DIR)/m68000/musashi/m68kops.c \ 31 | $(CORE_DIR)/m68000/musashi/softfloat/softfloat.c 32 | endif 33 | endif 34 | 35 | SOURCES_C += \ 36 | $(CORE_DIR)/x68k/adpcm.c \ 37 | $(CORE_DIR)/x68k/bg.c \ 38 | $(CORE_DIR)/x68k/crtc.c \ 39 | $(CORE_DIR)/x68k/dmac.c \ 40 | $(CORE_DIR)/x68k/fdc.c \ 41 | $(CORE_DIR)/x68k/fdd.c \ 42 | $(CORE_DIR)/x68k/disk_d88.c \ 43 | $(CORE_DIR)/x68k/disk_dim.c \ 44 | $(CORE_DIR)/x68k/disk_xdf.c \ 45 | $(CORE_DIR)/x68k/gvram.c \ 46 | $(CORE_DIR)/x68k/ioc.c \ 47 | $(CORE_DIR)/x68k/irqh.c \ 48 | $(CORE_DIR)/x68k/mem_wrap.c \ 49 | $(CORE_DIR)/x68k/mercury.c \ 50 | $(CORE_DIR)/x68k/mfp.c \ 51 | $(CORE_DIR)/x68k/palette.c \ 52 | $(CORE_DIR)/x68k/midi.c \ 53 | $(CORE_DIR)/x68k/pia.c \ 54 | $(CORE_DIR)/x68k/rtc.c \ 55 | $(CORE_DIR)/x68k/sasi.c \ 56 | $(CORE_DIR)/x68k/scc.c \ 57 | $(CORE_DIR)/x68k/scsi.c \ 58 | $(CORE_DIR)/x68k/sram.c \ 59 | $(CORE_DIR)/x68k/sysport.c \ 60 | $(CORE_DIR)/x68k/tvram.c \ 61 | $(CORE_DIR)/libretro/joystick.c \ 62 | $(CORE_DIR)/libretro/keyboard.c \ 63 | $(CORE_DIR)/libretro/mouse.c \ 64 | $(CORE_DIR)/libretro/prop.c \ 65 | $(CORE_DIR)/libretro/timer.c \ 66 | $(CORE_DIR)/libretro/dswin.c \ 67 | $(CORE_DIR)/libretro/windraw.c \ 68 | $(CORE_DIR)/libretro/winui.c \ 69 | $(CORE_DIR)/libretro/dosio.c \ 70 | $(CORE_DIR)/libretro/fake.c \ 71 | $(CORE_DIR)/libretro/peace.c \ 72 | $(CORE_DIR)/libretro/state.c \ 73 | $(CORE_DIR)/libretro.c 74 | 75 | SOURCES_CXX += \ 76 | $(CORE_DIR)/fmgen/fmg_wrap.cpp \ 77 | $(CORE_DIR)/fmgen/fmgen.cpp \ 78 | $(CORE_DIR)/fmgen/fmtimer.cpp \ 79 | $(CORE_DIR)/fmgen/opm.cpp \ 80 | $(CORE_DIR)/fmgen/opna.cpp \ 81 | $(CORE_DIR)/fmgen/psg.cpp 82 | 83 | ifeq ($(USE_LIBRETRO_VFS),1) 84 | SOURCES_C += \ 85 | $(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \ 86 | $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \ 87 | $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ 88 | $(LIBRETRO_COMM_DIR)/compat/compat_snprintf.c \ 89 | $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \ 90 | $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \ 91 | $(LIBRETRO_COMM_DIR)/file/file_path.c \ 92 | $(LIBRETRO_COMM_DIR)/file/file_path_io.c \ 93 | $(LIBRETRO_COMM_DIR)/file/retro_dirent.c \ 94 | $(LIBRETRO_COMM_DIR)/streams/file_stream.c \ 95 | $(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.c \ 96 | $(LIBRETRO_COMM_DIR)/string/stdstring.c \ 97 | $(LIBRETRO_COMM_DIR)/time/rtime.c \ 98 | $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c 99 | ifdef _MSC_VER 100 | SOURCES_C += \ 101 | $(LIBRETRO_COMM_DIR)/compat/compat_snprintf.c 102 | endif 103 | endif 104 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | px68k-libretro 2 | 3 | forked from https://github.com/hissorii/px68k 4 | backported c68k core from https://github.com/kenyahiro/px68k/ 5 | (fork of https://github.com/hissorii/px68k using recent c68k yabause core to support X64 build) 6 | 7 | All credit goes to hissorii ( and kenyahiro for updating c68k core) . 8 | 9 | How to use : 10 | 11 | First create a 'keropi' folder in retroarch system directory. 12 | put the x68000 bios files in. 13 | 14 | Then launch emulator with some content (dim|zip|img|d88|88d|hdm|dup|2hd|xdf|hdf) 15 | 12 or joypad L2 to enter menu. 16 | Touroku key via ScrollLock key or Joypad R2 to enable MIDI music when preseed in Wolfteam games. 17 | 18 | 19 | You can launch content with: 20 | 21 | - retroarch -L px68k_libretro.so ./content.hdf 22 | 23 | - retroarch -L px68k_libretro.so ./content.xdf 24 | 25 | - retroarch -L px68k_libretro.so ./content.cmd 26 | (cmdfile is a text file contening cmd like "px68k /somewhere/software/x68000/content1.dim /somewhere/software/x68000/content2.dim") 27 | 28 | - retroarch -L sdlpx68k_libretro.so "px68k /somewhere/software/x68000/content1.dim /somewhere/software/x68000/content2.dim" 29 | 30 | - load retroarch , then load core and content from RA menu. 31 | 32 | ひっそりぃ(hissorii)/sakahi 33 | http://hissorii.blog45.fc2.com (ひっそりぃドットコム) 34 | http://emuhani.seesaa.net (えみゅはに - Emulator Hacking 日記) 35 | GitHub: https://github.com/hissorii/px68k 36 | iOS 版リポジトリ http://hissorii-com.appspot.com 37 | Twitter: @hissorii_com 38 | -------------------------------------------------------------------------------- /develop.txt: -------------------------------------------------------------------------------- 1 | ポータブルX68000エミュレータ 2 | PX68K ( Portable (x)keropi PRO-68K ) 3 | 4 | ソースを自分でコンパイルする際に役に立つかもしれないドキュメント 5 | 2014/07/04 ひっそりぃ 6 | 7 | ■開発環境について 8 | 9 | ・UNIX 系 10 | 11 | Ubuntu Linux 13.04 12 | SDL 1.2 13 | SDL_gfx 1.2-4 14 | 15 | ・PSP 16 | 17 | Mac OS X 10.9.2 18 | psptoolchain 19 | psplibraries (SDL 1.2.9) 20 | 21 | ・Android 22 | 23 | Mac OS X 10.9.2 24 | SDL2-2.0.3 (http://www.libsdl.org/ から入手) 25 | android-ndk-r9-linux-x86 (Android NDK) 26 | adt-bundle-linux-x86-20130729 (Android SDK) 27 | OpenGL ES 1.1 28 | 29 | ・Mac OS X 30 | 31 | Mac OS X 10.9.3 32 | SDL2-2.0.3 33 | SDL2_gfx-1.0.1 34 | Xcode 5.0.2 (GUIは使わずMakefileを用いてコマンドからmake) 35 | 36 | 37 | ■コンパイルについて 38 | 39 | ・UNIX 系 40 | 41 | ・SDL1.2 の場合 42 | 43 | $ make 44 | 45 | (ばりばりソース修正とコンパイルをする方は、make depend で 46 | あらかじめ Makefile に依存関係情報を付与してください) 47 | 48 | ・SDL2 の場合 49 | 50 | $ make SDL2=1 51 | 52 | 53 | ・PSP 54 | 55 | $ make -f Makefile.psp 56 | 57 | 58 | ・Android 59 | 60 | ※ SDL2-2.0.0 から SDL2-2.0.3 に変更します。(2014/4/1) 61 | 既に SDL2-2.0.0 環境を作成している方は以下の対処を行ってください。 62 | ・px68k/px68k-android/jni/SDL を 2.0.3 に更新 63 | ・Eclipse で 「Android SDK Manager」を実行し、 64 | 「Android3.1 (API 12)」の「SDK Platform」をインストール 65 | ・Eclipse で「Package Explorer」の「PX68K」アイコンを右クリックし、 66 | 「Propertiles」を選択。 67 | 「Android」をクリックし、「Android 3.1」を選択する。 68 | 69 | * px68k-android/jni/ にSDLという名前でSDL2-2.0.3のディレクトリをコピー 70 | するか、シンボリックリンクをはってください。 71 | 72 | * Android.mk の LOCAL_C_INCLUDES で、ndkのディレクトリを指定している 73 | 箇所は、自分の環境にあわせて書き直すこと 74 | 75 | * まずはnative codeのコンパイル 76 | 77 | px68k-android/jni/srcディレクトリに移動してから、 78 | $ /usr/local/android-ndk-r9/ndk-build (ndkを/usr/local/に入れた場合) 79 | 80 | * Eclipseへのプロジェクトの登録 81 | 82 | ・[File] -> [New] -> [Other] 83 | Android Project from Existing Code を選択して[Next] 84 | 85 | ・[Root Directory:]にandroid-projectのディレクトリを指定する 86 | (例) /home/hissorii/src/px68k/px68k-android 87 | 88 | ・[Projects:]の[New Project Name]のSDLActivityを二つともPX68Kに変更 89 | 90 | ・[Finish] をクリック 91 | 92 | * 次にapkの作成 93 | 94 | px68k-androidディレクトリに移動してから、 95 | $ ant release (またはant debug) 96 | 97 | で、px68k-android/bin/ に .apk ファイルが作成される 98 | 99 | README-android.txtに記載があるが、antを実行するためには、 100 | px68k-android/local.propatiesにsdkのパスを指定しておくこと。 101 | ひっそりぃの設定は以下。 102 | hissorii@ubuntu:~/src/px68k/px68k-android$ cat local.properties 103 | sdk.dir=/usr/local/adt-bundle-linux-x86-20130729/sdk 104 | 105 | antで作成したrelease版は.apkインストールではじかれるな。うーむ。 106 | 署名をしなければならないらしい。 107 | とりあえずeclipse上で[Run]->[Run]で作成される.apkだと大丈夫。 108 | 109 | 110 | ・Raspberry Pi (Raspbian) について 111 | 112 | ・自前でコンパイルしてください。 113 | 114 | ・インターネットにつながっている状態で、以下を実行してください。 115 | 116 | $ sudo apt-get install libsdl1.2-dev libsdl-gfx1.2-dev 117 | $ mkdir src ; cd src ; git clone http://github.com/hissorii/px68k 118 | $ cd px68k 119 | $ make 120 | 121 | ・GitHub 上のソースが更新された場合は、インターネットにつながっている 122 | 状態で、以下を実行してください。 123 | 124 | $ cd src/px68k 125 | $ git pull http://github.com/hissorii/px68k 126 | $ make clean ; make 127 | 128 | 129 | ・Mac OS X 版 130 | 131 | SDL2 はソースを入手してコンパイルします。 132 | SDL2 のソースを解凍したディレクトリに移動し、以下を実行します。 133 | 134 | $ ./configure CFLAGS="-m32 -O3" LDFLAGS=-m32 135 | $ make 136 | $ sudo make install 137 | 138 | 次にSDL2_gfx のコンパイルをします。 139 | 140 | $ ./configure CFLAGS="-m32 -O2" LDFLAGS=-m32 141 | $ make 142 | $ sudo make install 143 | 144 | ここまでで、/usr/local/ 以下に 32bit 版の SDL2, SDL2_gfx が 145 | インストールされます。 146 | 64bit の SDL アプリを作成したい場合は、これらのライブラリも 147 | 64bit で作り直す必要がありますのでご注意ください。 148 | 149 | 次に px68k のディレクトリに移動し、以下を実行してください。 150 | 151 | $ make SDL2=1 152 | 153 | 154 | 以上 155 | -------------------------------------------------------------------------------- /doc/kero_src.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/doc/kero_src.txt -------------------------------------------------------------------------------- /fmgen/fmg_wrap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/fmg_wrap.cpp -------------------------------------------------------------------------------- /fmgen/fmg_wrap.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN68_OPM_FMGEN_H 2 | #define _WIN68_OPM_FMGEN_H 3 | 4 | #include 5 | 6 | int OPM_Init(int clock); 7 | void OPM_Cleanup(void); 8 | void OPM_Reset(void); 9 | void OPM_Update(int16_t *buffer, int length, uint8_t *pbsp, uint8_t *pbep); 10 | void FASTCALL OPM_Write(uint32_t r, uint8_t v); 11 | uint8_t FASTCALL OPM_Read(void); 12 | void FASTCALL OPM_Timer(uint32_t step); 13 | void OPM_SetVolume(uint8_t vol); 14 | int OPM_StateAction(StateMem *sm, int load, int data_only); 15 | 16 | int M288_Init(int clock, const char* path); 17 | void M288_Cleanup(void); 18 | void M288_Reset(void); 19 | void M288_Update(int16_t *buffer, size_t length); 20 | void FASTCALL M288_Write(uint32_t r, uint8_t v); 21 | uint8_t FASTCALL M288_Read(uint16_t a); 22 | void FASTCALL M288_Timer(uint32_t step); 23 | void M288_SetVolume(uint8_t vol); 24 | void M288_RomeoOut(unsigned int delay); 25 | 26 | #endif /* _WIN68_OPM_FMGEN_H */ 27 | -------------------------------------------------------------------------------- /fmgen/fmgen.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/fmgen.cpp -------------------------------------------------------------------------------- /fmgen/fmgen.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/fmgen.h -------------------------------------------------------------------------------- /fmgen/fmgeninl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/fmgeninl.h -------------------------------------------------------------------------------- /fmgen/fmtimer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/fmtimer.cpp -------------------------------------------------------------------------------- /fmgen/fmtimer.h: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // FM sound generator common timer module 3 | // Copyright (C) cisc 1998, 2000. 4 | // --------------------------------------------------------------------------- 5 | // $fmgen-Id: fmtimer.h,v 1.2 2003/04/22 13:12:53 cisc Exp $ 6 | 7 | #ifndef FM_TIMER_H 8 | #define FM_TIMER_H 9 | 10 | #include 11 | 12 | namespace FM 13 | { 14 | class Timer 15 | { 16 | public: 17 | void Reset(); 18 | bool Count(int32_t us); 19 | int StateAction(StateMem *st, int load, int data_only); 20 | 21 | protected: 22 | virtual void SetStatus(uint32_t bit) = 0; 23 | virtual void ResetStatus(uint32_t bit) = 0; 24 | 25 | void SetTimerBase(uint32_t clock); 26 | void SetTimerA(uint32_t addr, uint32_t data); 27 | void SetTimerB(uint32_t data); 28 | void SetTimerControl(uint32_t data); 29 | 30 | uint8_t status; 31 | uint8_t regtc; 32 | 33 | private: 34 | virtual void TimerA() {} 35 | 36 | uint8_t regta[2]; 37 | 38 | int32_t timera, timera_count; 39 | int32_t timerb, timerb_count; 40 | int32_t timer_step; 41 | }; 42 | 43 | inline void Timer::Reset() 44 | { 45 | timera_count = 0; 46 | timerb_count = 0; 47 | } 48 | 49 | } // namespace FM 50 | 51 | #endif // FM_TIMER_H 52 | -------------------------------------------------------------------------------- /fmgen/misc.h: -------------------------------------------------------------------------------- 1 | #ifndef MISC_H 2 | #define MISC_H 3 | 4 | #define FMGEN_MAX(x, y) (((x) > (y)) ? (x) : (y)) 5 | #define FMGEN_MIN(x, y) (((x) < (y)) ? (x) : (y)) 6 | 7 | inline int Limit(int v, int max, int min) 8 | { 9 | return v > max ? max : (v < min ? min : v); 10 | } 11 | 12 | #endif /* MISC_H */ 13 | 14 | -------------------------------------------------------------------------------- /fmgen/opm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/opm.cpp -------------------------------------------------------------------------------- /fmgen/opm.h: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // OPM-like Sound Generator 3 | // Copyright (C) cisc 1998, 2003. 4 | // --------------------------------------------------------------------------- 5 | 6 | #ifndef FM_OPM_H 7 | #define FM_OPM_H 8 | 9 | #include 10 | 11 | #include "fmgen.h" 12 | #include "fmtimer.h" 13 | #include "psg.h" 14 | 15 | namespace FM 16 | { 17 | // YM2151(OPM) ---------------------------------------------------- 18 | class OPM : public Timer 19 | { 20 | public: 21 | OPM(); 22 | virtual ~OPM() {} 23 | 24 | bool Init(uint32_t c, uint32_t r); 25 | bool SetRate(uint32_t c, uint32_t r); 26 | void Reset(); 27 | 28 | void SetReg(uint32_t addr, uint32_t data); 29 | uint32_t GetReg(uint32_t addr); 30 | uint32_t ReadStatus() { return status & 0x03; } 31 | 32 | void Mix(int16_t* buffer, int nsamples, uint8_t* pbsp, uint8_t* pbep); 33 | 34 | void SetVolume(int db); 35 | void SetChannelMask(uint32_t mask); 36 | 37 | int StateAction(StateMem *sm, int load, int data_only); 38 | 39 | private: 40 | virtual void Intr(bool) {} 41 | 42 | private: 43 | enum 44 | { 45 | OPM_LFOENTS = 512, 46 | }; 47 | 48 | void SetStatus(uint32_t bit); 49 | void ResetStatus(uint32_t bit); 50 | void SetParameter(uint32_t addr, uint32_t data); 51 | void TimerA(); 52 | void RebuildTimeTable(); 53 | void MixSub(int activech, ISample**); 54 | void MixSubL(int activech, ISample**); 55 | void LFO(); 56 | uint32_t Noise(); 57 | 58 | int fmvolume; 59 | 60 | uint32_t clock; 61 | uint32_t rate; 62 | 63 | uint32_t pmd; 64 | uint32_t amd; 65 | uint32_t lfocount; 66 | uint32_t lfodcount; 67 | 68 | uint32_t lfo_count_; 69 | uint32_t lfo_count_diff_; 70 | uint32_t lfo_step_; 71 | uint32_t lfo_count_prev_; 72 | 73 | uint32_t lfowaveform; 74 | uint32_t rateratio; 75 | uint32_t noise; 76 | int32_t noisecount; 77 | uint32_t noisedelta; 78 | 79 | uint8_t lfofreq; 80 | uint8_t status; 81 | uint8_t reg01; 82 | 83 | uint8_t kc[8]; 84 | uint8_t kf[8]; 85 | uint8_t pan[8]; 86 | 87 | Channel4 ch[8]; 88 | Chip chip; 89 | 90 | static void BuildLFOTable(); 91 | static int amtable[4][OPM_LFOENTS]; 92 | static int pmtable[4][OPM_LFOENTS]; 93 | }; 94 | } 95 | 96 | #endif // FM_OPM_H 97 | -------------------------------------------------------------------------------- /fmgen/opna.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/opna.cpp -------------------------------------------------------------------------------- /fmgen/opna.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/opna.h -------------------------------------------------------------------------------- /fmgen/psg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/psg.cpp -------------------------------------------------------------------------------- /fmgen/psg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/psg.h -------------------------------------------------------------------------------- /fmgen/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/px68k-libretro/9dfa6abc25ddd6e597790f7a535cd0a1d7f9c385/fmgen/readme.txt -------------------------------------------------------------------------------- /libretro-common/compat/compat_posix_string.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_posix_string.c). 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 | #include 24 | 25 | #include 26 | 27 | #ifdef _WIN32 28 | 29 | #undef strcasecmp 30 | #undef strdup 31 | #undef isblank 32 | #undef strtok_r 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | int retro_strcasecmp__(const char *a, const char *b) 41 | { 42 | while (*a && *b) 43 | { 44 | int a_ = tolower(*a); 45 | int b_ = tolower(*b); 46 | 47 | if (a_ != b_) 48 | return a_ - b_; 49 | 50 | a++; 51 | b++; 52 | } 53 | 54 | return tolower(*a) - tolower(*b); 55 | } 56 | 57 | char *retro_strdup__(const char *orig) 58 | { 59 | size_t len = strlen(orig) + 1; 60 | char *ret = (char*)malloc(len); 61 | if (!ret) 62 | return NULL; 63 | 64 | strlcpy(ret, orig, len); 65 | return ret; 66 | } 67 | 68 | int retro_isblank__(int c) 69 | { 70 | return (c == ' ') || (c == '\t'); 71 | } 72 | 73 | char *retro_strtok_r__(char *str, const char *delim, char **saveptr) 74 | { 75 | char *first = NULL; 76 | if (!saveptr || !delim) 77 | return NULL; 78 | 79 | if (str) 80 | *saveptr = str; 81 | 82 | do 83 | { 84 | char *ptr = NULL; 85 | first = *saveptr; 86 | while (*first && strchr(delim, *first)) 87 | *first++ = '\0'; 88 | 89 | if (*first == '\0') 90 | return NULL; 91 | 92 | ptr = first + 1; 93 | 94 | while (*ptr && !strchr(delim, *ptr)) 95 | ptr++; 96 | 97 | *saveptr = ptr + (*ptr ? 1 : 0); 98 | *ptr = '\0'; 99 | } while (strlen(first) == 0); 100 | 101 | return first; 102 | } 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_snprintf.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_snprintf.c). 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 | /* THIS FILE HAS NOT BEEN VALIDATED ON PLATFORMS BESIDES MSVC */ 24 | #ifdef _MSC_VER 25 | 26 | #include 27 | #include 28 | 29 | #if _MSC_VER < 1800 30 | #define va_copy(dst, src) ((dst) = (src)) 31 | #endif 32 | 33 | #if _MSC_VER < 1300 34 | #define _vscprintf c89_vscprintf_retro__ 35 | 36 | static int c89_vscprintf_retro__(const char *fmt, va_list pargs) 37 | { 38 | int retval; 39 | va_list argcopy; 40 | va_copy(argcopy, pargs); 41 | retval = vsnprintf(NULL, 0, fmt, argcopy); 42 | va_end(argcopy); 43 | return retval; 44 | } 45 | #endif 46 | 47 | /* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */ 48 | 49 | int c99_vsnprintf_retro__(char *s, size_t len, const char *fmt, va_list ap) 50 | { 51 | int count = -1; 52 | 53 | if (len != 0) 54 | { 55 | #if (_MSC_VER <= 1310) 56 | count = _vsnprintf(s, len - 1, fmt, ap); 57 | #else 58 | count = _vsnprintf_s(s, len, len - 1, fmt, ap); 59 | #endif 60 | } 61 | 62 | if (count == -1) 63 | count = _vscprintf(fmt, ap); 64 | 65 | /* there was no room for a NULL, so truncate the last character */ 66 | if (count == len && len) 67 | s[len - 1] = '\0'; 68 | 69 | return count; 70 | } 71 | 72 | int c99_snprintf_retro__(char *s, size_t len, const char *fmt, ...) 73 | { 74 | int count; 75 | va_list ap; 76 | 77 | va_start(ap, fmt); 78 | count = c99_vsnprintf_retro__(s, len, fmt, ap); 79 | va_end(ap); 80 | 81 | return count; 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_strcasestr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_strcasestr.c). 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 | #include 24 | 25 | #include 26 | 27 | /* Pretty much strncasecmp. */ 28 | static int casencmp(const char *a, const char *b, size_t n) 29 | { 30 | size_t i; 31 | 32 | for (i = 0; i < n; i++) 33 | { 34 | int a_lower = tolower(a[i]); 35 | int b_lower = tolower(b[i]); 36 | if (a_lower != b_lower) 37 | return a_lower - b_lower; 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | char *strcasestr_retro__(const char *haystack, const char *needle) 44 | { 45 | size_t i, search_off; 46 | size_t hay_len = strlen(haystack); 47 | size_t needle_len = strlen(needle); 48 | 49 | if (needle_len > hay_len) 50 | return NULL; 51 | 52 | search_off = hay_len - needle_len; 53 | for (i = 0; i <= search_off; i++) 54 | if (!casencmp(haystack + i, needle, needle_len)) 55 | return (char*)haystack + i; 56 | 57 | return NULL; 58 | } 59 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_strl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_strl.c). 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 | #include 24 | #include 25 | 26 | #include 27 | 28 | /* Implementation of strlcpy()/strlcat() based on OpenBSD. */ 29 | 30 | #ifndef __MACH__ 31 | 32 | size_t strlcpy(char *dest, const char *source, size_t size) 33 | { 34 | size_t src_size = 0; 35 | size_t n = size; 36 | 37 | if (n) 38 | while (--n && (*dest++ = *source++)) src_size++; 39 | 40 | if (!n) 41 | { 42 | if (size) *dest = '\0'; 43 | while (*source++) src_size++; 44 | } 45 | 46 | return src_size; 47 | } 48 | 49 | size_t strlcat(char *dest, const char *source, size_t size) 50 | { 51 | size_t len = strlen(dest); 52 | 53 | dest += len; 54 | 55 | if (len > size) 56 | size = 0; 57 | else 58 | size -= len; 59 | 60 | return len + strlcpy(dest, source, size); 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /libretro-common/compat/fopen_utf8.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (fopen_utf8.c). 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 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) 29 | #ifndef LEGACY_WIN32 30 | #define LEGACY_WIN32 31 | #endif 32 | #endif 33 | 34 | #ifdef _WIN32 35 | #undef fopen 36 | 37 | void *fopen_utf8(const char * filename, const char * mode) 38 | { 39 | #if defined(LEGACY_WIN32) 40 | char * filename_local = utf8_to_local_string_alloc(filename); 41 | if (filename_local) 42 | { 43 | FILE *ret = fopen(filename_local, mode); 44 | free(filename_local); 45 | return ret; 46 | } 47 | #else 48 | wchar_t * filename_w = utf8_to_utf16_string_alloc(filename); 49 | if (filename_w) 50 | { 51 | FILE *ret = NULL; 52 | wchar_t *mode_w = utf8_to_utf16_string_alloc(mode); 53 | if (mode_w) 54 | { 55 | ret = _wfopen(filename_w, mode_w); 56 | free(mode_w); 57 | } 58 | free(filename_w); 59 | return ret; 60 | } 61 | #endif 62 | return NULL; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /libretro-common/file/file_path_io.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_path_io.c). 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 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #define VFS_FRONTEND 37 | #include 38 | 39 | #ifdef _WIN32 40 | #include 41 | #else 42 | #include /* stat() is defined here */ 43 | #endif 44 | 45 | /* TODO/FIXME - globals */ 46 | static retro_vfs_stat_t path_stat_cb = retro_vfs_stat_impl; 47 | static retro_vfs_mkdir_t path_mkdir_cb = retro_vfs_mkdir_impl; 48 | 49 | void path_vfs_init(const struct retro_vfs_interface_info* vfs_info) 50 | { 51 | const struct retro_vfs_interface* 52 | vfs_iface = vfs_info->iface; 53 | 54 | path_stat_cb = retro_vfs_stat_impl; 55 | path_mkdir_cb = retro_vfs_mkdir_impl; 56 | 57 | if (vfs_info->required_interface_version < PATH_REQUIRED_VFS_VERSION || !vfs_iface) 58 | return; 59 | 60 | path_stat_cb = vfs_iface->stat; 61 | path_mkdir_cb = vfs_iface->mkdir; 62 | } 63 | 64 | int path_stat(const char *path) 65 | { 66 | return path_stat_cb(path, NULL); 67 | } 68 | 69 | /** 70 | * path_is_directory: 71 | * @path : path 72 | * 73 | * Checks if path is a directory. 74 | * 75 | * @return true if path is a directory, otherwise false. 76 | */ 77 | bool path_is_directory(const char *path) 78 | { 79 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_DIRECTORY) != 0; 80 | } 81 | 82 | bool path_is_character_special(const char *path) 83 | { 84 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_CHARACTER_SPECIAL) != 0; 85 | } 86 | 87 | bool path_is_valid(const char *path) 88 | { 89 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_VALID) != 0; 90 | } 91 | 92 | int32_t path_get_size(const char *path) 93 | { 94 | int32_t filesize = 0; 95 | if (path_stat_cb(path, &filesize) != 0) 96 | return filesize; 97 | 98 | return -1; 99 | } 100 | 101 | /** 102 | * path_mkdir: 103 | * @dir : directory 104 | * 105 | * Create directory on filesystem. 106 | * 107 | * Recursive function. 108 | * 109 | * @return true if directory could be created, otherwise false. 110 | **/ 111 | bool path_mkdir(const char *dir) 112 | { 113 | bool norecurse = false; 114 | char *basedir = NULL; 115 | 116 | if (!(dir && *dir)) 117 | return false; 118 | 119 | /* Use heap. Real chance of stack 120 | * overflow if we recurse too hard. */ 121 | if (!(basedir = strdup(dir))) 122 | return false; 123 | 124 | path_parent_dir(basedir, strlen(basedir)); 125 | 126 | if (!*basedir || !strcmp(basedir, dir)) 127 | { 128 | free(basedir); 129 | return false; 130 | } 131 | 132 | if ( path_is_directory(basedir) 133 | || path_mkdir(basedir)) 134 | norecurse = true; 135 | 136 | free(basedir); 137 | 138 | if (norecurse) 139 | { 140 | int ret = path_mkdir_cb(dir); 141 | 142 | /* Don't treat this as an error. */ 143 | if (ret == -2 && path_is_directory(dir)) 144 | return true; 145 | else if (ret == 0) 146 | return true; 147 | } 148 | return false; 149 | } 150 | -------------------------------------------------------------------------------- /libretro-common/file/retro_dirent.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_dirent.c). 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 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #define VFS_FRONTEND 32 | #include 33 | 34 | /* TODO/FIXME - static globals */ 35 | static retro_vfs_opendir_t dirent_opendir_cb = NULL; 36 | static retro_vfs_readdir_t dirent_readdir_cb = NULL; 37 | static retro_vfs_dirent_get_name_t dirent_dirent_get_name_cb = NULL; 38 | static retro_vfs_dirent_is_dir_t dirent_dirent_is_dir_cb = NULL; 39 | static retro_vfs_closedir_t dirent_closedir_cb = NULL; 40 | 41 | void dirent_vfs_init(const struct retro_vfs_interface_info* vfs_info) 42 | { 43 | const struct retro_vfs_interface* vfs_iface; 44 | 45 | dirent_opendir_cb = NULL; 46 | dirent_readdir_cb = NULL; 47 | dirent_dirent_get_name_cb = NULL; 48 | dirent_dirent_is_dir_cb = NULL; 49 | dirent_closedir_cb = NULL; 50 | 51 | vfs_iface = vfs_info->iface; 52 | 53 | if ( 54 | vfs_info->required_interface_version < DIRENT_REQUIRED_VFS_VERSION || 55 | !vfs_iface) 56 | return; 57 | 58 | dirent_opendir_cb = vfs_iface->opendir; 59 | dirent_readdir_cb = vfs_iface->readdir; 60 | dirent_dirent_get_name_cb = vfs_iface->dirent_get_name; 61 | dirent_dirent_is_dir_cb = vfs_iface->dirent_is_dir; 62 | dirent_closedir_cb = vfs_iface->closedir; 63 | } 64 | 65 | struct RDIR *retro_opendir_include_hidden( 66 | const char *name, bool include_hidden) 67 | { 68 | if (dirent_opendir_cb) 69 | return (struct RDIR *)dirent_opendir_cb(name, include_hidden); 70 | return (struct RDIR *)retro_vfs_opendir_impl(name, include_hidden); 71 | } 72 | 73 | struct RDIR *retro_opendir(const char *name) 74 | { 75 | return retro_opendir_include_hidden(name, false); 76 | } 77 | 78 | bool retro_dirent_error(struct RDIR *rdir) 79 | { 80 | /* Left for compatibility */ 81 | return false; 82 | } 83 | 84 | int retro_readdir(struct RDIR *rdir) 85 | { 86 | if (dirent_readdir_cb) 87 | return dirent_readdir_cb((struct retro_vfs_dir_handle *)rdir); 88 | return retro_vfs_readdir_impl((struct retro_vfs_dir_handle *)rdir); 89 | } 90 | 91 | const char *retro_dirent_get_name(struct RDIR *rdir) 92 | { 93 | if (dirent_dirent_get_name_cb) 94 | return dirent_dirent_get_name_cb((struct retro_vfs_dir_handle *)rdir); 95 | return retro_vfs_dirent_get_name_impl((struct retro_vfs_dir_handle *)rdir); 96 | } 97 | 98 | /** 99 | * 100 | * retro_dirent_is_dir: 101 | * @rdir : pointer to the directory entry. 102 | * @unused : deprecated, included for compatibility reasons, pass NULL 103 | * 104 | * Is the directory listing entry a directory? 105 | * 106 | * Returns: true if directory listing entry is 107 | * a directory, false if not. 108 | */ 109 | bool retro_dirent_is_dir(struct RDIR *rdir, const char *unused) 110 | { 111 | if (dirent_dirent_is_dir_cb) 112 | return dirent_dirent_is_dir_cb((struct retro_vfs_dir_handle *)rdir); 113 | return retro_vfs_dirent_is_dir_impl((struct retro_vfs_dir_handle *)rdir); 114 | } 115 | 116 | void retro_closedir(struct RDIR *rdir) 117 | { 118 | if (dirent_closedir_cb) 119 | dirent_closedir_cb((struct retro_vfs_dir_handle *)rdir); 120 | else 121 | retro_vfs_closedir_impl((struct retro_vfs_dir_handle *)rdir); 122 | } 123 | -------------------------------------------------------------------------------- /libretro-common/include/boolean.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (boolean.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_BOOLEAN_H 24 | #define __LIBRETRO_SDK_BOOLEAN_H 25 | 26 | #ifndef __cplusplus 27 | 28 | #if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3) 29 | /* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */ 30 | #define bool unsigned char 31 | #define true 1 32 | #define false 0 33 | #else 34 | #include 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libretro-common/include/compat/fopen_utf8.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (fopen_utf8.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_COMPAT_FOPEN_UTF8_H 24 | #define __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H 25 | 26 | #ifdef _WIN32 27 | /* Defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ 28 | /* TODO: enable */ 29 | /* #define fopen (use fopen_utf8 instead) */ 30 | void *fopen_utf8(const char * filename, const char * mode); 31 | #else 32 | #define fopen_utf8 fopen 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /libretro-common/include/compat/msvc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (msvc.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_COMPAT_MSVC_H 24 | #define __LIBRETRO_SDK_COMPAT_MSVC_H 25 | 26 | #ifdef _MSC_VER 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /* Pre-MSVC 2015 compilers don't implement snprintf, vsnprintf in a cross-platform manner. */ 33 | #if _MSC_VER < 1900 34 | #include 35 | #include 36 | #include 37 | 38 | #ifndef snprintf 39 | #define snprintf c99_snprintf_retro__ 40 | #endif 41 | int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); 42 | 43 | #ifndef vsnprintf 44 | #define vsnprintf c99_vsnprintf_retro__ 45 | #endif 46 | int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap); 47 | #endif 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #undef UNICODE /* Do not bother with UNICODE at this time. */ 54 | #include 55 | #include 56 | 57 | #define _USE_MATH_DEFINES 58 | #include 59 | 60 | /* Python headers defines ssize_t and sets HAVE_SSIZE_T. 61 | * Cannot duplicate these efforts. 62 | */ 63 | #ifndef HAVE_SSIZE_T 64 | #if defined(_WIN64) 65 | typedef __int64 ssize_t; 66 | #elif defined(_WIN32) 67 | typedef int ssize_t; 68 | #endif 69 | #endif 70 | 71 | #define mkdir(dirname, unused) _mkdir(dirname) 72 | #define strtoull _strtoui64 73 | #undef strcasecmp 74 | #define strcasecmp _stricmp 75 | #undef strncasecmp 76 | #define strncasecmp _strnicmp 77 | 78 | /* Disable some of the annoying warnings. */ 79 | #pragma warning(disable : 4800) 80 | #pragma warning(disable : 4805) 81 | #pragma warning(disable : 4244) 82 | #pragma warning(disable : 4305) 83 | #pragma warning(disable : 4146) 84 | #pragma warning(disable : 4267) 85 | #pragma warning(disable : 4723) 86 | #pragma warning(disable : 4996) 87 | 88 | /* roundf and va_copy is available since MSVC 2013 */ 89 | #if _MSC_VER < 1800 90 | #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) 91 | #define va_copy(x, y) ((x) = (y)) 92 | #endif 93 | 94 | #if _MSC_VER <= 1310 95 | #ifndef __cplusplus 96 | /* VC6 math.h doesn't define some functions when in C mode. 97 | * Trying to define a prototype gives "undefined reference". 98 | * But providing an implementation then gives "function already has body". 99 | * So the equivalent of the implementations from math.h are used as 100 | * defines here instead, and it seems to work. 101 | */ 102 | #define cosf(x) ((float)cos((double)x)) 103 | #define powf(x, y) ((float)pow((double)x, (double)y)) 104 | #define sinf(x) ((float)sin((double)x)) 105 | #define ceilf(x) ((float)ceil((double)x)) 106 | #define floorf(x) ((float)floor((double)x)) 107 | #define sqrtf(x) ((float)sqrt((double)x)) 108 | #define fabsf(x) ((float)fabs((double)(x))) 109 | #endif 110 | 111 | #ifndef _strtoui64 112 | #define _strtoui64(x, y, z) (_atoi64(x)) 113 | #endif 114 | 115 | #endif 116 | 117 | #ifndef PATH_MAX 118 | #define PATH_MAX _MAX_PATH 119 | #endif 120 | 121 | #ifndef SIZE_MAX 122 | #define SIZE_MAX _UI32_MAX 123 | #endif 124 | 125 | #endif 126 | #endif 127 | -------------------------------------------------------------------------------- /libretro-common/include/compat/posix_string.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (posix_string.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_COMPAT_POSIX_STRING_H 24 | #define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H 25 | 26 | #include 27 | 28 | /** 29 | * @file posix_string.h 30 | * 31 | * Portable reimplementations of various string functions 32 | * that are normally provided by libc or POSIX. 33 | */ 34 | 35 | #ifdef _MSC_VER 36 | #include 37 | #endif 38 | 39 | RETRO_BEGIN_DECLS 40 | 41 | #if defined(_WIN32) || defined(DOXYGEN) 42 | #undef strtok_r 43 | #define strtok_r(str, delim, saveptr) retro_strtok_r__(str, delim, saveptr) 44 | 45 | /** 46 | * Portable reimplementation of \c strtok_r(). 47 | * The original function will be used if it's available. 48 | * 49 | * @see https://man7.org/linux/man-pages/man3/strtok.3.html 50 | */ 51 | char *strtok_r(char *str, const char *delim, char **saveptr); 52 | #endif 53 | 54 | #if defined(_MSC_VER) || defined(DOXYGEN) 55 | #undef strcasecmp 56 | #undef strdup 57 | 58 | #define strcasecmp(a, b) retro_strcasecmp__(a, b) 59 | #define strdup(orig) retro_strdup__(orig) 60 | /** 61 | * Portable reimplementation of \c strcasecmp(). 62 | * The original function will be used if it's available. 63 | * 64 | * @see https://man7.org/linux/man-pages/man3/strcasecmp.3.html 65 | */ 66 | int strcasecmp(const char *a, const char *b); 67 | 68 | /** 69 | * Portable reimplementation of \c strdup(). 70 | * The original function will be used if it's available. 71 | * 72 | * @see https://man7.org/linux/man-pages/man3/strdup.3.html 73 | */ 74 | char *strdup(const char *orig); 75 | 76 | /* isblank is available since MSVC 2013 */ 77 | #if _MSC_VER < 1800 78 | #undef isblank 79 | #define isblank(c) retro_isblank__(c) 80 | /** 81 | * Portable reimplementation of \c isblank(). 82 | * The original function will be used if it's available. 83 | * 84 | * @see https://en.cppreference.com/w/c/string/byte/isblank 85 | */ 86 | int isblank(int c); 87 | #endif 88 | 89 | #endif 90 | 91 | RETRO_END_DECLS 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /libretro-common/include/compat/strcasestr.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (strcasestr.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_COMPAT_STRCASESTR_H 24 | #define __LIBRETRO_SDK_COMPAT_STRCASESTR_H 25 | 26 | #include 27 | 28 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 29 | #include "../../../config.h" 30 | #endif 31 | 32 | #ifndef HAVE_STRCASESTR 33 | 34 | #include 35 | 36 | RETRO_BEGIN_DECLS 37 | 38 | /* Avoid possible naming collisions during link 39 | * since we prefer to use the actual name. */ 40 | #define strcasestr(haystack, needle) strcasestr_retro__(haystack, needle) 41 | 42 | /** 43 | * Portable reimplementation of \c strcasestr(3). 44 | * If the original function is available 45 | * (as determined by the presence of \c HAVE_STRCASESTR), 46 | * it will be used instead. 47 | * 48 | * @see https://man7.org/linux/man-pages/man3/strstr.3.html 49 | */ 50 | char *strcasestr(const char *haystack, const char *needle); 51 | 52 | RETRO_END_DECLS 53 | 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libretro-common/include/compat/strl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (strl.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_COMPAT_STRL_H 24 | #define __LIBRETRO_SDK_COMPAT_STRL_H 25 | 26 | /** 27 | * @file strl.h 28 | * 29 | * Portable implementation of \c strlcpy(3) and \c strlcat(3). 30 | * If these functions are available on the target platform, 31 | * then the originals should be imported instead. 32 | * 33 | * @see https://linux.die.net/man/3/strlcpy 34 | */ 35 | #include 36 | #include 37 | 38 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 39 | #include "../../../config.h" 40 | #endif 41 | 42 | #include 43 | 44 | RETRO_BEGIN_DECLS 45 | 46 | #ifdef __MACH__ 47 | #ifndef HAVE_STRL 48 | #define HAVE_STRL 49 | #endif 50 | #endif 51 | 52 | #ifndef HAVE_STRL 53 | /* Avoid possible naming collisions during link since 54 | * we prefer to use the actual name. */ 55 | #define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size) 56 | 57 | #define strlcat(dst, src, size) strlcat_retro__(dst, src, size) 58 | 59 | /** 60 | * @brief Portable implementation of \c strlcpy(3). 61 | * @see https://linux.die.net/man/3/strlcpy 62 | */ 63 | size_t strlcpy(char *dest, const char *source, size_t size); 64 | 65 | /** 66 | * @brief Portable implementation of \c strlcat(3). 67 | * @see https://linux.die.net/man/3/strlcpy 68 | */ 69 | size_t strlcat(char *dest, const char *source, size_t size); 70 | 71 | #endif 72 | 73 | /** 74 | * A version of \c strndup(3) that guarantees the result will be null-terminated. 75 | * 76 | * @param s The string to duplicate. 77 | * @param n The maximum number of characters to copy from \c s. 78 | * The result will allocate one more byte than this value. 79 | * @return Pointer to the cloned string. 80 | * Must be freed with \c free(). 81 | */ 82 | char *strldup(const char *s, size_t n); 83 | 84 | RETRO_END_DECLS 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /libretro-common/include/encodings/utf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (utf.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_ENCODINGS_UTF_H 24 | #define _LIBRETRO_ENCODINGS_UTF_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | RETRO_BEGIN_DECLS 34 | 35 | enum CodePage 36 | { 37 | CODEPAGE_LOCAL = 0, /* CP_ACP */ 38 | CODEPAGE_UTF8 = 65001 /* CP_UTF8 */ 39 | }; 40 | 41 | /** 42 | * utf8_conv_utf32: 43 | * 44 | * Simple implementation. Assumes the sequence is 45 | * properly synchronized and terminated. 46 | **/ 47 | size_t utf8_conv_utf32(uint32_t *out, size_t out_chars, 48 | const char *in, size_t in_size); 49 | 50 | /** 51 | * utf16_conv_utf8: 52 | * 53 | * Leaf function. 54 | **/ 55 | bool utf16_conv_utf8(uint8_t *out, size_t *out_chars, 56 | const uint16_t *in, size_t in_size); 57 | 58 | /** 59 | * utf8len: 60 | * 61 | * Leaf function. 62 | **/ 63 | size_t utf8len(const char *string); 64 | 65 | /** 66 | * utf8cpy: 67 | * 68 | * Acts mostly like strlcpy. 69 | * 70 | * Copies the given number of UTF-8 characters, 71 | * but at most @d_len bytes. 72 | * 73 | * Always NULL terminates. Does not copy half a character. 74 | * @s is assumed valid UTF-8. 75 | * Use only if @chars is considerably less than @d_len. 76 | * 77 | * Hidden non-leaf function cost: 78 | * - Calls memcpy 79 | * 80 | * @return Number of bytes. 81 | **/ 82 | size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars); 83 | 84 | /** 85 | * utf8skip: 86 | * 87 | * Leaf function 88 | **/ 89 | const char *utf8skip(const char *str, size_t chars); 90 | 91 | /** 92 | * utf8_walk: 93 | * 94 | * Does not validate the input. 95 | * 96 | * Leaf function. 97 | * 98 | * @return Returns garbage if it's not UTF-8. 99 | **/ 100 | uint32_t utf8_walk(const char **string); 101 | 102 | /** 103 | * utf16_to_char_string: 104 | **/ 105 | bool utf16_to_char_string(const uint16_t *in, char *s, size_t len); 106 | 107 | /** 108 | * utf8_to_local_string_alloc: 109 | * 110 | * @return Returned pointer MUST be freed by the caller if non-NULL. 111 | **/ 112 | char *utf8_to_local_string_alloc(const char *str); 113 | 114 | /** 115 | * local_to_utf8_string_alloc: 116 | * 117 | * @return Returned pointer MUST be freed by the caller if non-NULL. 118 | **/ 119 | char *local_to_utf8_string_alloc(const char *str); 120 | 121 | /** 122 | * utf8_to_utf16_string_alloc: 123 | * 124 | * @return Returned pointer MUST be freed by the caller if non-NULL. 125 | **/ 126 | wchar_t *utf8_to_utf16_string_alloc(const char *str); 127 | 128 | /** 129 | * utf16_to_utf8_string_alloc: 130 | * 131 | * @return Returned pointer MUST be freed by the caller if non-NULL. 132 | **/ 133 | char *utf16_to_utf8_string_alloc(const wchar_t *str); 134 | 135 | RETRO_END_DECLS 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /libretro-common/include/libretro_gskit_ps2.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this libretro API header (libretro_d3d.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 9 | * "Software"), 10 | * to deal in the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 12 | * and to permit persons to whom the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef LIBRETRO_GSKIT_PS2_H_ 28 | #define LIBRETRO_GSKIT_PS2_H_ 29 | 30 | #include "libretro.h" 31 | 32 | #if defined(PS2) 33 | 34 | #include 35 | 36 | #define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 2 37 | 38 | struct retro_hw_ps2_insets 39 | { 40 | float top; 41 | float left; 42 | float bottom; 43 | float right; 44 | }; 45 | 46 | #define empty_ps2_insets (struct retro_hw_ps2_insets){0.f, 0.f, 0.f, 0.f} 47 | 48 | struct retro_hw_render_interface_gskit_ps2 49 | { 50 | /* Must be set to RETRO_HW_RENDER_INTERFACE_GSKIT_PS2. */ 51 | enum retro_hw_render_interface_type interface_type; 52 | /* Must be set to RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION. */ 53 | unsigned interface_version; 54 | 55 | /* Opaque handle to the GSKit_PS2 backend in the frontend 56 | * which must be passed along to all function pointers 57 | * in this interface. 58 | */ 59 | GSTEXTURE *coreTexture; 60 | struct retro_hw_ps2_insets padding; 61 | }; 62 | typedef struct retro_hw_render_interface_gskit_ps2 RETRO_HW_RENDER_INTEFACE_GSKIT_PS2; 63 | 64 | #endif 65 | 66 | #endif /* LIBRETRO_GSKIT_PS2_H_ */ 67 | -------------------------------------------------------------------------------- /libretro-common/include/memalign.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (memalign.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_MEMALIGN_H 24 | #define _LIBRETRO_MEMALIGN_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | RETRO_BEGIN_DECLS 31 | 32 | void *memalign_alloc(size_t boundary, size_t size); 33 | 34 | void *memalign_alloc_aligned(size_t size); 35 | 36 | void memalign_free(void *ptr); 37 | 38 | RETRO_END_DECLS 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libretro-common/include/retro_assert.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_assert.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 __RETRO_ASSERT_H 24 | #define __RETRO_ASSERT_H 25 | 26 | #include 27 | 28 | #ifdef RARCH_INTERNAL 29 | #include 30 | #define retro_assert(cond) ((void)( (cond) || (printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__), abort(), 0) )) 31 | #else 32 | #define retro_assert(cond) assert(cond) 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libretro-common/include/retro_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_common.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_COMMON_RETRO_COMMON_H 24 | #define _LIBRETRO_COMMON_RETRO_COMMON_H 25 | 26 | /*! 27 | * @internal This file is designed to normalize the libretro-common compiling environment. 28 | * It is not to be used in public API headers, as they should be designed as leanly as possible. 29 | * Nonetheless.. in the meantime, if you do something like use ssize_t, which is not fully portable, 30 | * in a public API, you may need this. 31 | */ 32 | 33 | /* conditional compilation is handled inside here */ 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libretro-common/include/retro_common_api.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_common_api.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_COMMON_RETRO_COMMON_API_H 24 | #define _LIBRETRO_COMMON_RETRO_COMMON_API_H 25 | 26 | /* 27 | This file is designed to normalize the libretro-common compiling environment 28 | for public API headers. This should be leaner than a normal compiling environment, 29 | since it gets #included into other project's sources. 30 | */ 31 | 32 | /* ------------------------------------ */ 33 | 34 | /* 35 | Ordinarily we want to put #ifdef __cplusplus extern "C" in C library 36 | headers to enable them to get used by c++ sources. 37 | However, we want to support building this library as C++ as well, so a 38 | special technique is called for. 39 | */ 40 | 41 | #define RETRO_BEGIN_DECLS 42 | #define RETRO_END_DECLS 43 | 44 | #ifdef __cplusplus 45 | 46 | #ifdef CXX_BUILD 47 | /* build wants everything to be built as c++, so no extern "C" */ 48 | #else 49 | #undef RETRO_BEGIN_DECLS 50 | #undef RETRO_END_DECLS 51 | #define RETRO_BEGIN_DECLS extern "C" { 52 | #define RETRO_END_DECLS } 53 | #endif 54 | 55 | #else 56 | 57 | /* header is included by a C source file, so no extern "C" */ 58 | 59 | #endif 60 | 61 | /* 62 | IMO, this non-standard ssize_t should not be used. 63 | However, it's a good example of how to handle something like this. 64 | */ 65 | #ifdef _MSC_VER 66 | #ifndef HAVE_SSIZE_T 67 | #define HAVE_SSIZE_T 68 | #if defined(_WIN64) 69 | typedef __int64 ssize_t; 70 | #elif defined(_WIN32) 71 | typedef int ssize_t; 72 | #endif 73 | #endif 74 | #elif defined(__MACH__) 75 | #include 76 | #endif 77 | 78 | #ifdef _MSC_VER 79 | #if _MSC_VER >= 1800 80 | #include 81 | #else 82 | #ifndef PRId64 83 | #define PRId64 "I64d" 84 | #define PRIu64 "I64u" 85 | #define PRIuPTR "Iu" 86 | #endif 87 | #endif 88 | #else 89 | /* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */ 90 | /* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */ 91 | /* https://github.com/libretro/RetroArch/issues/6009 */ 92 | #ifndef __STDC_FORMAT_MACROS 93 | #define __STDC_FORMAT_MACROS 1 94 | #endif 95 | #include 96 | #endif 97 | #ifndef PRId64 98 | #error "inttypes.h is being screwy" 99 | #endif 100 | #define STRING_REP_INT64 "%" PRId64 101 | #define STRING_REP_UINT64 "%" PRIu64 102 | #define STRING_REP_USIZE "%" PRIuPTR 103 | 104 | /* Wrap a declaration in RETRO_DEPRECATED() to produce a compiler warning when 105 | it's used. This is intended for developer machines, so it won't work on ancient 106 | or obscure compilers */ 107 | #if defined(_MSC_VER) 108 | #if _MSC_VER >= 1400 /* Visual C 2005 or later */ 109 | #define RETRO_DEPRECATED(decl) __declspec(deprecated) decl 110 | #endif 111 | #elif defined(__GNUC__) 112 | #if __GNUC__ >= 3 /* GCC 3 or later */ 113 | #define RETRO_DEPRECATED(decl) decl __attribute__((deprecated)) 114 | #endif 115 | #elif defined(__clang__) 116 | #if __clang_major__ >= 3 /* clang 3 or later */ 117 | #define RETRO_DEPRECATED(decl) decl __attribute__((deprecated)) 118 | #endif 119 | #endif 120 | #ifndef RETRO_DEPRECATED /* Unsupported compilers */ 121 | #define RETRO_DEPRECATED(decl) decl 122 | #endif 123 | 124 | /* 125 | I would like to see retro_inline.h moved in here; possibly boolean too. 126 | 127 | rationale: these are used in public APIs, and it is easier to find problems 128 | and write code that works the first time portably when theyre included uniformly 129 | than to do the analysis from scratch each time you think you need it, for each feature. 130 | 131 | Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h, 132 | then you should pay the price everywhere, so you can see how much grief it will cause. 133 | 134 | Of course, another school of thought is that you should do as little damage as possible 135 | in as few places as possible... 136 | */ 137 | 138 | /* _LIBRETRO_COMMON_RETRO_COMMON_API_H */ 139 | #endif 140 | -------------------------------------------------------------------------------- /libretro-common/include/retro_environment.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_environment.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_ENVIRONMENT_H 24 | #define __LIBRETRO_SDK_ENVIRONMENT_H 25 | 26 | /* 27 | This file is designed to create a normalized environment for compiling 28 | libretro-common's private implementations, or any other sources which might 29 | enjoy use of it's environment (RetroArch for instance). 30 | This should be an elaborately crafted environment so that sources don't 31 | need to be full of platform-specific workarounds. 32 | */ 33 | 34 | #if defined (__cplusplus) 35 | #if 0 36 | printf("This is C++, version %d.\n", __cplusplus); 37 | #endif 38 | /* The expected values would be 39 | * 199711L, for ISO/IEC 14882:1998 or 14882:2003 40 | */ 41 | 42 | #elif defined(__STDC__) 43 | /* This is standard C. */ 44 | 45 | #if (__STDC__ == 1) 46 | /* The implementation is ISO-conforming. */ 47 | #define __STDC_ISO__ 48 | #else 49 | /* The implementation is not ISO-conforming. */ 50 | #endif 51 | 52 | #if defined(__STDC_VERSION__) 53 | #if (__STDC_VERSION__ >= 201112L) 54 | /* This is C11. */ 55 | #define __STDC_C11__ 56 | #elif (__STDC_VERSION__ >= 199901L) 57 | /* This is C99. */ 58 | #define __STDC_C99__ 59 | #elif (__STDC_VERSION__ >= 199409L) 60 | /* This is C89 with amendment 1. */ 61 | #define __STDC_C89__ 62 | #define __STDC_C89_AMENDMENT_1__ 63 | #else 64 | /* This is C89 without amendment 1. */ 65 | #define __STDC_C89__ 66 | #endif 67 | #else /* !defined(__STDC_VERSION__) */ 68 | /* This is C89. __STDC_VERSION__ is not defined. */ 69 | #define __STDC_C89__ 70 | #endif 71 | 72 | #else /* !defined(__STDC__) */ 73 | /* This is not standard C. __STDC__ is not defined. */ 74 | #endif 75 | 76 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 77 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 78 | #if defined(_MSC_VER) && defined(__has_include) 79 | #if __has_include() 80 | #define HAVE_WINAPIFAMILY_H 1 81 | #else 82 | #define HAVE_WINAPIFAMILY_H 0 83 | #endif 84 | 85 | /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ 86 | #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ 87 | #define HAVE_WINAPIFAMILY_H 1 88 | #else 89 | #define HAVE_WINAPIFAMILY_H 0 90 | #endif 91 | 92 | #if HAVE_WINAPIFAMILY_H 93 | #include 94 | #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) 95 | #else 96 | #define WINAPI_FAMILY_WINRT 0 97 | #endif /* HAVE_WINAPIFAMILY_H */ 98 | 99 | #if WINAPI_FAMILY_WINRT 100 | #undef __WINRT__ 101 | #define __WINRT__ 1 102 | #endif 103 | 104 | /* MSVC obviously has to have some non-standard constants... */ 105 | #if _M_IX86_FP == 1 106 | #define __SSE__ 1 107 | #elif _M_IX86_FP == 2 || (defined(_M_AMD64) || defined(_M_X64)) 108 | #define __SSE__ 1 109 | #define __SSE2__ 1 110 | #endif 111 | 112 | #endif 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /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 | /** 29 | * Cross-platform inline specifier. 30 | * 31 | * Expands to something like \c __inline or \c inline, 32 | * depending on the compiler. 33 | */ 34 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 35 | #define INLINE __inline 36 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 37 | #define INLINE inline 38 | #elif defined(__GNUC__) 39 | #define INLINE __inline__ 40 | #else 41 | #define INLINE 42 | #endif 43 | 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /libretro-common/include/streams/file_stream_transforms.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_stream_transforms.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_FILE_STREAM_TRANSFORMS_H 24 | #define __LIBRETRO_SDK_FILE_STREAM_TRANSFORMS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /** 32 | * @file file_stream_transforms.h 33 | * 34 | * Contains macros that redirect standard C I/O functions 35 | * to libretro's own file stream API. 36 | * Useful when porting an existing emulator to a core. 37 | * To use these functions without overriding the standard I/O functions, 38 | * define \c SKIP_STDIO_REDEFINES before including this header. 39 | * 40 | * @see https://man7.org/linux/man-pages/man3/stdio.3.html 41 | */ 42 | 43 | RETRO_BEGIN_DECLS 44 | 45 | #ifndef SKIP_STDIO_REDEFINES 46 | 47 | /** @see https://en.cppreference.com/w/c/io/FILE */ 48 | #define FILE RFILE 49 | 50 | #undef fopen 51 | #undef fclose 52 | #undef ftell 53 | #undef fseek 54 | #undef fread 55 | #undef fgets 56 | #undef fgetc 57 | #undef fwrite 58 | #undef fputc 59 | #undef fflush 60 | #undef fprintf 61 | #undef ferror 62 | #undef feof 63 | #undef fscanf 64 | 65 | #define fopen rfopen 66 | #define fclose rfclose 67 | #define ftell rftell 68 | #define fseek rfseek 69 | #define fread rfread 70 | #define fgets rfgets 71 | #define fgetc rfgetc 72 | #define fwrite rfwrite 73 | #define fputc rfputc 74 | #define fflush rfflush 75 | #define fprintf rfprintf 76 | #define ferror rferror 77 | #define feof rfeof 78 | #define fscanf rfscanf 79 | 80 | #endif 81 | 82 | /** @see https://en.cppreference.com/w/c/io/fopen */ 83 | RFILE* rfopen(const char *path, const char *mode); 84 | 85 | /** @see https://en.cppreference.com/w/c/io/fclose */ 86 | int rfclose(RFILE* stream); 87 | 88 | /** @see https://en.cppreference.com/w/c/io/ftell */ 89 | int64_t rftell(RFILE* stream); 90 | 91 | /** @see https://en.cppreference.com/w/c/io/fseek */ 92 | int64_t rfseek(RFILE* stream, int64_t offset, int origin); 93 | 94 | /** @see https://en.cppreference.com/w/c/io/fread */ 95 | int64_t rfread(void* buffer, 96 | size_t elem_size, size_t elem_count, RFILE* stream); 97 | 98 | /** @see https://en.cppreference.com/w/c/io/fgets */ 99 | char *rfgets(char *buffer, int maxCount, RFILE* stream); 100 | 101 | /** @see https://en.cppreference.com/w/c/io/fgetc */ 102 | int rfgetc(RFILE* stream); 103 | 104 | /** @see https://en.cppreference.com/w/c/io/fwrite */ 105 | int64_t rfwrite(void const* buffer, 106 | size_t elem_size, size_t elem_count, RFILE* stream); 107 | 108 | /** @see https://en.cppreference.com/w/c/io/fputc */ 109 | int rfputc(int character, RFILE * stream); 110 | 111 | /** @see https://en.cppreference.com/w/c/io/fflush */ 112 | int64_t rfflush(RFILE * stream); 113 | 114 | /** @see https://en.cppreference.com/w/c/io/fprintf */ 115 | int rfprintf(RFILE * stream, const char * format, ...); 116 | 117 | /** @see https://en.cppreference.com/w/c/io/ferror */ 118 | int rferror(RFILE* stream); 119 | 120 | /** @see https://en.cppreference.com/w/c/io/feof */ 121 | int rfeof(RFILE* stream); 122 | 123 | /** @see https://en.cppreference.com/w/c/io/fscanf */ 124 | int rfscanf(RFILE * stream, const char * format, ...); 125 | 126 | RETRO_END_DECLS 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /libretro-common/include/streams/memory_stream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (memory_stream.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_FILE_MEMORY_STREAM_H 24 | #define _LIBRETRO_SDK_FILE_MEMORY_STREAM_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | RETRO_BEGIN_DECLS 32 | 33 | typedef struct memstream memstream_t; 34 | 35 | memstream_t *memstream_open(unsigned writing); 36 | 37 | void memstream_close(memstream_t *stream); 38 | 39 | uint64_t memstream_read(memstream_t *stream, void *data, uint64_t bytes); 40 | 41 | uint64_t memstream_write(memstream_t *stream, const void *data, uint64_t bytes); 42 | 43 | int memstream_getc(memstream_t *stream); 44 | 45 | void memstream_putc(memstream_t *stream, int c); 46 | 47 | char *memstream_gets(memstream_t *stream, char *buffer, size_t len); 48 | 49 | uint64_t memstream_pos(memstream_t *stream); 50 | 51 | void memstream_rewind(memstream_t *stream); 52 | 53 | int64_t memstream_seek(memstream_t *stream, int64_t offset, int whence); 54 | 55 | void memstream_set_buffer(uint8_t *buffer, uint64_t size); 56 | 57 | uint64_t memstream_get_last_size(void); 58 | 59 | uint64_t memstream_get_ptr(memstream_t *stream); 60 | 61 | RETRO_END_DECLS 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libretro-common/include/time/rtime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rtime.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_RTIME_H__ 24 | #define __LIBRETRO_SDK_RTIME_H__ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | /* TODO/FIXME: Move all generic time handling functions 35 | * to this file */ 36 | 37 | /** 38 | * Must be called before using \c rtime_localtime(). 39 | * May be called multiple times without ill effects, 40 | * but must only be called from the main thread. 41 | */ 42 | void rtime_init(void); 43 | 44 | /** 45 | * Must be called upon program or core termination. 46 | * May be called multiple times without ill effects, 47 | * but must only be called from the main thread. 48 | */ 49 | void rtime_deinit(void); 50 | 51 | /** 52 | * Thread-safe wrapper around standard \c localtime(), 53 | * which by itself is not guaranteed to be thread-safe. 54 | * @param timep Pointer to a time_t object to convert. 55 | * @param result Pointer to a tm object to store the result in. 56 | * @return \c result. 57 | * @see https://en.cppreference.com/w/c/chrono/localtime 58 | */ 59 | struct tm *rtime_localtime(const time_t *timep, struct tm *result); 60 | 61 | RETRO_END_DECLS 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libretro-common/include/vfs/vfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (vfs_implementation.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_VFS_H 24 | #define __LIBRETRO_SDK_VFS_H 25 | 26 | #include 27 | #include 28 | 29 | #ifdef RARCH_INTERNAL 30 | #ifndef VFS_FRONTEND 31 | #define VFS_FRONTEND 32 | #endif 33 | #endif 34 | 35 | RETRO_BEGIN_DECLS 36 | 37 | #ifdef _WIN32 38 | typedef void* HANDLE; 39 | #endif 40 | 41 | #ifdef HAVE_CDROM 42 | typedef struct 43 | { 44 | int64_t byte_pos; 45 | char *cue_buf; 46 | size_t cue_len; 47 | unsigned cur_lba; 48 | unsigned last_frame_lba; 49 | unsigned char cur_min; 50 | unsigned char cur_sec; 51 | unsigned char cur_frame; 52 | unsigned char cur_track; 53 | unsigned char last_frame[2352]; 54 | char drive; 55 | bool last_frame_valid; 56 | } vfs_cdrom_t; 57 | #endif 58 | 59 | enum vfs_scheme 60 | { 61 | VFS_SCHEME_NONE = 0, 62 | VFS_SCHEME_CDROM 63 | }; 64 | 65 | #if !(defined(__WINRT__) && defined(__cplusplus_winrt)) 66 | #ifdef VFS_FRONTEND 67 | struct retro_vfs_file_handle 68 | #else 69 | struct libretro_vfs_implementation_file 70 | #endif 71 | { 72 | #ifdef HAVE_CDROM 73 | vfs_cdrom_t cdrom; /* int64_t alignment */ 74 | #endif 75 | int64_t size; 76 | uint64_t mappos; 77 | uint64_t mapsize; 78 | FILE *fp; 79 | #ifdef _WIN32 80 | HANDLE fh; 81 | #endif 82 | char *buf; 83 | char* orig_path; 84 | uint8_t *mapped; 85 | int fd; 86 | unsigned hints; 87 | enum vfs_scheme scheme; 88 | }; 89 | #endif 90 | 91 | /* Replace the following symbol with something appropriate 92 | * to signify the file is being compiled for a front end instead of a core. 93 | * This allows the same code to act as reference implementation 94 | * for VFS and as fallbacks for when the front end does not provide VFS functionality. 95 | */ 96 | 97 | #ifdef VFS_FRONTEND 98 | typedef struct retro_vfs_file_handle libretro_vfs_implementation_file; 99 | #else 100 | typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file; 101 | #endif 102 | 103 | #ifdef VFS_FRONTEND 104 | typedef struct retro_vfs_dir_handle libretro_vfs_implementation_dir; 105 | #else 106 | typedef struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir; 107 | #endif 108 | 109 | RETRO_END_DECLS 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /libretro-common/include/vfs/vfs_implementation.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (vfs_implementation.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_VFS_IMPLEMENTATION_H 24 | #define __LIBRETRO_SDK_VFS_IMPLEMENTATION_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, unsigned mode, unsigned hints); 35 | 36 | int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream); 37 | 38 | int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream); 39 | 40 | int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream); 41 | 42 | int64_t retro_vfs_file_truncate_impl(libretro_vfs_implementation_file *stream, int64_t length); 43 | 44 | int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream); 45 | 46 | int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64_t offset, int seek_position); 47 | 48 | int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void *s, uint64_t len); 49 | 50 | int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len); 51 | 52 | int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream); 53 | 54 | int retro_vfs_file_remove_impl(const char *path); 55 | 56 | int retro_vfs_file_rename_impl(const char *old_path, const char *new_path); 57 | 58 | const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *stream); 59 | 60 | int retro_vfs_stat_impl(const char *path, int32_t *size); 61 | 62 | int retro_vfs_mkdir_impl(const char *dir); 63 | 64 | libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *dir, bool include_hidden); 65 | 66 | bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *dirstream); 67 | 68 | const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *dirstream); 69 | 70 | bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *dirstream); 71 | 72 | int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *dirstream); 73 | 74 | #ifdef __WINRT__ 75 | 76 | void uwp_set_acl(const wchar_t* path, const wchar_t* AccessString); 77 | 78 | #endif 79 | 80 | RETRO_END_DECLS 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /libretro-common/streams/file_stream_transforms.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_stream_transforms.c). 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 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | RFILE* rfopen(const char *path, const char *mode) 30 | { 31 | RFILE *output = NULL; 32 | unsigned int retro_mode = RETRO_VFS_FILE_ACCESS_READ; 33 | bool position_to_end = false; 34 | 35 | if (strstr(mode, "r")) 36 | { 37 | retro_mode = RETRO_VFS_FILE_ACCESS_READ; 38 | if (strstr(mode, "+")) 39 | { 40 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE | 41 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 42 | } 43 | } 44 | else if (strstr(mode, "w")) 45 | { 46 | retro_mode = RETRO_VFS_FILE_ACCESS_WRITE; 47 | if (strstr(mode, "+")) 48 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE; 49 | } 50 | else if (strstr(mode, "a")) 51 | { 52 | retro_mode = RETRO_VFS_FILE_ACCESS_WRITE | 53 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 54 | position_to_end = true; 55 | if (strstr(mode, "+")) 56 | { 57 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE | 58 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 59 | } 60 | } 61 | 62 | output = filestream_open(path, retro_mode, 63 | RETRO_VFS_FILE_ACCESS_HINT_NONE); 64 | if (output && position_to_end) 65 | filestream_seek(output, 0, RETRO_VFS_SEEK_POSITION_END); 66 | 67 | return output; 68 | } 69 | 70 | int rfclose(RFILE* stream) 71 | { 72 | if (!stream) 73 | return EOF; 74 | 75 | return filestream_close(stream); 76 | } 77 | 78 | int64_t rftell(RFILE* stream) 79 | { 80 | if (!stream) 81 | return -1; 82 | 83 | return filestream_tell(stream); 84 | } 85 | 86 | int64_t rfseek(RFILE* stream, int64_t offset, int origin) 87 | { 88 | int seek_position = -1; 89 | 90 | if (!stream) 91 | return -1; 92 | 93 | switch (origin) 94 | { 95 | case SEEK_SET: 96 | seek_position = RETRO_VFS_SEEK_POSITION_START; 97 | break; 98 | case SEEK_CUR: 99 | seek_position = RETRO_VFS_SEEK_POSITION_CURRENT; 100 | break; 101 | case SEEK_END: 102 | seek_position = RETRO_VFS_SEEK_POSITION_END; 103 | break; 104 | } 105 | 106 | return filestream_seek(stream, offset, seek_position); 107 | } 108 | 109 | int64_t rfread(void* buffer, 110 | size_t elem_size, size_t elem_count, RFILE* stream) 111 | { 112 | if (!stream || (elem_size == 0) || (elem_count == 0)) 113 | return 0; 114 | 115 | return (filestream_read(stream, buffer, elem_size * elem_count) / elem_size); 116 | } 117 | 118 | char *rfgets(char *buffer, int maxCount, RFILE* stream) 119 | { 120 | if (!stream) 121 | return NULL; 122 | 123 | return filestream_gets(stream, buffer, maxCount); 124 | } 125 | 126 | int rfgetc(RFILE* stream) 127 | { 128 | if (!stream) 129 | return EOF; 130 | 131 | return filestream_getc(stream); 132 | } 133 | 134 | int64_t rfwrite(void const* buffer, 135 | size_t elem_size, size_t elem_count, RFILE* stream) 136 | { 137 | if (!stream || (elem_size == 0) || (elem_count == 0)) 138 | return 0; 139 | 140 | return (filestream_write(stream, buffer, elem_size * elem_count) / elem_size); 141 | } 142 | 143 | int rfputc(int character, RFILE * stream) 144 | { 145 | if (!stream) 146 | return EOF; 147 | 148 | return filestream_putc(stream, character); 149 | } 150 | 151 | int64_t rfflush(RFILE * stream) 152 | { 153 | if (!stream) 154 | return EOF; 155 | 156 | return filestream_flush(stream); 157 | } 158 | 159 | int rfprintf(RFILE * stream, const char * format, ...) 160 | { 161 | int result; 162 | va_list vl; 163 | 164 | if (!stream) 165 | return -1; 166 | 167 | va_start(vl, format); 168 | result = filestream_vprintf(stream, format, vl); 169 | va_end(vl); 170 | return result; 171 | } 172 | 173 | int rferror(RFILE* stream) 174 | { 175 | return filestream_error(stream); 176 | } 177 | 178 | int rfeof(RFILE* stream) 179 | { 180 | return filestream_eof(stream); 181 | } 182 | 183 | int rfscanf(RFILE * stream, const char * format, ...) 184 | { 185 | int result; 186 | va_list vl; 187 | 188 | if (!stream) 189 | return 0; 190 | 191 | va_start(vl, format); 192 | result = filestream_vscanf(stream, format, &vl); 193 | va_end(vl); 194 | return result; 195 | } 196 | -------------------------------------------------------------------------------- /libretro-common/time/rtime.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rtime.c). 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 | #ifdef HAVE_THREADS 24 | #include 25 | #include 26 | #endif 27 | 28 | #include 29 | #include