diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..00a283e2ad --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ +## Guidelines + +1. Rebase before opening a pull request +2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each +3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises + + +## Description + +[Description of the pull request, detail any issues you are fixing or any features you are implementing] + +## Related Issues + +[Any issues this pull request may be addressing] + +## Related Pull Requests + +[Any other PRs from related repositories that might be needed for this pull request to work] + +## Reviewers + +[If possible @mention all the people that should review your pull request] diff --git a/.gitignore b/.gitignore index ad6ea6ab19..292bff2bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,8 @@ obj-unix/ /pkg/msvc/Release Cg/*.lpl /pkg/msvc/Release Cg/*.cfg /pkg/msvc/*.db +/pkg/msvc/.vs +/pkg/msvc/*/.vs /pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.tlog /pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.lastbuildstate /pkg/msvc/msvc-2010/Release Cg/*.log diff --git a/.travis.yml b/.travis.yml index 73b48fb889..a67a17b635 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,6 +55,7 @@ addons: - libsdl-image1.2-dev - libsdl-mixer1.2-dev - libsdl-ttf2.0-dev + - libusb-1.0-0-dev coverity_scan: project: name: "RetroArch" diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000..81c2529184 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,125 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] + }, + { + "name": "Linux", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "Win32", + "includePath": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw32", + "includePath": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw64", + "includePath": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 3 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..6e1f69631a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,48 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "msys2-mingw64 debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/retroarch.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + }, + { + "name": "msys2-mingw32 debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/retroarch.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "miDebuggerPath": "c:\\msys64\\mingw32\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..1fdc2bf309 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe", + "terminal.integrated.env.windows": { + "PATH": "/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:$PATH", + "MSYSTEM": "MINGW64", + }, + "terminal.integrated.cursorBlinking": true, + + "editor.tabSize": 3, + "editor.renderWhitespace": "all", + "editor.insertSpaces": true, +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..b271c66e8f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,91 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "taskName": "msys2-mingw64 build", + "type": "shell", + + "group": { + "kind": "build", + "isDefault": true }, + + "command": "./configure; make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "msys2-mingw64 build with debug symbols", + "type": "shell", + + "group": "build", + + "command": "./configure; DEBUG=1 make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "msys2-mingw64 rebuild", + "type": "shell", + + "group": "build", + + "command": "make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "msys2-mingw64 clean", + "type": "shell", + + "group": "build", + + "command": "make clean", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "msys2-mingw64 run", + "type": "shell", + + "group": { + "kind": "test", + "isDefault": true }, + + "command": "./retroarch -v", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + ] +} \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index 17bb6ec41b..29d55435d6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,40 @@ # 1.7.0 (future) -- CHEEVOS: Add badges +- CHEEVOS: Add badges for achievements, shows thumbnail images of achievements. +- CHEEVOS: Leaderboard support. +- CHEEVOS: Only disable savestates on hardcore mode if achievements are not available. +- COMMON: Add 'Automatically Load Content To Playlist' feature, enabled by default. +- COMMON: Fix slowmotion ratio always being reset back to 1. +- COMMON: Optimized NBIO implementations now for Apple, Windows, and Linux. Uses mmap for Linux/Windows/BSD if/when available. File I/O should now be much faster for loading images inside the menu. +- COMMON: Native Blissbox support now for latest firmware as of writing (2.0). Implementation through libusb and/or native Windows HID. +- COMMON: New lightgun API. +- COMMON: Fixed some playlist bugs. +- COMMON: New snow shader. +- COMMON: Fix loading cores that require no content one after another. +- EMSCRIPTEN: Fix references to browserfs. +- FREEBSD: Support libusb HID input driver. +- HAIKU: Buildfix. +- INPUT: Map clear button to DEL key. +- LINUX/X11: Add RetroArch logo to window title bar. +- LINUX/X11: Input driver now supports new lightgun code. +- LINUX/X11: Support window transparency (requires a compositing window manager). +- LOBBIES: Fix for crash on join netplay rooms via touch / glui. +- LOCALIZATION: Update Italian translation. +- LOCALIZATION: Update Japanese translation. +- LOCALIZATION: Update Portuguese-Brazilian translation. +- LOCALIZATION: Update Russian translation. +- OSX/PPC: Fix the GL2 renderchain, had to use EXT versions of framebuffer/renderbuffer functions. +- PSP: Fix content loading, port should be functional again. +- PSP: Us 64MB when available. +- SCANNER: Fix crash from Windows-incompatible format string. +- VITA: Improve packaging, installation times. +- WIIU: Disabled the controller patcher for now since it was the source of many stability issues. +- WINDOWS: Add MSVC 2017 solution. +- WINDOWS: Get rid of the empty console window in MSVC 2010 builds. +- WINDOWS: Raw input driver now supports new lightgun code. +- WINDOWS: Use configured OSD/text message color on GDI driver. +- WINDOWS/XINPUT: Populate XInput VID/PID from DInput so autoconfig doesn't rely solely on joypad names +- WINDOWS: Improve version reporting under System Information. +- WINDOWS: Support window transparency. # 1.6.9 - COMMON: Small memory leak. diff --git a/Makefile b/Makefile index 8e70dd430d..b820c54233 100644 --- a/Makefile +++ b/Makefile @@ -205,13 +205,6 @@ install: $(TARGET) mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \ cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ - echo "Removing unneeded source image files.."; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/flatui/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/monochrome/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/neoactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retrosystem/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/dot-art/src; \ echo "Asset copying done."; \ fi diff --git a/Makefile.common b/Makefile.common index ace2a5c4a6..1ba0da7f23 100644 --- a/Makefile.common +++ b/Makefile.common @@ -127,6 +127,10 @@ ifeq ($(HAVE_UNIX), 1) OBJ += frontend/drivers/platform_unix.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += frontend/drivers/platform_ctr.o +endif + ifeq ($(findstring Haiku,$(OS)),) LIBS += -lm DEBUG_FLAG = -g @@ -170,6 +174,7 @@ OBJ += frontend/frontend.o \ tasks/task_audio_mixer.o \ $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.o \ $(LIBRETRO_COMM_DIR)/encodings/encoding_crc32.o \ + $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.o \ $(LIBRETRO_COMM_DIR)/lists/file_list.o \ $(LIBRETRO_COMM_DIR)/lists/dir_list.o \ $(LIBRETRO_COMM_DIR)/file/retro_dirent.o \ @@ -178,6 +183,7 @@ OBJ += frontend/frontend.o \ $(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.o \ $(LIBRETRO_COMM_DIR)/streams/interface_stream.o \ $(LIBRETRO_COMM_DIR)/streams/memory_stream.o \ + $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.o \ $(LIBRETRO_COMM_DIR)/lists/string_list.o \ $(LIBRETRO_COMM_DIR)/string/stdstring.o \ $(LIBRETRO_COMM_DIR)/memmap/memalign.o \ @@ -196,6 +202,7 @@ OBJ += frontend/frontend.o \ $(LIBRETRO_COMM_DIR)/audio/audio_mixer.o \ input/input_driver.o \ gfx/video_coord_array.o \ + gfx/video_display_server.o \ gfx/video_driver.o \ camera/camera_driver.o \ wifi/wifi_driver.o \ @@ -242,6 +249,7 @@ OBJ += frontend/frontend.o \ camera/drivers/nullcamera.o \ wifi/drivers/nullwifi.o \ gfx/drivers/nullgfx.o \ + gfx/display_servers/dispserv_null.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ input/drivers_hid/null_hid.o \ @@ -569,12 +577,21 @@ ifeq ($(HAVE_CORETEXT), 1) OBJ += gfx/drivers_font_renderer/coretext.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += gfx/drivers_font/ctr_font.o +endif + ifeq ($(HAVE_OSS), 1) OBJ += audio/drivers/oss.o else ifeq ($(HAVE_OSS_BSD), 1) OBJ += audio/drivers/oss.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += audio/drivers/ctr_csnd_audio.o \ + audio/drivers/ctr_dsp_audio.o +endif + ifeq ($(HAVE_ALSA), 1) OBJ += audio/drivers/alsa.o @@ -757,6 +774,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_event.o \ menu/menu_entries.o \ menu/menu_setting.o \ + menu/menu_networking.o \ menu/menu_shader.o \ menu/widgets/menu_filebrowser.o \ menu/widgets/menu_dialog.o \ @@ -844,6 +862,13 @@ endif CFLAGS += -I$(DEPS_DIR)/libvita2d/include endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += gfx/drivers/ctr_gfx.o \ + menu/drivers_display/menu_display_ctr.o \ + input/drivers/ctr_input.o \ + input/drivers_joypad/ctr_joypad.o +endif + ifeq ($(HAVE_WAYLAND), 1) OBJ += gfx/drivers_context/wayland_ctx.o \ input/drivers/wayland_input.o @@ -874,12 +899,12 @@ endif ifeq ($(HAVE_X11), 1) OBJ += input/common/input_x11_common.o \ input/drivers/x11_input.o \ - gfx/common/dbus_common.o \ gfx/common/x11_common.o \ - gfx/common/xinerama_common.o + gfx/common/xinerama_common.o \ + gfx/display_servers/dispserv_x11.o LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS) - DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS) + DEFINES += -DHAVE_X11 $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS) ifeq ($(HAVE_XCB),1) LIBS += -lX11-xcb endif @@ -902,6 +927,7 @@ endif ifeq ($(HAVE_DBUS), 1) LIBS += $(DBUS_LIBS) CFLAGS += $(DBUS_CFLAGS) + OBJ += gfx/common/dbus_common.o endif ifeq ($(HAVE_UDEV), 1) @@ -916,7 +942,11 @@ ifeq ($(HAVE_THREADS), 1) ifeq ($(HAVE_HID), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o - LIBS += -lusb-1.0 + ifneq ($(findstring BSD,$(OS)),) + LIBS += -lusb + else + LIBS += -lusb-1.0 + endif endif endif endif @@ -1525,9 +1555,10 @@ ifneq ($(findstring Win32,$(OS)),) OBJ += gfx/drivers/gdi_gfx.o \ gfx/drivers_context/gdi_ctx.o \ gfx/drivers_font/gdi_font.o \ + gfx/display_servers/dispserv_win32.o \ menu/drivers_display/menu_display_gdi.o - LIBS += -lmsimg32 + LIBS += -lmsimg32 -lhid -lsetupapi endif ifeq ($(HAVE_AVFOUNDATION), 1) @@ -1579,3 +1610,27 @@ ifneq ($(findstring DOS,$(OS)),) OBJ += menu/drivers_display/menu_display_vga.o endif endif + +ifeq ($(HAVE_STATIC_VIDEO_FILTERS), 1) +OBJ += gfx/video_filters/2xsai.o \ + gfx/video_filters/super2xsai.o \ + gfx/video_filters/supereagle.o \ + gfx/video_filters/2xbr.o \ + gfx/video_filters/darken.o \ + gfx/video_filters/epx.o \ + gfx/video_filters/scale2x.o \ + gfx/video_filters/blargg_ntsc_snes.o \ + gfx/video_filters/lq2x.o \ + gfx/video_filters/phosphor2x.o +endif + +ifeq ($(HAVE_STATIC_AUDIO_FILTERS), 1) +OBJ += libretro-common/audio/dsp_filters/echo.o \ + libretro-common/audio/dsp_filters/eq.o \ + libretro-common/audio/dsp_filters/chorus.o \ + libretro-common/audio/dsp_filters/iir.o \ + libretro-common/audio/dsp_filters/panning.o \ + libretro-common/audio/dsp_filters/phaser.o \ + libretro-common/audio/dsp_filters/reverb.o \ + libretro-common/audio/dsp_filters/wahwah.o +endif diff --git a/Makefile.ctr b/Makefile.ctr index c277d3df77..701d87298e 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -9,8 +9,8 @@ BUILD_3DS = 1 BUILD_CIA = 1 LIBCTRU_NO_DEPRECATION = 1 -APP_TITLE = Retroarch 3DS -APP_DESCRIPTION = Retroarch 3DS +APP_TITLE = RetroArch 3DS +APP_DESCRIPTION = RetroArch 3DS APP_AUTHOR = Team Libretro APP_PRODUCT_CODE = RETROARCH-3DS APP_UNIQUE_ID = 0xBAC00 @@ -61,42 +61,16 @@ else HAVE_ZARCH = 0 HAVE_MATERIALUI = 1 HAVE_XMB = 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 include Makefile.common BLACKLIST := BLACKLIST += input/input_overlay.o BLACKLIST += tasks/task_overlay.o OBJ := $(filter-out $(BLACKLIST),$(OBJ)) - - OBJ += gfx/drivers/ctr_gfx.o - OBJ += gfx/drivers_font/ctr_font.o - OBJ += menu/drivers_display/menu_display_ctr.o - OBJ += input/drivers/ctr_input.o - OBJ += input/drivers_joypad/ctr_joypad.o - OBJ += audio/drivers/ctr_csnd_audio.o - OBJ += audio/drivers/ctr_dsp_audio.o - OBJ += frontend/drivers/platform_ctr.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif - ifeq ($(strip $(DEVKITPRO)),) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitpro") endif diff --git a/Makefile.ctr.salamander b/Makefile.ctr.salamander index 930b5badc7..6c67391f17 100644 --- a/Makefile.ctr.salamander +++ b/Makefile.ctr.salamander @@ -35,6 +35,7 @@ OBJ := ctr/ctr_system.o \ libretro-common/compat/compat_strl.o \ libretro-common/file/config_file.o \ libretro-common/streams/file_stream.o \ + libretro-common/vfs/vfs_implementation.o \ libretro-common/hash/rhash.o \ file_path_str.o \ verbosity.o diff --git a/Makefile.emscripten b/Makefile.emscripten index fb3a215339..e191cfd874 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -20,6 +20,8 @@ HAVE_SDL = 0 HAVE_SDL2 = 1 HAVE_ZLIB = 1 WANT_ZLIB = 1 +HAVE_STATIC_VIDEO_FILTERS = 1 +HAVE_STATIC_AUDIO_FILTERS = 1 MEMORY = 536870912 # XXX: setting this to 1/2 currently crashes Firefox nightly @@ -51,26 +53,6 @@ endif include Makefile.common -OBJ += gfx/video_filters/2xsai.o -OBJ += gfx/video_filters/super2xsai.o -OBJ += gfx/video_filters/supereagle.o -OBJ += gfx/video_filters/2xbr.o -OBJ += gfx/video_filters/darken.o -OBJ += gfx/video_filters/epx.o -OBJ += gfx/video_filters/scale2x.o -OBJ += gfx/video_filters/blargg_ntsc_snes.o -OBJ += gfx/video_filters/lq2x.o -OBJ += gfx/video_filters/phosphor2x.o - -OBJ += libretro-common/audio/dsp_filters/echo.o -OBJ += libretro-common/audio/dsp_filters/eq.o -OBJ += libretro-common/audio/dsp_filters/chorus.o -OBJ += libretro-common/audio/dsp_filters/iir.o -OBJ += libretro-common/audio/dsp_filters/panning.o -OBJ += libretro-common/audio/dsp_filters/phaser.o -OBJ += libretro-common/audio/dsp_filters/reverb.o -OBJ += libretro-common/audio/dsp_filters/wahwah.o - CFLAGS += -Ideps/libz -Ideps -Ideps/stb libretro = libretro_emscripten.bc diff --git a/Makefile.griffin b/Makefile.griffin index fccba281b4..5e2217dd6e 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -334,7 +334,7 @@ else ifeq ($(platform), windows_msvc6_x86) PLATCFLAGS += -D_WIN32 -D_WIN32_WINNT=0x0351 -D__STDC_CONSTANT_MACROS -D_MBCS LDFLAGS += shell32.lib user32.lib gdi32.lib comdlg32.lib winmm.lib ole32.lib - VCDIR ?= $(shell reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\DevStudio\6.0\Products\Microsoft Visual C++" -v "ProductDir" | grep -o '[A-Z]:\\.*') + VCDIR ?= $(shell reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\DevStudio\6.0\Products\Microsoft Visual C++" -v "ProductDir" | grep -io '[A-Z]:\\.*') PATH := $(shell IFS=$$'\n'; cygpath "$(VCDIR)/bin"):$(PATH) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VCDIR)/../Common/MSDev98/Bin") @@ -493,8 +493,8 @@ else ifneq (,$(findstring windows_msvc2010,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -io '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) @@ -568,7 +568,7 @@ else ifneq (,$(findstring windows_msvc2012,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS110COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS110COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) @@ -642,7 +642,7 @@ else ifneq (,$(findstring windows_msvc2013,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS120COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS120COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) @@ -833,6 +833,7 @@ ifeq ($(DEBUG), 1) endif CFLAGS += -Od -Zi -D_DEBUG -MTd -TP + LDFLAGS += -DEBUG else CFLAGS += -O0 -g -DDEBUG endif diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index ab51d0db4d..0d716a2e8f 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -44,6 +44,7 @@ PPU_SRCS = frontend/frontend_salamander.c \ libretro-common/compat/compat_strl.c \ libretro-common/compat/compat_strcasestr.c \ libretro-common/streams/file_stream.c \ + libretro-common/vfs/vfs_implementation.c \ libretro-common/file/config_file.c \ file_path_str.c \ verbosity.c diff --git a/Makefile.psp1 b/Makefile.psp1 index a99c89e754..31f5751f74 100644 --- a/Makefile.psp1 +++ b/Makefile.psp1 @@ -1,6 +1,8 @@ -BUILD_PRX = 1 +BUILD_PRX = 0 +PSP_LARGE_MEMORY = 1 DEBUG = 0 HAVE_KERNEL_PRX = 1 +HAVE_LOGGER = 0 HAVE_FILE_LOGGER = 0 HAVE_THREADS = 0 BIG_STACK = 0 @@ -11,7 +13,7 @@ TARGET = retroarchpsp ifeq ($(DEBUG), 1) OPTIMIZE_LV := -O0 -g else - OPTIMIZE_LV := -O3 -g + OPTIMIZE_LV := -O2 endif ifeq ($(WHOLE_ARCHIVE_LINK), 1) diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index 68e0732582..7bcc29a0e8 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -1,4 +1,5 @@ -BUILD_PRX = 1 +BUILD_PRX = 0 +PSP_LARGE_MEMORY = 1 HAVE_FILE_LOGGER = 0 DEBUG = 0 @@ -7,7 +8,7 @@ TARGET = retroarchpsp_salamander ifeq ($(DEBUG), 1) OPTIMIZE_LV := -O0 -g else - OPTIMIZE_LV := -O2 -g + OPTIMIZE_LV := -O2 endif INCDIR = $(PSPPATH)/include libretro-common/include @@ -24,7 +25,7 @@ ifeq ($(HAVE_FILE_LOGGER), 1) CFLAGS += -DHAVE_FILE_LOGGER endif -CFLAGS += $(RARCH_DEFINES) +CFLAGS += $(RARCH_DEFINES) EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = RetroArch @@ -45,6 +46,7 @@ OBJS = frontend/frontend_salamander.o \ libretro-common/compat/compat_strcasestr.o \ libretro-common/file/config_file.o \ libretro-common/streams/file_stream.o \ + libretro-common/vfs/vfs_implementation.o \ libretro-common/hash/rhash.o \ file_path_str.o \ verbosity.o \ diff --git a/Makefile.vita b/Makefile.vita index 3138442913..25d79a673e 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -47,6 +47,8 @@ else HAVE_CC_RESAMPLER := 1 HAVE_CHEEVOS := 1 RARCH_CONSOLE := 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 ifeq ($(DEBUG), 1) HAVE_NETLOGGER = 1 @@ -60,24 +62,6 @@ else OBJ += input/drivers_joypad/psp_joypad.o OBJ += audio/drivers/psp_audio.o OBJ += frontend/drivers/platform_psp.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif diff --git a/Makefile.vita.salamander b/Makefile.vita.salamander index 3af34fb28e..a443c2c0f7 100644 --- a/Makefile.vita.salamander +++ b/Makefile.vita.salamander @@ -46,6 +46,7 @@ OBJS = frontend/frontend_salamander.o \ libretro-common/compat/compat_strcasestr.o \ libretro-common/file/config_file.o \ libretro-common/streams/file_stream.o \ + libretro-common/vfs/vfs_implementation.o \ libretro-common/hash/rhash.o \ file_path_str.o \ verbosity.o diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index a125d3f9ed..e39c30bdc8 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -61,6 +61,7 @@ OBJ = frontend/frontend_salamander.o \ libretro-common/lists/string_list.o \ libretro-common/lists/dir_list.o \ libretro-common/streams/file_stream.o \ + libretro-common/vfs/vfs_implementation.o \ libretro-common/file/retro_dirent.o \ libretro-common/encodings/encoding_utf.o \ libretro-common/compat/compat_strl.o \ diff --git a/Makefile.wiiu b/Makefile.wiiu index b83d1caae7..b3389af1af 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -18,24 +18,27 @@ OBJ += wiiu/system/exception_handler.o OBJ += wiiu/system/missing_libc_functions.o OBJ += wiiu/fs/sd_fat_devoptab.o OBJ += wiiu/fs/fs_utils.o -OBJ += wiiu/controller_patcher/ControllerPatcher.o -OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o -OBJ += wiiu/controller_patcher/ConfigReader.o -OBJ += wiiu/controller_patcher/config/ConfigParser.o -OBJ += wiiu/controller_patcher/config/ConfigValues.o -OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o -OBJ += wiiu/controller_patcher/network/TCPServer.o -OBJ += wiiu/controller_patcher/network/UDPClient.o -OBJ += wiiu/controller_patcher/network/UDPServer.o -OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o -OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o -OBJ += wiiu/controller_patcher/utils/CPRetainVars.o -OBJ += wiiu/controller_patcher/utils/CPStringTools.o -OBJ += wiiu/controller_patcher/utils/PadConst.o -OBJ += wiiu/controller_patcher/utils/FSHelper.o OBJ += wiiu/tex_shader.o OBJ += wiiu/hbl.o +ifeq ($(ENABLE_CONTROLLER_PATCHER), 1) + OBJ += wiiu/controller_patcher/ControllerPatcher.o + OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o + OBJ += wiiu/controller_patcher/ConfigReader.o + OBJ += wiiu/controller_patcher/config/ConfigParser.o + OBJ += wiiu/controller_patcher/config/ConfigValues.o + OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o + OBJ += wiiu/controller_patcher/network/TCPServer.o + OBJ += wiiu/controller_patcher/network/UDPClient.o + OBJ += wiiu/controller_patcher/network/UDPServer.o + OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o + OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o + OBJ += wiiu/controller_patcher/utils/CPRetainVars.o + OBJ += wiiu/controller_patcher/utils/CPStringTools.o + OBJ += wiiu/controller_patcher/utils/PadConst.o + OBJ += wiiu/controller_patcher/utils/FSHelper.o +endif + DEFINES := ifeq ($(GRIFFIN_BUILD), 1) @@ -68,6 +71,8 @@ else HAVE_NETWORKING = 1 HAVE_CHEEVOS = 1 # WANT_IFADDRS = 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 include Makefile.common BLACKLIST := @@ -83,24 +88,6 @@ else OBJ += input/drivers_joypad/wiiu_joypad.o OBJ += audio/drivers/wiiu_audio.o OBJ += frontend/drivers/platform_wiiu.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif DEFINES += -DHAVE_KEYMAPPER @@ -158,6 +145,9 @@ CFLAGS += -DWIIU -DMSB_FIRST CFLAGS += -DHAVE_MAIN CFLAGS += -DHAVE_UPDATE_ASSETS CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE +ifeq ($(ENABLE_CONTROLLER_PATCHER), 1) + CFLAGS += -DENABLE_CONTROLLER_PATCHER +endif CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES) ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),) diff --git a/Makefile.wiiu.salamander b/Makefile.wiiu.salamander index 221d8193d1..893dbda848 100644 --- a/Makefile.wiiu.salamander +++ b/Makefile.wiiu.salamander @@ -26,6 +26,7 @@ OBJ += libretro-common/file/retro_dirent.o OBJ += libretro-common/compat/compat_strl.o OBJ += libretro-common/file/config_file.o OBJ += libretro-common/streams/file_stream.o +OBJ += libretro-common/vfs/vfs_implementation.o OBJ += libretro-common/hash/rhash.o OBJ += file_path_str.o OBJ += verbosity.o diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 6acb0b2ca7..6cd70cf681 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -111,7 +111,7 @@ static const audio_driver_t *audio_drivers[] = { #endif #if defined(PSP) || defined(VITA) &audio_psp, -#endif +#endif #ifdef _3DS &audio_ctr_csnd, &audio_ctr_dsp, @@ -150,7 +150,7 @@ static uint64_t audio_driver_free_samples_count = 0; static size_t audio_driver_buffer_size = 0; static size_t audio_driver_data_ptr = 0; -static bool audio_driver_control = false; +static bool audio_driver_control = false; static bool audio_driver_mixer_mute_enable = false; static bool audio_driver_mute_enable = false; static bool audio_driver_use_float = false; @@ -212,12 +212,12 @@ static void compute_audio_buffer_statistics(void) accum_var += diff * diff; } -#if defined(_MSC_VER) && _MSC_VER <= 1200 +#if defined(_MSC_VER) && _MSC_VER <= 1200 /* FIXME: error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64 */ -#else - stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); - avg_filled = 1.0f - (float)avg / audio_driver_buffer_size; - deviation = (float)stddev / audio_driver_buffer_size; +#else + stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); + avg_filled = 1.0f - (float)avg / audio_driver_buffer_size; + deviation = (float)stddev / audio_driver_buffer_size; #endif low_water_size = (unsigned)(audio_driver_buffer_size * 3 / 4); high_water_size = (unsigned)(audio_driver_buffer_size / 4); @@ -335,13 +335,13 @@ static bool audio_driver_init_internal(bool audio_cb_inited) size_t max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; settings_t *settings = config_get_ptr(); /* Accomodate rewind since at some point we might have two full buffers. */ - size_t outsamples_max = AUDIO_CHUNK_SIZE_NONBLOCKING * 2 * AUDIO_MAX_RATIO * + size_t outsamples_max = AUDIO_CHUNK_SIZE_NONBLOCKING * 2 * AUDIO_MAX_RATIO * settings->floats.slowmotion_ratio; convert_s16_to_float_init_simd(); convert_float_to_s16_init_simd(); - conv_buf = (int16_t*)malloc(outsamples_max + conv_buf = (int16_t*)malloc(outsamples_max * sizeof(int16_t)); /* Used for recording even if audio isn't enabled. */ retro_assert(conv_buf != NULL); @@ -379,9 +379,9 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!audio_init_thread( ¤t_audio, &audio_driver_context_audio_data, - *settings->arrays.audio_device + *settings->arrays.audio_device ? settings->arrays.audio_device : NULL, - settings->uints.audio_out_rate, &new_rate, + settings->uints.audio_out_rate, &new_rate, settings->uints.audio_latency, settings->uints.audio_block_frames, current_audio)) @@ -393,7 +393,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) else #endif { - audio_driver_context_audio_data = + audio_driver_context_audio_data = current_audio->init(*settings->arrays.audio_device ? settings->arrays.audio_device : NULL, settings->uints.audio_out_rate, @@ -414,7 +414,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) } audio_driver_use_float = false; - if ( audio_driver_active + if ( audio_driver_active && current_audio->use_float(audio_driver_context_audio_data)) audio_driver_use_float = true; @@ -470,7 +470,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if ( !audio_cb_inited - && audio_driver_active + && audio_driver_active && settings->bools.audio_rate_control ) { @@ -478,7 +478,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) * and buffer_size to be implemented. */ if (current_audio->buffer_size) { - audio_driver_buffer_size = + audio_driver_buffer_size = current_audio->buffer_size(audio_driver_context_audio_data); audio_driver_control = true; } @@ -516,8 +516,8 @@ void audio_driver_set_nonblocking_state(bool enable) audio_driver_context_audio_data, settings->bools.audio_sync ? enable : true); - audio_driver_chunk_size = enable ? - audio_driver_chunk_nonblock_size : + audio_driver_chunk_size = enable ? + audio_driver_chunk_nonblock_size : audio_driver_chunk_block_size; } @@ -541,7 +541,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) bool is_slowmotion = false; const void *output_data = NULL; unsigned output_frames = 0; - float audio_volume_gain = !audio_driver_mute_enable ? + float audio_volume_gain = !audio_driver_mute_enable ? audio_driver_volume_gain : 0.0f; src_data.data_in = NULL; @@ -597,7 +597,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) unsigned write_idx = audio_driver_free_samples_count++ & (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); int half_size = (int)(audio_driver_buffer_size / 2); - int avail = + int avail = (int)current_audio->write_avail(audio_driver_context_audio_data); int delta_mid = avail - half_size; double direction = (double)delta_mid / half_size; @@ -610,7 +610,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) audio_driver_free_samples_buf [write_idx] = avail; - audio_source_ratio_current = + audio_source_ratio_current = audio_source_ratio_original * adjust; #if 0 @@ -632,9 +632,9 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) if (audio_mixer_active) { - bool override = audio_driver_mixer_mute_enable ? true : + bool override = audio_driver_mixer_mute_enable ? true : (audio_driver_mixer_volume_gain != 0.0f) ? true : false; - float mixer_gain = !audio_driver_mixer_mute_enable ? + float mixer_gain = !audio_driver_mixer_mute_enable ? audio_driver_mixer_volume_gain : 0.0f; audio_mixer_mix(audio_driver_output_samples_buf, src_data.output_frames, mixer_gain, override); @@ -679,7 +679,7 @@ void audio_driver_sample(int16_t left, int16_t right) if (audio_driver_data_ptr < audio_driver_chunk_size) return; - audio_driver_flush(audio_driver_output_samples_conv_buf, + audio_driver_flush(audio_driver_output_samples_conv_buf, audio_driver_data_ptr); audio_driver_data_ptr = 0; @@ -710,8 +710,8 @@ size_t audio_driver_sample_batch(const int16_t *data, size_t frames) * @left : value of the left audio channel. * @right : value of the right audio channel. * - * Audio sample render callback function (rewind version). - * This callback function will be used instead of + * Audio sample render callback function (rewind version). + * This callback function will be used instead of * audio_driver_sample when rewinding is activated. **/ void audio_driver_sample_rewind(int16_t left, int16_t right) @@ -725,9 +725,9 @@ void audio_driver_sample_rewind(int16_t left, int16_t right) * @data : pointer to audio buffer. * @frames : amount of audio frames to push. * - * Batched audio sample render callback function (rewind version). + * Batched audio sample render callback function (rewind version). * - * This callback function will be used instead of + * This callback function will be used instead of * audio_driver_sample_batch when rewinding is activated. * * Returns: amount of frames sampled. Will be equal to @frames @@ -800,9 +800,9 @@ void audio_driver_monitor_adjust_system_rates(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); float video_refresh_rate = settings->floats.video_refresh_rate; float max_timing_skew = settings->floats.audio_max_timing_skew; - const struct retro_system_timing *info = av_info ? + const struct retro_system_timing *info = av_info ? (const struct retro_system_timing*)&av_info->timing : NULL; - + if (!info || info->sample_rate <= 0.0) return; @@ -882,7 +882,7 @@ bool audio_driver_free_devices_list(void) if (!current_audio || !current_audio->device_list_free || !audio_driver_context_audio_data) return false; - current_audio->device_list_free(audio_driver_context_audio_data, + current_audio->device_list_free(audio_driver_context_audio_data, audio_driver_devices_list); audio_driver_devices_list = NULL; return true; @@ -1003,7 +1003,7 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params) audio_mixer_stop_cb_t stop_cb = audio_mixer_play_stop_cb; bool looped = false; void *buf = NULL; - + if (audio_mixer_current_max_idx >= AUDIO_MIXER_MAX_STREAMS) return false; @@ -1132,7 +1132,7 @@ bool audio_driver_set_callback(const void *data) bool audio_driver_enable_callback(void) { if (!audio_callback.callback) - return false; + return false; if (audio_callback.set_state) audio_callback.set_state(true); return true; @@ -1152,7 +1152,7 @@ bool audio_driver_disable_callback(void) void audio_driver_monitor_set_rate(void) { settings_t *settings = config_get_ptr(); - double new_src_ratio = (double)settings->uints.audio_out_rate / + double new_src_ratio = (double)settings->uints.audio_out_rate / audio_driver_input; audio_source_ratio_original = new_src_ratio; @@ -1191,8 +1191,8 @@ bool audio_driver_mixer_toggle_mute(void) static INLINE bool audio_driver_alive(void) { - if ( current_audio - && current_audio->alive + if ( current_audio + && current_audio->alive && audio_driver_context_audio_data) return current_audio->alive(audio_driver_context_audio_data); return false; @@ -1200,7 +1200,7 @@ static INLINE bool audio_driver_alive(void) bool audio_driver_start(bool is_shutdown) { - if (!current_audio || !current_audio->start + if (!current_audio || !current_audio->start || !audio_driver_context_audio_data) goto error; if (!current_audio->start(audio_driver_context_audio_data, is_shutdown)) @@ -1218,7 +1218,7 @@ error: bool audio_driver_stop(void) { - if (!current_audio || !current_audio->stop + if (!current_audio || !current_audio->stop || !audio_driver_context_audio_data) return false; if (!audio_driver_alive()) diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 3a62b95c29..27b6a4205c 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -90,7 +90,7 @@ typedef struct audio_driver /* Is the audio driver currently running? */ bool (*alive)(void *data); - /* Should we care about blocking in audio thread? Fast forwarding. + /* Should we care about blocking in audio thread? Fast forwarding. * * If state is true, nonblocking operation is assumed. * This is typically used for fast-forwarding. If driver cannot @@ -103,7 +103,7 @@ typedef struct audio_driver void (*free)(void *data); /* Defines if driver will take standard floating point samples, - * or int16_t samples. + * or int16_t samples. * * If true is returned, the audio driver is capable of using * floating point data. This will likely increase performance as the diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 196fd201c6..76e130fd44 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -56,7 +56,7 @@ static void audio_thread_loop(void *data) return; RARCH_LOG("[Audio Thread]: Initializing audio driver.\n"); - thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency, + thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency, thr->block_frames, thr->new_rate); slock_lock(thr->lock); thr->inited = thr->driver_data ? 1 : -1; @@ -68,7 +68,7 @@ static void audio_thread_loop(void *data) if (thr->inited < 0) return; - /* Wait until we start to avoid calling + /* Wait until we start to avoid calling * stop immediately after initialization. */ slock_lock(thr->lock); while (thr->stopped) @@ -188,7 +188,7 @@ static bool audio_thread_stop(void *data) audio_thread_t *thr = (audio_thread_t*)data; if (!thr) - return false; + return false; audio_thread_block(thr); thr->is_paused = true; @@ -274,7 +274,7 @@ static const audio_driver_t audio_thread = { * * Starts a audio driver in a new thread. * Access to audio driver will be mediated through this driver. - * This driver interfaces with audio callback and is + * This driver interfaces with audio callback and is * only used in that case. * * Returns: true (1) if successful, otherwise false (0). diff --git a/audio/audio_thread_wrapper.h b/audio/audio_thread_wrapper.h index 298941d4ff..fcb2e0d028 100644 --- a/audio/audio_thread_wrapper.h +++ b/audio/audio_thread_wrapper.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index 379b579658..c2f2a13f91 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -121,7 +121,7 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency, if (snd_pcm_hw_params(alsa->pcm, params) < 0) goto error; - /* Shouldn't have to bother with this, + /* Shouldn't have to bother with this, * but some drivers are apparently broken. */ if (snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL)) snd_pcm_hw_params_get_period_size_min(params, &buffer_size, NULL); diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index 6fe075cfd9..76d442db98 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -231,7 +231,7 @@ static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) if (avail_write) { - memcpy(alsa->buffer[alsa->buffer_index] + + memcpy(alsa->buffer[alsa->buffer_index] + alsa->buffer_ptr, buf, avail_write); alsa->buffer_ptr += avail_write; @@ -355,8 +355,8 @@ static void alsa_qsa_free(void *data) static size_t alsa_qsa_write_avail(void *data) { alsa_t *alsa = (alsa_t*)data; - size_t avail = (alsa->buf_count - - (int)alsa->buffered_blocks - 1) * alsa->buf_size + + size_t avail = (alsa->buf_count - + (int)alsa->buffered_blocks - 1) * alsa->buf_size + (alsa->buf_size - (int)alsa->buffer_ptr); return avail; } @@ -364,7 +364,7 @@ static size_t alsa_qsa_write_avail(void *data) static size_t alsa_qsa_buffer_size(void *data) { alsa_t *alsa = (alsa_t*)data; - return alsa->buf_size * alsa->buf_count; + return alsa->buf_size * alsa->buf_count; } audio_driver_t audio_alsa = { diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index e6206eb65b..b01b6a424a 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -77,7 +77,7 @@ static void alsa_worker_thread(void *data) frames = snd_pcm_writei(alsa->pcm, buf, alsa->period_frames); - if (frames == -EPIPE || frames == -EINTR || + if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { if (snd_pcm_recover(alsa->pcm, frames, 1) < 0) @@ -192,7 +192,7 @@ static void *alsa_thread_init(const char *device, TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params)); - /* Shouldn't have to bother with this, + /* Shouldn't have to bother with this, * but some drivers are apparently broken. */ if (snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL)) snd_pcm_hw_params_get_period_size_min( diff --git a/audio/drivers/coreaudio.c b/audio/drivers/coreaudio.c index 02ff2c6b9a..6f255bbc5b 100644 --- a/audio/drivers/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2014 - Chris Moeller - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -112,7 +112,7 @@ static OSStatus audio_write_cb(void *userdata, slock_unlock(dev->lock); /* Technically possible to deadlock without. */ - scond_signal(dev->cond); + scond_signal(dev->cond); return noErr; } @@ -169,10 +169,10 @@ static void choose_output_device(coreaudio_t *dev, const char* device) size = 1024; if (AudioObjectGetPropertyData(devices[i], - &propaddr, 0, 0, &size, device_name) == noErr + &propaddr, 0, 0, &size, device_name) == noErr && string_is_equal(device_name, device)) { - AudioUnitSetProperty(dev->dev, kAudioOutputUnitProperty_CurrentDevice, + AudioUnitSetProperty(dev->dev, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &devices[i], sizeof(AudioDeviceID)); goto done; } @@ -244,7 +244,7 @@ static void *coreaudio_init(const char *device, #endif if (comp == NULL) goto error; - + #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr); #else @@ -269,17 +269,17 @@ static void *coreaudio_init(const char *device, stream_desc.mBytesPerFrame = 2 * sizeof(float); stream_desc.mFramesPerPacket = 1; stream_desc.mFormatID = kAudioFormatLinearPCM; - stream_desc.mFormatFlags = kAudioFormatFlagIsFloat | - kAudioFormatFlagIsPacked | (is_little_endian() ? + stream_desc.mFormatFlags = kAudioFormatFlagIsFloat | + kAudioFormatFlagIsPacked | (is_little_endian() ? 0 : kAudioFormatFlagIsBigEndian); - + if (AudioUnitSetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &stream_desc, sizeof(stream_desc)) != noErr) goto error; - + /* Check returned audio format. */ i_size = sizeof(real_desc); - if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, + if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &real_desc, &i_size) != noErr) goto error; diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 4765cd7f5c..8731706c32 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -49,7 +49,7 @@ typedef struct static void ctr_csnd_audio_update_playpos(ctr_csnd_audio_t* ctr) { uint64_t current_tick = svcGetSystemTick(); - uint32_t samples_played = (current_tick - ctr->cpu_ticks_last) + uint32_t samples_played = (current_tick - ctr->cpu_ticks_last) / CTR_CSND_CPU_TICKS_PER_SAMPLE; ctr->playpos = (ctr->playpos + samples_played) & CTR_CSND_AUDIO_COUNT_MASK; @@ -94,7 +94,7 @@ Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan, if (loopMode == CSND_LOOPMODE_NORMAL && paddr1 > paddr0) { - /* Now that the first block is playing, + /* Now that the first block is playing, * configure the size of the subsequent blocks */ size -= paddr1 - paddr0; CSND_SetBlock(chn, 1, paddr1, size); @@ -209,7 +209,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) } static bool ctr_csnd_audio_stop(void *data) -{ +{ ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data; /* using SetPlayState would make tracking the playback diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index 9514236f4a..09b8119f87 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr, struct audio_lock *region) { const char *err = NULL; - HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, + HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); if (res == DSERR_BUFFERLOST) @@ -152,7 +152,7 @@ static void dsound_thread(void *data) struct audio_lock region; DWORD read_ptr, avail, fifo_avail; get_positions(ds, &read_ptr, NULL); - + avail = write_avail(read_ptr, write_ptr, ds->buffer_size); EnterCriticalSection(&ds->crit); @@ -161,12 +161,12 @@ static void dsound_thread(void *data) if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2))) { - /* No space to write, or we don't have data in our fifo, + /* No space to write, or we don't have data in our fifo, * but we can wait some time before it underruns ... */ /* We could opt for using the notification interface, - * but it is not guaranteed to work, so use high + * but it is not guaranteed to work, so use high * priority sleeping patterns. */ retro_sleep(1); @@ -182,7 +182,7 @@ static void dsound_thread(void *data) if (fifo_avail < CHUNK_SIZE) { - /* Got space to write, but nothing in FIFO (underrun), + /* Got space to write, but nothing in FIFO (underrun), * fill block with silence. */ memset(region.chunk1, 0, region.size1); @@ -191,7 +191,7 @@ static void dsound_thread(void *data) release_region(ds, ®ion); write_ptr = (write_ptr + region.size1 + region.size2) % ds->buffer_size; } - else + else { /* All is good. Pull from it and notify FIFO. */ diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 7453060881..5e840a933f 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -129,9 +129,9 @@ static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) if (frames < to_write) to_write = frames; - /* FIXME: Nonblocking audio should break out of loop + /* FIXME: Nonblocking audio should break out of loop * when it has nothing to write. */ - while ((wa->dma_write == wa->dma_next || + while ((wa->dma_write == wa->dma_next || wa->dma_write == wa->dma_busy) && !wa->nonblock) OSSleepThread(wa->cond); diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 9b0758175f..40a116f292 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -181,7 +181,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency, RARCH_ERR("[JACK]: Failed to register ports.\n"); goto error; } - + jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput); if (jports == NULL) { @@ -222,7 +222,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency, for (i = 0; i < parsed; i++) free(dest_ports[i]); - + jack_free(jports); return jd; diff --git a/audio/drivers/nullaudio.c b/audio/drivers/nullaudio.c index d0d9c0d36b..39be26d4d0 100644 --- a/audio/drivers/nullaudio.c +++ b/audio/drivers/nullaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/openal.c b/audio/drivers/openal.c index 69964f4225..6127ca9b4d 100644 --- a/audio/drivers/openal.c +++ b/audio/drivers/openal.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/opensl.c b/audio/drivers/opensl.c index fef08db8f2..113bce3567 100644 --- a/audio/drivers/opensl.c +++ b/audio/drivers/opensl.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -200,7 +200,7 @@ error: static bool sl_stop(void *data) { sl_t *sl = (sl_t*)data; - sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED) + sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED) == SL_RESULT_SUCCESS) ? true : false; return sl->is_paused ? true : false; diff --git a/audio/drivers/oss.c b/audio/drivers/oss.c index d6d4d28ffa..1c6691187e 100644 --- a/audio/drivers/oss.c +++ b/audio/drivers/oss.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -51,7 +51,7 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency, int frags, frag, channels, format, new_rate; int *fd = (int*)calloc(1, sizeof(int)); const char *oss_device = device ? device : DEFAULT_OSS_DEV; - + if (!fd) return NULL; diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index 0d4e56e467..1f5eba29b6 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -110,11 +110,11 @@ static void *ps3_audio_init(const char *device, return NULL; } - data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES * + data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS * AUDIO_BLOCKS * sizeof(float)); #ifdef __PSL1GHT__ - sys_lwmutex_attr_t lock_attr = + sys_lwmutex_attr_t lock_attr = {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"}; sys_lwmutex_attr_t cond_lock_attr = {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"}; diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 808f21e3e5..49c3362440 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -50,6 +50,9 @@ typedef struct psp_audio char lock[32] __attribute__ ((aligned (8))); char cond_lock[32] __attribute__ ((aligned (8))); char cond[32] __attribute__ ((aligned (8))); +#else + SceUID lock; + SceUID cond; #endif } psp_audio_t; @@ -83,15 +86,13 @@ static int audioMainLoop(SceSize args, void* argp) #ifdef VITA sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0); +#else + sceKernelWaitSema(psp->lock, 1, 0); #endif cond = ((uint16_t)(psp->write_pos - read_pos) & AUDIO_BUFFER_SIZE_MASK) < (AUDIO_OUT_COUNT * 2); -#ifndef VITA - sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer) - : (psp->buffer + read_pos)); -#endif if (!cond) { read_pos += AUDIO_OUT_COUNT; @@ -106,6 +107,13 @@ static int audioMainLoop(SceSize args, void* argp) sceAudioOutOutput(port, cond ? (psp->zeroBuffer) : (psp->buffer + read_pos_2)); +#else + sceKernelSignalSema(psp->lock, 1); + if(!cond){ + sceKernelSignalSema(psp->cond, 1); + } + sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer) + : (psp->buffer + read_pos)); #endif } @@ -151,6 +159,8 @@ static void *psp_audio_init(const char *device, psp->thread = sceKernelCreateThread ("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL); #else + psp->cond=sceKernelCreateSema("audio_start_sema", 0, 0, 1, NULL); + psp->lock=sceKernelCreateSema("audio_lock_sema", 0, 1, 1, NULL); psp->thread = sceKernelCreateThread ("audioMainLoop", audioMainLoop, 0x08, 0x10000, 0, NULL); #endif @@ -177,6 +187,8 @@ static void psp_audio_free(void *data) sceKernelDeleteLwCond((struct SceKernelLwCondWork*)&psp->cond); #else sceKernelWaitThreadEnd(psp->thread, &timeout); + sceKernelDeleteSema(psp->lock); + sceKernelDeleteSema(psp->cond); #endif free(psp->buffer); sceKernelDeleteThread(psp->thread); @@ -192,9 +204,11 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) if (psp->nonblocking) { +//#ifdef VITA if (AUDIO_BUFFER_SIZE - ((uint16_t) (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size) - return 0; + return 0; +//#endif } #ifdef VITA @@ -203,6 +217,11 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) sceKernelWaitLwCond((struct SceKernelLwCondWork*)&psp->cond, 0); sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0); +#else + while (AUDIO_BUFFER_SIZE - ((uint16_t) + (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size) + sceKernelWaitSema(psp->cond, 1, 0); + sceKernelWaitSema(psp->lock, 1, 0); #endif if((write_pos + sampleCount) > AUDIO_BUFFER_SIZE) @@ -225,7 +244,9 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) return size; #else - return sampleCount; + sceKernelSignalSema(psp->lock, 1); + + return size; #endif } @@ -244,9 +265,9 @@ static bool psp_audio_stop(void *data) SceUInt timeout = 100000; psp_audio_t* psp = (psp_audio_t*)data; - if(psp && !psp->running) + if(psp && !psp->running) return true; - + info.size = sizeof(SceKernelThreadInfo); if (sceKernelGetThreadInfo( @@ -269,8 +290,8 @@ static bool psp_audio_start(void *data, bool is_shutdown) { SceKernelThreadInfo info; psp_audio_t* psp = (psp_audio_t*)data; - - if(psp && psp->running) + + if(psp && psp->running) return true; info.size = sizeof(SceKernelThreadInfo); @@ -309,6 +330,8 @@ static size_t psp_write_avail(void *data) #ifdef VITA sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0); +#else + sceKernelWaitSema(psp->lock, 1, 0); #endif val = AUDIO_BUFFER_SIZE - ((uint16_t) @@ -316,6 +339,8 @@ static size_t psp_write_avail(void *data) #ifdef VITA sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1); +#else + sceKernelSignalSema(psp->lock, 1); #endif return val; diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index 61e47fd08f..ce3e94bd5e 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -88,7 +88,7 @@ static void context_state_cb(pa_context *c, void *data) } } -static void stream_state_cb(pa_stream *s, void *data) +static void stream_state_cb(pa_stream *s, void *data) { pa_t *pa = (pa_t*)data; @@ -104,7 +104,7 @@ static void stream_state_cb(pa_stream *s, void *data) } } -static void stream_request_cb(pa_stream *s, size_t length, void *data) +static void stream_request_cb(pa_stream *s, size_t length, void *data) { pa_t *pa = (pa_t*)data; @@ -114,7 +114,7 @@ static void stream_request_cb(pa_stream *s, size_t length, void *data) pa_threaded_mainloop_signal(pa->mainloop, 0); } -static void stream_latency_update_cb(pa_stream *s, void *data) +static void stream_latency_update_cb(pa_stream *s, void *data) { pa_t *pa = (pa_t*)data; @@ -149,7 +149,7 @@ static void buffer_attr_cb(pa_stream *s, void *data) } static void *pulse_init(const char *device, unsigned rate, - unsigned latency, + unsigned latency, unsigned block_frames, unsigned *new_rate) { @@ -232,7 +232,7 @@ static void *pulse_init(const char *device, unsigned rate, unlock_error: pa_threaded_mainloop_unlock(pa->mainloop); error: - pulse_free(pa); + pulse_free(pa); return NULL; } diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 7e08f74749..815e5ade96 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/rsound.c b/audio/drivers/rsound.c index 258f42aa2a..c6241c51d5 100644 --- a/audio/drivers/rsound.c +++ b/audio/drivers/rsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/rsound.h b/audio/drivers/rsound.h index 645eaa8316..236eeb16e6 100644 --- a/audio/drivers/rsound.h +++ b/audio/drivers/rsound.h @@ -1,6 +1,6 @@ /* RSound - A PCM audio client/server * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RSound is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ RETRO_BEGIN_DECLS #endif /* Feature tests */ -#define RSD_SAMPLERATE RSD_SAMPLERATE +#define RSD_SAMPLERATE RSD_SAMPLERATE #define RSD_CHANNELS RSD_CHANNELS #define RSD_HOST RSD_HOST #define RSD_PORT RSD_PORT @@ -125,7 +125,7 @@ enum rsd_settings /* Audio callback for rsd_set_callback. Return -1 to trigger an error in the stream. */ typedef ssize_t (*rsd_audio_callback_t)(void *data, size_t bytes, void *userdata); -/* Error callback. Signals caller that stream has been stopped, +/* Error callback. Signals caller that stream has been stopped, * either by audio callback returning -1 or stream was hung up. */ typedef void (*rsd_error_callback_t)(void *userdata); @@ -144,7 +144,7 @@ typedef struct rsound int conn_type; volatile int buffer_pointer; /* Obsolete, but kept for backwards header compatibility. */ - size_t buffer_size; + size_t buffer_size; fifo_buffer_t *fifo_buffer; volatile int thread_active; @@ -196,13 +196,13 @@ typedef struct rsound rsd_set_param(rd, RSD_HOST, "foohost"); *sets more params* rsd_start(rd); - rsd_write(rd, buf, size); + rsd_write(rd, buf, size); rsd_stop(rd); rsd_free(rd); */ int rsd_init (rsound_t **rd); -/* This is a simpler function that initializes an rsound struct, sets params as given, +/* This is a simpler function that initializes an rsound struct, sets params as given, and starts the stream. Should this function fail, the structure will stay uninitialized. Should NULL be passed in either host, port or ident, defaults will be used. */ @@ -211,29 +211,29 @@ int rsd_simple_start (rsound_t **rd, const char* host, const char* port, const c /* Sets params associated with an rsound_t. These options (int options) include: -RSD_HOST: Server to connect to. Expects (char *) in param. -If not set, will default to environmental variable RSD_SERVER or "localhost". +RSD_HOST: Server to connect to. Expects (char *) in param. +If not set, will default to environmental variable RSD_SERVER or "localhost". -RSD_PORT: Set port. Expects (char *) in param. +RSD_PORT: Set port. Expects (char *) in param. If not set, will default to environmental variable RSD_PORT or "12345". RSD_CHANNELS: Set number of audio channels. Expects (int *) in param. Mandatory. RSD_SAMPLERATE: Set samplerate of audio stream. Expects (int *) in param. Mandatory. -RSD_BUFSIZE: Sets internal buffersize for the stream. -Might be overridden if too small. +RSD_BUFSIZE: Sets internal buffersize for the stream. +Might be overridden if too small. Expects (int *) in param. Optional. -RSD_LATENCY: Sets maximum audio latency in milliseconds, -(must be used with rsd_delay_wait() or this will have no effect). -Most applications do not need this. -Might be overridden if too small. +RSD_LATENCY: Sets maximum audio latency in milliseconds, +(must be used with rsd_delay_wait() or this will have no effect). +Most applications do not need this. +Might be overridden if too small. Expects (int *) in param. Optional. -RSD_FORMAT: Sets sample format. -It defaults to S16_LE, so you probably will not use this. -Expects (int *) in param, with available values found in the format enum. +RSD_FORMAT: Sets sample format. +It defaults to S16_LE, so you probably will not use this. +Expects (int *) in param, with available values found in the format enum. If invalid format is given, param might be changed to reflect the sample format the library will use. RSD_IDENTITY: Sets an identity string associated with the client. @@ -244,14 +244,14 @@ Will be truncated if longer than 256 bytes. int rsd_set_param (rsound_t *rd, enum rsd_settings option, void* param); -/* Enables use of the callback interface. This must be set when stream is not active. - When callback is active, use of the blocking interface is disabled. - Only valid functions to call after rsd_start() is stopping the stream with either rsd_pause() or rsd_stop(). Calling any other function is undefined. - The callback is called at regular intervals and is asynchronous, so thread safety must be ensured by the caller. - If not enough data can be given to the callback, librsound will fill the rest of the callback data with silence. +/* Enables use of the callback interface. This must be set when stream is not active. + When callback is active, use of the blocking interface is disabled. + Only valid functions to call after rsd_start() is stopping the stream with either rsd_pause() or rsd_stop(). Calling any other function is undefined. + The callback is called at regular intervals and is asynchronous, so thread safety must be ensured by the caller. + If not enough data can be given to the callback, librsound will fill the rest of the callback data with silence. librsound will attempt to obey latency information given with RSD_LATENCY as given before calling rsd_start(). max_size signifies the maximum size that will ever be requested by librsound. Set this to 0 to let librsound decide the maximum size. - Should an error occur to the stream, err_callback will be called, and the stream will be stopped. The stream can be started again. + Should an error occur to the stream, err_callback will be called, and the stream will be stopped. The stream can be started again. Callbacks can be disabled by setting callbacks to NULL. */ @@ -260,37 +260,37 @@ void rsd_set_callback (rsound_t *rd, rsd_audio_callback_t callback, rsd_error_ca /* Lock and unlock the callback. When the callback lock is aquired, the callback is guaranteed to not be executing. The lock has to be unlocked afterwards. Attemping to call several rsd_callback_lock() in succession might cause a deadlock. - The lock should be held for as short period as possible. + The lock should be held for as short period as possible. Try to avoid calling code that may block when holding the lock. */ void rsd_callback_lock (rsound_t *rd); void rsd_callback_unlock (rsound_t *rd); -/* Establishes connection to server. Might fail if connection can't be established or that one of +/* Establishes connection to server. Might fail if connection can't be established or that one of the mandatory options isn't set in rsd_set_param(). This needs to be called after params have been set - with rsd_set_param(), and before rsd_write(). */ + with rsd_set_param(), and before rsd_write(). */ int rsd_start (rsound_t *rd); /* Shuts down the rsound data structures, but returns the file descriptor associated with the connection. - The control socket will be shut down. If this function returns a negative number, the exec failed, - but the data structures will not be teared down. + The control socket will be shut down. If this function returns a negative number, the exec failed, + but the data structures will not be teared down. Should a valid file descriptor be returned, it will always be blocking. This call will block until all internal buffers have been sent to the network. */ int rsd_exec (rsound_t *rd); -/* Disconnects from server. All audio data still in network buffer and other buffers will be dropped. +/* Disconnects from server. All audio data still in network buffer and other buffers will be dropped. To continue playing, you will need to rsd_start() again. */ int rsd_stop (rsound_t *rd); -/* Writes from buf to the internal buffer. Might fail if no connection is established, +/* Writes from buf to the internal buffer. Might fail if no connection is established, or there was an unexpected error. This function will block until all data has been written to the buffer. This function will return the number of bytes written to the buffer, or 0 should it fail (disconnection from server). You will have to restart the stream again should this occur. */ size_t rsd_write (rsound_t *rd, const void* buf, size_t size); -/* Gets the position of the buffer pointer. - Not really interesting for normal applications. - Might be useful for implementing rsound on top of other blocking APIs. +/* Gets the position of the buffer pointer. + Not really interesting for normal applications. + Might be useful for implementing rsound on top of other blocking APIs. *NOTE* This function is deprecated, it should not be used in new applications. */ size_t rsd_pointer (rsound_t *rd); @@ -306,12 +306,12 @@ size_t rsd_delay_ms (rsound_t *rd); /* Returns bytes per sample */ int rsd_samplesize(rsound_t *rd); -/* Will sleep until latency of stream reaches maximum allowed latency defined earlier by rsd_set_param - RSD_LATENCY +/* Will sleep until latency of stream reaches maximum allowed latency defined earlier by rsd_set_param - RSD_LATENCY Useful for hard headed blocking I/O design where user defined latency is needed. If rsd_set_param hasn't been set with RSD_LATENCY, this function will do nothing. */ void rsd_delay_wait(rsound_t *rd); -/* Pauses or unpauses a stream. pause -> enable = 1 +/* Pauses or unpauses a stream. pause -> enable = 1 This function essentially calls on start() and stop(). This behavior might be changed later. */ int rsd_pause (rsound_t *rd, int enable); diff --git a/audio/drivers/rwebaudio.c b/audio/drivers/rwebaudio.c index 5a90e69233..3e819b2049 100644 --- a/audio/drivers/rwebaudio.c +++ b/audio/drivers/rwebaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index 49703948a2..31152a644b 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ static void *sdl_audio_init(const char *device, if (!sdl) return NULL; - /* We have to buffer up some data ourselves, so we let SDL + /* We have to buffer up some data ourselves, so we let SDL * carry approximately half of the latency. * * SDL double buffers audio and we do as well. */ @@ -119,7 +119,7 @@ static void *sdl_audio_init(const char *device, sdl->cond = scond_new(); #endif - RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n", + RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / (*new_rate))); /* Create a buffer twice as big as needed and prefill the buffer. */ diff --git a/audio/drivers/tinyalsa.c b/audio/drivers/tinyalsa.c index 08e8ea4a1a..bb12d3a253 100644 --- a/audio/drivers/tinyalsa.c +++ b/audio/drivers/tinyalsa.c @@ -30,7 +30,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2017 - Charlton Head - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -508,7 +508,7 @@ struct snd_pcm_sw_params struct snd_pcm_hw_params { unsigned int flags; - struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; struct snd_mask mres[5]; /* reserved masks */ struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - @@ -2320,7 +2320,7 @@ tinyalsa_write(void *data, const void *buf_, size_t size_) } } - return written; + return written; } @@ -2366,7 +2366,7 @@ tinyalsa_start(void *data, bool is_shutdown) RARCH_ERR("[TINYALSA]: Failed to unpause.\n"); return false; } - + tinyalsa->is_paused = false; } @@ -2414,7 +2414,7 @@ static size_t tinyalsa_write_avail(void *data) static size_t tinyalsa_buffer_size(void *data) { tinyalsa_t *tinyalsa = (tinyalsa_t*)data; - + return tinyalsa->buffer_size; } diff --git a/audio/drivers/wasapi.c b/audio/drivers/wasapi.c index 973be6411c..249ab3589d 100644 --- a/audio/drivers/wasapi.c +++ b/audio/drivers/wasapi.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -15,7 +15,7 @@ #include -#ifdef _WIN32_WINNT +#ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif #define _WIN32_WINNT 0x0600 @@ -40,7 +40,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0 #ifdef __cplusplus #define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->Item(nDevice,ppdevice) -#define _IAudioClient_Start(This) ( (This)->Start() ) +#define _IAudioClient_Start(This) ( (This)->Start() ) #define _IAudioClient_Stop(This) ( (This)->Stop() ) #define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \ ( (This)->GetCurrentPadding(pNumPaddingFrames) ) @@ -62,7 +62,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0 #define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->GetCount(cProps) ) #else #define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice) -#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) ) +#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) ) #define _IAudioClient_Stop(This) ( (This)->lpVtbl -> Stop(This) ) #define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \ ( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) ) @@ -163,7 +163,7 @@ static bool wasapi_check_device_id(IMMDevice *device, const char *id) id_length = MultiByteToWideChar(CP_ACP, 0, id, -1, dev_cmp_id, id_length); WASAPI_SR_CHECK(id_length > 0, "MultiByteToWideChar", goto error); - + hr = _IMMDevice_GetId(device, &dev_id); WASAPI_HR_CHECK(hr, "IMMDevice::GetId", goto error); @@ -306,7 +306,7 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, bool float_fmt_res = *float_fmt; unsigned rate_res = *rate; HRESULT hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -336,9 +336,10 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, if (hr == AUDCLNT_E_ALREADY_INITIALIZED) { + HRESULT hr; WASAPI_RELEASE(client); - HRESULT hr = _IMMDevice_Activate(device, - IID_IAudioClient, + hr = _IMMDevice_Activate(device, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -390,7 +391,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, REFERENCE_TIME buffer_duration = 0; UINT32 buffer_length = 0; HRESULT hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -432,7 +433,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -451,7 +452,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, { WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -668,7 +669,7 @@ static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency, error: WASAPI_RELEASE(w->renderer); - WASAPI_RELEASE(w->client); + WASAPI_RELEASE(w->client); WASAPI_RELEASE(w->device); if (w->write_event) CloseHandle(w->write_event); @@ -1044,7 +1045,7 @@ static size_t wasapi_write_avail(void *wh) hr = _IAudioClient_GetCurrentPadding(w->client, &padding); WASAPI_HR_CHECK(hr, "IAudioClient::GetCurrentPadding", return 0); - + return w->engine_buffer_size - padding * w->frame_size; } diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index cae0f8a289..f3c81a1741 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -69,7 +69,7 @@ struct xaudio2 virtual ~xaudio2() {} STDMETHOD_(void, OnBufferStart) (void *) {} - STDMETHOD_(void, OnBufferEnd) (void *) + STDMETHOD_(void, OnBufferEnd) (void *) { InterlockedDecrement((LONG volatile*)&buffers); SetEvent(hEvent); @@ -96,27 +96,27 @@ struct xaudio2 }; #ifndef __cplusplus -static void WINAPI voice_on_buffer_end(void *handle_, void *data) -{ - xaudio2_t *handle = (xaudio2_t*)handle_; - (void)data; - InterlockedDecrement((LONG volatile*)&handle->buffers); - SetEvent(handle->hEvent); -} +static void WINAPI voice_on_buffer_end(void *handle_, void *data) +{ + xaudio2_t *handle = (xaudio2_t*)handle_; + (void)data; + InterlockedDecrement((LONG volatile*)&handle->buffers); + SetEvent(handle->hEvent); +} -static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } -static void WINAPI dummy_nil(void *handle) { (void)handle; } -static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } -static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } +static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } +static void WINAPI dummy_nil(void *handle) { (void)handle; } +static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } +static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } -const struct IXAudio2VoiceCallbackVtbl voice_vtable = { - dummy_uint32, - dummy_nil, - dummy_nil, - dummy_voidp, - voice_on_buffer_end, - dummy_voidp, - dummy_voidp_hresult, +const struct IXAudio2VoiceCallbackVtbl voice_vtable = { + dummy_uint32, + dummy_nil, + dummy_nil, + dummy_voidp, + voice_on_buffer_end, + dummy_voidp, + dummy_voidp_hresult, }; #endif @@ -225,9 +225,9 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, xaudio2_set_wavefmt(&wfx, channels, samplerate); - if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2, - &handle->pSourceVoice, &wfx, - XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, + if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2, + &handle->pSourceVoice, &wfx, + XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, (IXAudio2VoiceCallback*)handle, 0, 0))) goto error; @@ -240,7 +240,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, if (!handle->buf) goto error; - if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0, + if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0, XAUDIO2_COMMIT_NOW))) goto error; @@ -265,7 +265,7 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_) { unsigned need = MIN(bytes, handle->bufsize - handle->bufptr); - memcpy(handle->buf + handle->write_buffer * + memcpy(handle->buf + handle->write_buffer * handle->bufsize + handle->bufptr, buffer, need); diff --git a/audio/drivers/xaudio.h b/audio/drivers/xaudio.h index 41e21be09d..4c03e60035 100644 --- a/audio/drivers/xaudio.h +++ b/audio/drivers/xaudio.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2010-2014 - OV2 - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -58,7 +58,7 @@ DEFINE_IID(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb); #include #ifndef __cplusplus -#undef OPAQUE +#undef OPAQUE #define OPAQUE struct #endif @@ -131,7 +131,7 @@ typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER typedef enum XAUDIO2_FILTER_TYPE { LowPassFilter, BandPassFilter, - HighPassFilter + HighPassFilter } XAUDIO2_FILTER_TYPE; typedef struct XAUDIO2_DEVICE_DETAILS @@ -294,27 +294,27 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) #ifdef __cplusplus /* C++ hooks */ -#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) -#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) -#define IXAudio2SourceVoice_Stop(handle, a, b) handle->Stop(a, b) -#define IXAudio2SourceVoice_DestroyVoice(handle) handle->DestroyVoice() -#define IXAudio2MasteringVoice_DestroyVoice(handle) handle->DestroyVoice() -#define IXAudio2_Release(handle) handle->Release() -#define IXAudio2_CreateSourceVoice(handle, a, b, c, d, e, f, g) handle->CreateSourceVoice(a, b, c, d, e, f, g) -#define IXAudio2_CreateMasteringVoice(handle, a, b, c, d, e, f) handle->CreateMasteringVoice(a, b, c, d, e, f) -#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) +#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) +#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) +#define IXAudio2SourceVoice_Stop(handle, a, b) handle->Stop(a, b) +#define IXAudio2SourceVoice_DestroyVoice(handle) handle->DestroyVoice() +#define IXAudio2MasteringVoice_DestroyVoice(handle) handle->DestroyVoice() +#define IXAudio2_Release(handle) handle->Release() +#define IXAudio2_CreateSourceVoice(handle, a, b, c, d, e, f, g) handle->CreateSourceVoice(a, b, c, d, e, f, g) +#define IXAudio2_CreateMasteringVoice(handle, a, b, c, d, e, f) handle->CreateMasteringVoice(a, b, c, d, e, f) +#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) #else /* C hooks */ -#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) -#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) -#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) -#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) -#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) -#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) -#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) -#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) +#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) +#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) +#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) +#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) +#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) +#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) +#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) +#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) +#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) +#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) #define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) #endif @@ -324,16 +324,11 @@ STDAPI XAudio2Create(__deref_out IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0) #else static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_PROCESSOR proc) { - HRESULT hr; IXAudio2 *pXAudio2 = NULL; - - (void)flags; - (void)proc; - #ifdef __cplusplus - hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2); + HRESULT hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2); #else - hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2); + HRESULT hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2); #endif if (SUCCEEDED(hr)) @@ -342,9 +337,7 @@ static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_ if (SUCCEEDED(hr)) *ppXAudio2 = pXAudio2; else - { IXAudio2_Release(pXAudio2); - } } return hr; } diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index b72e01fc4d..fdcd585572 100644 --- a/audio/drivers/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -70,7 +70,7 @@ static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size) { while (xenon_sound_get_unplayed() >= MAX_BUFFER) { - /* libxenon doesn't have proper + /* libxenon doesn't have proper * synchronization primitives for this... */ udelay(50); } diff --git a/audio/drivers_resampler/cc_resampler.c b/audio/drivers_resampler/cc_resampler.c index b743338f10..5a3f920431 100644 --- a/audio/drivers_resampler/cc_resampler.c +++ b/audio/drivers_resampler/cc_resampler.c @@ -498,12 +498,12 @@ static void *resampler_CC_init(const struct resampler_config *config, rarch_CC_resampler_t *re = (rarch_CC_resampler_t*) memalign_alloc(32, sizeof(rarch_CC_resampler_t)); - /* TODO: lookup if NEON support can be detected at + /* TODO: lookup if NEON support can be detected at * runtime and a funcptr set at runtime for either * C codepath or NEON codepath. This will help out * Android. */ (void)mask; - (void)config; + (void)config; if (!re) return NULL; diff --git a/audio/librsound.c b/audio/librsound.c index 273fc13334..da2aaeaa86 100644 --- a/audio/librsound.c +++ b/audio/librsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ /* RSound - A PCM audio client/server * Copyright (C) 2010 - Hans-Kristian Arntzen - * + * * RSound is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include #include @@ -75,8 +75,8 @@ #include #include -/* - **************************************************************************** +/* + **************************************************************************** Naming convention. Functions for use in API are called rsd_*(), * internal function are called rsnd_*() * **************************************************************************** @@ -251,7 +251,7 @@ static int rsnd_connect_server( rsound_t *rd ) if ( rd->conn.ctl_socket < 0 ) goto error; - /* Uses non-blocking IO since it performed more deterministic with poll()/send() */ + /* Uses non-blocking IO since it performed more deterministic with poll()/send() */ #ifdef __CELLOS_LV2__ setsockopt(rd->conn.socket, SOL_SOCKET, SO_NBIO, &i, sizeof(int)); @@ -302,7 +302,7 @@ static int rsnd_send_header_info(rsound_t *rd) uint16_t temp16; uint32_t temp32; - /* These magic numbers represent the position of the elements in the wave header. + /* These magic numbers represent the position of the elements in the wave header. We can't simply send a wave struct over the network since the compiler is allowed to pad our structs as they like, so sizeof(waveheader) might not be similar on two different systems. */ @@ -353,7 +353,7 @@ static int rsnd_send_header_info(rsound_t *rd) } /* Since the values in the wave header we are interested in, are little endian (>_<), we need - to determine whether we're running it or not, so we can byte swap accordingly. + to determine whether we're running it or not, so we can byte swap accordingly. Could determine this compile time, but it was simpler to do it this way. */ // Fancy macros for embedding little endian values into the header. @@ -501,7 +501,7 @@ static int rsnd_get_backend_info ( rsound_t *rd ) // Can we read the last 8 bytes so we can use the protocol interface? // This is non-blocking. if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 0) == RSND_HEADER_SIZE ) - rd->conn_type |= RSD_CONN_PROTO; + rd->conn_type |= RSD_CONN_PROTO; else { RSD_DEBUG("[RSound] Failed to get new proto.\n"); } @@ -515,7 +515,7 @@ static int rsnd_get_backend_info ( rsound_t *rd ) return 0; } -/* Makes sure that we're connected and done with wave header handshaking. Returns -1 on error, and 0 on success. +/* Makes sure that we're connected and done with wave header handshaking. Returns -1 on error, and 0 on success. This goes for all other functions in use. */ static int rsnd_create_connection(rsound_t *rd) { @@ -750,7 +750,7 @@ static int64_t rsnd_get_time_usec(void) /* Calculates how many bytes there are in total in the virtual buffer. This is calculated client side. It should be accurate enough unless we have big problems with buffer underruns. - This function is called by rsd_delay() to determine the latency. + This function is called by rsd_delay() to determine the latency. This function might be changed in the future to correctly determine latency from server. */ static void rsnd_drain(rsound_t *rd) { @@ -777,7 +777,7 @@ static void rsnd_drain(rsound_t *rd) } /* Tries to fill the buffer. Uses signals to determine when the buffer is ready to be filled. Should the thread not be active - it will treat this as an error. Crude implementation of a blocking FIFO. */ + it will treat this as an error. Crude implementation of a blocking FIFO. */ static size_t rsnd_fill_buffer(rsound_t *rd, const char *buf, size_t size) { @@ -851,7 +851,7 @@ static int rsnd_stop_thread(rsound_t *rd) sthread_join(rd->thread.thread); RSD_DEBUG("[RSound] Thread joined successfully.\n"); - + return 0; } else @@ -981,7 +981,7 @@ static int rsnd_close_ctl(rsound_t *rd) } -// Sends delay info request to server on the ctl socket. This code section isn't critical, and will work if it works. +// Sends delay info request to server on the ctl socket. This code section isn't critical, and will work if it works. // It will never block. static int rsnd_send_info_query(rsound_t *rd) { @@ -1111,7 +1111,7 @@ static void rsnd_thread ( void * thread_data ) // We only bother to check after 1 sec of audio has been played, as it might be quite inaccurate in the start of the stream. if ( (rd->conn_type & RSD_CONN_PROTO) && (rd->total_written > rd->channels * rd->rate * rd->samplesize) ) { - rsnd_send_info_query(rd); + rsnd_send_info_query(rd); rsnd_update_server_info(rd); } @@ -1263,7 +1263,7 @@ static void rsnd_cb_thread(void *thread_data) if ( (rd->conn_type & RSD_CONN_PROTO) && (rd->total_written > rd->channels * rd->rate * rd->samplesize) ) { - rsnd_send_info_query(rd); + rsnd_send_info_query(rd); rsnd_update_server_info(rd); } @@ -1304,7 +1304,7 @@ int rsd_stop(rsound_t *rd) const char buf[] = "RSD 5 STOP"; - // Do not really care about errors here. + // Do not really care about errors here. // The socket will be closed down in any case in rsnd_reset(). rsnd_send_chunk(rd->conn.ctl_socket, buf, strlen(buf), 0); @@ -1325,7 +1325,7 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size) while ( written < size ) { - size_t write_size = (size - written) > max_write ? max_write : (size - written); + size_t write_size = (size - written) > max_write ? max_write : (size - written); size_t result = rsnd_fill_buffer(rsound, (const char*)buf + written, write_size); if (result == 0) @@ -1454,7 +1454,7 @@ int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param) rd->max_latency = *((int*)param); break; - // Checks if format is valid. + // Checks if format is valid. case RSD_FORMAT: rd->format = (uint16_t)(*((int*)param)); rd->samplesize = rsnd_format_to_samplesize(rd->format); @@ -1509,7 +1509,7 @@ size_t rsd_pointer(rsound_t *rsound) retro_assert(rsound != NULL); int ptr; - ptr = rsnd_get_ptr(rsound); + ptr = rsnd_get_ptr(rsound); return ptr; } diff --git a/autosave.h b/autosave.h index 39cfe8a7a1..1421d60436 100644 --- a/autosave.h +++ b/autosave.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/bootstrap/psp1/kernel_functions_prx/Makefile b/bootstrap/psp1/kernel_functions_prx/Makefile index 0b6cdc3d41..810ade49ca 100644 --- a/bootstrap/psp1/kernel_functions_prx/Makefile +++ b/bootstrap/psp1/kernel_functions_prx/Makefile @@ -14,7 +14,7 @@ USE_KERNEL_LIBC=1 USE_KERNEL_LIBS=1 LIBDIR = -LDFLAGS = -mno-crt0 -nostartfiles +LDFLAGS = -nostartfiles LIBS = -lpspdebug -lpspge -lpspsdk -lc -lpspuser PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak diff --git a/bootstrap/psp1/kernel_functions_prx/main.c b/bootstrap/psp1/kernel_functions_prx/main.c index 335b156097..08ae0bf0ba 100644 --- a/bootstrap/psp1/kernel_functions_prx/main.c +++ b/bootstrap/psp1/kernel_functions_prx/main.c @@ -66,7 +66,7 @@ int module_start(SceSize args, void *argp) (void)argp; buttons = 0; - thread_active = 0; + thread_active = 0; main_thread_id = sceKernelCreateThread("main Thread", main_thread, 0x11, 0x200, 0, NULL); if (main_thread >= 0) diff --git a/bootstrap/vita/threading.c b/bootstrap/vita/threading.c index cceca6b30a..8b0d10aa2a 100644 --- a/bootstrap/vita/threading.c +++ b/bootstrap/vita/threading.c @@ -34,7 +34,7 @@ int __vita_delete_thread_reent(int thid) // We only need to cleanup if reent is allocated, i.e. if it's on our TLS // We also don't need to clean up the global reent struct _reent **on_tls = NULL; - + if (thid == 0) on_tls = TLS_REENT_PTR; else @@ -141,16 +141,16 @@ struct _reent *__getreent_for_thread(int thid) { // A pointer to our reent should be on the TLS struct _reent **on_tls = NULL; - + if (thid == 0) on_tls = TLS_REENT_PTR; else - on_tls = TLS_REENT_THID_PTR(thid); - + on_tls = TLS_REENT_THID_PTR(thid); + if (*on_tls) { return *on_tls; } - + sceKernelLockMutex(_newlib_reent_mutex, 1, 0); // If it's not on the TLS this means the thread doesn't have a reent allocated yet diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 34a5a31d88..0ee9a7f878 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -139,7 +139,7 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) case RARCH_CAMERA_CTL_OWNS_DRIVER: return camera_driver_data_own; case RARCH_CAMERA_CTL_SET_ACTIVE: - camera_driver_active = true; + camera_driver_active = true; break; case RARCH_CAMERA_CTL_FIND_DRIVER: { @@ -174,10 +174,10 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) } break; case RARCH_CAMERA_CTL_UNSET_ACTIVE: - camera_driver_active = false; + camera_driver_active = false; break; case RARCH_CAMERA_CTL_IS_ACTIVE: - return camera_driver_active; + return camera_driver_active; case RARCH_CAMERA_CTL_DEINIT: if (camera_data && camera_driver) { @@ -191,8 +191,8 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) camera_data = NULL; break; case RARCH_CAMERA_CTL_STOP: - if ( camera_driver - && camera_driver->stop + if ( camera_driver + && camera_driver->stop && camera_data) camera_driver->stop(camera_data); break; @@ -243,6 +243,6 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) default: break; } - + return true; } diff --git a/camera/camera_driver.h b/camera/camera_driver.h index a916165689..25bbc71d38 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/android.c b/camera/drivers/android.c index 2ee7541e33..ab17640155 100644 --- a/camera/drivers/android.c +++ b/camera/drivers/android.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -152,7 +152,7 @@ static void android_camera_stop(void *data) CALL_VOID_METHOD(env, android_app->activity->clazz, androidcamera->onCameraStop); - + if (androidcamera->tex) video_driver_texture_unload((uintptr_t*)&androidcamera->tex); } @@ -171,12 +171,12 @@ static bool android_camera_poll(void *data, (void)frame_raw_cb; - CALL_BOOLEAN_METHOD(env, newFrame, android_app->activity->clazz, + CALL_BOOLEAN_METHOD(env, newFrame, android_app->activity->clazz, androidcamera->onCameraPoll); if (newFrame) { - /* FIXME: Identity for now. Use proper texture matrix as + /* FIXME: Identity for now. Use proper texture matrix as * returned by Android Camera. */ static const float affine[] = { 1.0f, 0.0f, 0.0f, diff --git a/camera/drivers/nullcamera.c b/camera/drivers/nullcamera.c index bb0cc82c5c..332a671e34 100644 --- a/camera/drivers/nullcamera.c +++ b/camera/drivers/nullcamera.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2012-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/rwebcam.c b/camera/drivers/rwebcam.c index c630f0f4c1..a7a39cab36 100644 --- a/camera/drivers/rwebcam.c +++ b/camera/drivers/rwebcam.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2012-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 2be990821e..1fa94fcfa6 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cheevos/badges.c b/cheevos/badges.c index 961fbc600e..8b41bfd230 100644 --- a/cheevos/badges.c +++ b/cheevos/badges.c @@ -1,54 +1,58 @@ -#include -#include -#include - -#include "../file_path_special.h" -#include "../configuration.h" -#include "../verbosity.h" -#include "../network/net_http_special.h" - -#include "badges.h" - -badges_ctx_t badges_ctx; - -bool badge_exists(const char* filepath) -{ - if(path_file_exists(filepath)) - return true; - else - return false; -} - -void set_badge_menu_texture(badges_ctx_t * badges, int i) -{ - const char * locked_suffix = (badges->badge_locked[i] == true) ? "_lock.png" : ".png"; - - unsigned int bufferSize = 16; - char badge_file[bufferSize]; - - snprintf(badge_file, bufferSize, "%s", badges->badge_id_list[i]); - strcat(badge_file, locked_suffix); - - char fullpath[PATH_MAX_LENGTH]; - fill_pathname_application_special(fullpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); - - menu_display_reset_textures_list(badge_file, fullpath, &badges->menu_texture_list[i],TEXTURE_FILTER_MIPMAP_LINEAR); -} - -void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active) -{ - badge_struct->badge_id_list[id] = badge_id; - badge_struct->badge_locked[id] = active; - set_badge_menu_texture(badge_struct, id); -} - -menu_texture_item get_badge_texture (int id) -{ - settings_t *settings = config_get_ptr(); - if (!settings->bools.cheevos_badges_enable) - return (menu_texture_item)NULL; - - return badges_ctx.menu_texture_list[id]; -} +#include +#include +#include + +#include "../file_path_special.h" +#include "../configuration.h" +#include "../verbosity.h" +#include "../network/net_http_special.h" + +#include "badges.h" + +badges_ctx_t badges_ctx; + +bool badge_exists(const char* filepath) +{ + return filestream_exists(filepath); +} + +void set_badge_menu_texture(badges_ctx_t * badges, int i) +{ + char fullpath[PATH_MAX_LENGTH]; + const char * locked_suffix = (badges->badge_locked[i] == true) + ? "_lock.png" : ".png"; + unsigned int bufferSize = 16; + + /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ + char badge_file[bufferSize]; + + snprintf(badge_file, bufferSize, "%s", badges->badge_id_list[i]); + strcat(badge_file, locked_suffix); + + fill_pathname_application_special(fullpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); + + menu_display_reset_textures_list(badge_file, fullpath, + &badges->menu_texture_list[i],TEXTURE_FILTER_MIPMAP_LINEAR); +} + +void set_badge_info (badges_ctx_t *badge_struct, int id, + const char *badge_id, bool active) +{ + if (!badge_struct) + return; + + badge_struct->badge_id_list[id] = badge_id; + badge_struct->badge_locked[id] = active; + set_badge_menu_texture(badge_struct, id); +} + +menu_texture_item get_badge_texture(int id) +{ + settings_t *settings = config_get_ptr(); + if (!settings->bools.cheevos_badges_enable) + return (menu_texture_item)NULL; + + return badges_ctx.menu_texture_list[id]; +} diff --git a/cheevos/badges.h b/cheevos/badges.h index 57a8de6ed2..05fe875a2a 100644 --- a/cheevos/badges.h +++ b/cheevos/badges.h @@ -1,29 +1,29 @@ -#ifndef __RARCH_BADGE_H -#define __RARCH_BADGE_H - -#include "../menu/menu_driver.h" - -#include - -RETRO_BEGIN_DECLS - -#define CHEEVOS_BADGE_LIMIT 256 - -typedef struct -{ - bool badge_locked[CHEEVOS_BADGE_LIMIT]; - const char * badge_id_list[CHEEVOS_BADGE_LIMIT]; - menu_texture_item menu_texture_list[CHEEVOS_BADGE_LIMIT]; -} badges_ctx_t; - -bool badge_exists(const char* filepath); -void set_badge_menu_texture(badges_ctx_t * badges, int i); -extern void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active); -extern menu_texture_item get_badge_texture(int id); - -extern badges_ctx_t badges_ctx; -static badges_ctx_t new_badges_ctx; - -RETRO_END_DECLS - -#endif +#ifndef __RARCH_BADGE_H +#define __RARCH_BADGE_H + +#include "../menu/menu_driver.h" + +#include + +RETRO_BEGIN_DECLS + +#define CHEEVOS_BADGE_LIMIT 256 + +typedef struct +{ + bool badge_locked[CHEEVOS_BADGE_LIMIT]; + const char * badge_id_list[CHEEVOS_BADGE_LIMIT]; + menu_texture_item menu_texture_list[CHEEVOS_BADGE_LIMIT]; +} badges_ctx_t; + +bool badge_exists(const char* filepath); +void set_badge_menu_texture(badges_ctx_t * badges, int i); +extern void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active); +extern menu_texture_item get_badge_texture(int id); + +extern badges_ctx_t badges_ctx; +static badges_ctx_t new_badges_ctx; + +RETRO_END_DECLS + +#endif diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index b2cf87154b..827cd2290a 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -220,45 +221,9 @@ typedef struct cheevos_expr_t value; } cheevos_leaderboard_t; -/* typedef struct { - bool is_lookup; - char* prestring; - cheevos_expr_t expression; -} cheevos_rps_element_t; - -typedef struct -{ - char* name; - unsigned type; -} cheevos_rps_format_t; - -typedef struct -{ - unsigned compare; - char* result; -} cheevos_rps_lookup_value; - -typedef struct -{ - char* name; - cheevos_rps_lookup_value* values; -} cheevos_rps_lookup_t; - -typedef struct -{ - cheevos_rps_element_t* elements; - cheevos_rps_format_t* formats; - unsigned format_count; - cheevos_rps_lookup_t* lookups; - unsigned lookup_count; -} cheevos_rps_t; -*/ - -typedef struct -{ - int console_id; + cheevos_console_t console_id; bool core_supports; bool addrs_patched; int add_buffer; @@ -276,7 +241,7 @@ typedef struct static cheevos_locals_t cheevos_locals = { - /* console_id */ 0, + /* console_id */ CHEEVOS_CONSOLE_NONE, /* core_supports */ true, /* addrs_patched */ false, /* add_buffer */ 0, @@ -838,6 +803,7 @@ static int cheevos_count_cheevos(const char *json, int res; cheevos_countud_t ud; ud.in_cheevos = 0; + ud.in_lboards = 0; ud.core_count = 0; ud.unofficial_count = 0; ud.lboard_count = 0; @@ -1385,7 +1351,7 @@ static int cheevos_read__json_number(void *userdata, } else if (ud->is_console_id) { - cheevos_locals.console_id = (int)strtol(number, NULL, 10); + cheevos_locals.console_id = (cheevos_console_t)strtol(number, NULL, 10); ud->is_console_id = 0; } @@ -1796,6 +1762,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) } else if (valid) { + char msg[256]; char url[256]; url[0] = '\0'; @@ -1807,7 +1774,6 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) RARCH_LOG("[CHEEVOS]: awarding cheevo %u: %s (%s).\n", cheevo->id, cheevo->title, cheevo->description); - char msg[256]; snprintf(msg, sizeof(msg), "Achievement Unlocked: %s", cheevo->title); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 0, 2 * 60, false); @@ -1856,28 +1822,44 @@ static int cheevos_expr_value(cheevos_expr_t* expr) { cheevos_term_t* term = expr->terms; unsigned i; - /* Separate possible values with '$' operator, submit the largest */ unsigned current_value = 0; - int values[expr->compare_count]; + int values[16]; + + if (expr->compare_count >= sizeof(values) / sizeof(values[0])) + { + RARCH_ERR("[CHEEVOS]: too many values in the leaderboard expression: %u\n", expr->compare_count); + return 0; + } + memset(values, 0, sizeof values); for (i = expr->count; i != 0; i--, term++) { + if (current_value >= sizeof(values) / sizeof(values[0])) + { + RARCH_ERR("[CHEEVOS]: too many values in the leaderboard expression: %u\n", current_value); + return 0; + } + values[current_value] += cheevos_var_get_value(&term->var) * term->multiplier; + if (term->compare_next) current_value++; } if (expr->compare_count > 1) { + unsigned j; int maximum = values[0]; - for (unsigned j = 1; j < expr->compare_count; j++) + + for (j = 1; j < expr->compare_count; j++) maximum = values[j] > maximum ? values[j] : maximum; return maximum; } - else return values[0]; + else + return values[0]; } static void cheevos_make_lboard_url(const cheevos_leaderboard_t *lboard, @@ -1974,12 +1956,13 @@ static void cheevos_test_leaderboards(void) else { char url[256]; + char msg[256]; + char formatted_value[16]; + cheevos_make_lboard_url(lboard, url, sizeof(url)); task_push_http_transfer(url, true, NULL, cheevos_lboard_submit, lboard); RARCH_LOG("[CHEEVOS]: submit lboard %s\n", lboard->title); - char msg[256]; - char formatted_value[16]; cheevos_format_value(value, lboard->format, formatted_value, sizeof(formatted_value)); snprintf(msg, sizeof(msg), "Submitted %s for %s", formatted_value, lboard->title); msg[sizeof(msg) - 1] = 0; @@ -1998,11 +1981,12 @@ static void cheevos_test_leaderboards(void) { if (cheevos_test_lboard_condition(&lboard->start)) { + char msg[256]; + RARCH_LOG("[CHEEVOS]: start lboard %s\n", lboard->title); lboard->active = 1; lboard->last_value = -1; - char msg[256]; snprintf(msg, sizeof(msg), "Leaderboard Active: %s", lboard->title); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 0, 2 * 60, false); @@ -2505,7 +2489,7 @@ typedef struct size_t romsize, bytes; \ int mapper; \ bool round; \ - RFILE* stream; \ + intfstream_t *stream; \ size_t size; \ char url[256]; \ struct http_connection_t *conn; \ @@ -2657,14 +2641,17 @@ static int cheevos_iterate(coro_t* coro) /* Load the content into memory, or copy it over to our own buffer */ if (!CHEEVOS_VAR_DATA) { - CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, RFILE_MODE_READ, -1); + CHEEVOS_VAR_STREAM = intfstream_open_file( + CHEEVOS_VAR_PATH, + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!CHEEVOS_VAR_STREAM) CORO_STOP(); CORO_YIELD(); CHEEVOS_VAR_LEN = 0; - CHEEVOS_VAR_COUNT = filestream_get_size(CHEEVOS_VAR_STREAM); + CHEEVOS_VAR_COUNT = intfstream_get_size(CHEEVOS_VAR_STREAM); if (CHEEVOS_VAR_COUNT > CHEEVOS_SIZE_LIMIT) CHEEVOS_VAR_COUNT = CHEEVOS_SIZE_LIMIT; @@ -2673,7 +2660,8 @@ static int cheevos_iterate(coro_t* coro) if (!CHEEVOS_VAR_DATA) { - filestream_close(CHEEVOS_VAR_STREAM); + intfstream_close(CHEEVOS_VAR_STREAM); + free(CHEEVOS_VAR_STREAM); CORO_STOP(); } @@ -2685,7 +2673,7 @@ static int cheevos_iterate(coro_t* coro) if (to_read > CHEEVOS_VAR_COUNT) to_read = CHEEVOS_VAR_COUNT; - num_read = filestream_read(CHEEVOS_VAR_STREAM, (void*)buffer, to_read); + num_read = intfstream_read(CHEEVOS_VAR_STREAM, (void*)buffer, to_read); if (num_read <= 0) break; @@ -2699,7 +2687,8 @@ static int cheevos_iterate(coro_t* coro) CORO_YIELD(); } - filestream_close(CHEEVOS_VAR_STREAM); + intfstream_close(CHEEVOS_VAR_STREAM); + free(CHEEVOS_VAR_STREAM); } /* Use the supported extensions as a hint @@ -2835,10 +2824,10 @@ static int cheevos_iterate(coro_t* coro) { if(cheevos_locals.core.count > 0) { + int mode; const cheevo_t* cheevo = cheevos_locals.core.cheevos; const cheevo_t* end = cheevo + cheevos_locals.core.count; int number_of_unlocked = cheevos_locals.core.count; - int mode; char msg[256]; if(CHEEVOS_VAR_SETTINGS->bools.cheevos_hardcore_mode_enable) @@ -2860,8 +2849,12 @@ static int cheevos_iterate(coro_t* coro) } - CORO_GOSUB(GET_BADGES); + if ( cheevos_locals.core.count == 0 + && cheevos_locals.unofficial.count == 0 + && cheevos_locals.lboard_count == 0) + cheevos_unload(); + CORO_GOSUB(GET_BADGES); CORO_STOP(); /************************************************************************** @@ -3168,10 +3161,12 @@ static int cheevos_iterate(coro_t* coro) badges_ctx = new_badges_ctx; - settings_t *settings = config_get_ptr(); - if (!string_is_equal(settings->arrays.menu_driver, "xmb") || - !settings->bools.cheevos_badges_enable) - CORO_RET(); + { + settings_t *settings = config_get_ptr(); + if (!string_is_equal(settings->arrays.menu_driver, "xmb") || + !settings->bools.cheevos_badges_enable) + CORO_RET(); + } CHEEVOS_VAR_CHEEVO_CURR = cheevos_locals.core.cheevos; CHEEVOS_VAR_CHEEVO_END = cheevos_locals.core.cheevos + cheevos_locals.core.count; @@ -3187,7 +3182,7 @@ static int cheevos_iterate(coro_t* coro) if (!path_is_directory(CHEEVOS_VAR_BADGE_BASE_PATH)) path_mkdir(CHEEVOS_VAR_BADGE_BASE_PATH); CORO_YIELD(); - if (CHEEVOS_VAR_J == 0) + if (CHEEVOS_VAR_J == 0) snprintf(CHEEVOS_VAR_BADGE_NAME, sizeof(CHEEVOS_VAR_BADGE_NAME), "%s.png", CHEEVOS_VAR_CHEEVO_CURR->badge); else snprintf(CHEEVOS_VAR_BADGE_NAME, sizeof(CHEEVOS_VAR_BADGE_NAME), "%s_lock.png", CHEEVOS_VAR_CHEEVO_CURR->badge); diff --git a/cheevos/cheevos.h b/cheevos/cheevos.h index cf2526e504..ed1baae311 100644 --- a/cheevos/cheevos.h +++ b/cheevos/cheevos.h @@ -47,6 +47,7 @@ typedef struct cheevos_ctx_desc typedef enum { + CHEEVOS_CONSOLE_NONE = 0, /* Don't change those, the values match the console IDs * at retroachievements.org. */ CHEEVOS_CONSOLE_MEGA_DRIVE = 1, diff --git a/cheevos/var.c b/cheevos/var.c index 36828b46b3..e0e6d5c6d8 100644 --- a/cheevos/var.c +++ b/cheevos/var.c @@ -24,10 +24,15 @@ #include "../core.h" #include "../verbosity.h" +static void STUB_LOG(const char *fmt, ...) +{ + (void)fmt; +} + #ifdef CHEEVOS_VERBOSE #define CHEEVOS_LOG RARCH_LOG #else -#define CHEEVOS_LOG(...) +#define CHEEVOS_LOG STUB_LOG #endif /***************************************************************************** @@ -251,7 +256,7 @@ void cheevos_var_patch_addr(cheevos_var_t* var, cheevos_console_t console) else { unsigned i; - + for (i = 0; i < 4; i++) { retro_ctx_memory_info_t meminfo; @@ -347,7 +352,7 @@ unsigned cheevos_var_get_value(cheevos_var_t* var) case CHEEVOS_VAR_TYPE_VALUE_COMP: value = var->value; break; - + case CHEEVOS_VAR_TYPE_ADDRESS: case CHEEVOS_VAR_TYPE_DELTA_MEM: memory = cheevos_var_get_memory(var); diff --git a/command.c b/command.c index ac088b7fdb..0745ec1d22 100644 --- a/command.c +++ b/command.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifdef HAVE_CONFIG_H @@ -610,7 +611,7 @@ static void command_stdin_poll(command_t *handle) handle->stdin_buf_ptr += ret; handle->stdin_buf[handle->stdin_buf_ptr] = '\0'; - last_newline = + last_newline = strrchr(handle->stdin_buf, '\n'); if (!last_newline) @@ -1028,7 +1029,7 @@ static void command_event_init_controllers(void) break; case RETRO_DEVICE_JOYPAD: /* Ideally these checks shouldn't be required but if we always - * call core_set_controller_port_device input won't work on + * call core_set_controller_port_device input won't work on * cores that don't set port information properly */ if (info && info->ports.size != 0 && i < info->ports.size) set_controller = true; @@ -1102,7 +1103,7 @@ static void command_event_load_auto_state(void) #endif #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) goto error; #endif @@ -1114,7 +1115,7 @@ static void command_event_load_auto_state(void) file_path_str(FILE_PATH_AUTO_EXTENSION), savestate_name_auto_size); - if (!path_file_exists(savestate_name_auto)) + if (!filestream_exists(savestate_name_auto)) goto error; ret = content_load_state(savestate_name_auto, false, true); @@ -1126,7 +1127,7 @@ static void command_event_load_auto_state(void) msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM), savestate_name_auto, ret ? "succeeded" : "failed"); RARCH_LOG("%s\n", msg); - + free(savestate_name_auto); return; @@ -1338,7 +1339,7 @@ static bool command_event_save_auto_state(void) bool is_inited = false; char *savestate_name_auto = (char*) calloc(PATH_MAX_LENGTH, sizeof(*savestate_name_auto)); - size_t + size_t savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); @@ -1356,7 +1357,7 @@ static bool command_event_save_auto_state(void) goto error; #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) goto error; #endif @@ -1383,7 +1384,7 @@ static bool command_event_save_config( char *s, size_t len) { bool path_exists = !string_is_empty(config_path); - const char *str = path_exists ? config_path : + const char *str = path_exists ? config_path : path_get(RARCH_PATH_CONFIG); if (path_exists && config_save_file(config_path)) @@ -1446,7 +1447,7 @@ static bool command_event_save_core_config(void) core_path = path_get(RARCH_PATH_CORE); /* Infer file name based on libretro core. */ - if (!string_is_empty(core_path) && path_file_exists(core_path)) + if (!string_is_empty(core_path) && filestream_exists(core_path)) { unsigned i; RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG)); @@ -1474,7 +1475,7 @@ static bool command_event_save_core_config(void) sizeof(tmp)); strlcat(config_path, tmp, config_size); - if (!path_file_exists(config_path)) + if (!filestream_exists(config_path)) { found_path = true; break; @@ -1713,7 +1714,7 @@ void command_playlist_push_write( if (!playlist) return; - + if (playlist_push( playlist, path, @@ -1806,9 +1807,12 @@ bool command_event(enum event_command cmd, void *data) { #ifdef HAVE_MENU core_info_ctx_find_t info_find; - rarch_system_info_t *system_info = runloop_get_system_info(); - struct retro_system_info *system = &system_info->info; - const char *core_path = path_get(RARCH_PATH_CORE); + rarch_system_info_t *system_info = NULL; + struct retro_system_info *system = NULL; + const char *core_path = NULL; + system_info = runloop_get_system_info(); + system = &system_info->info; + core_path = path_get(RARCH_PATH_CORE); #if defined(HAVE_DYNAMIC) if (string_is_empty(core_path)) @@ -1845,7 +1849,7 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_CHEEVOS { settings_t *settings = config_get_ptr(); - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; } #endif @@ -1887,7 +1891,7 @@ bool command_event(enum event_command cmd, void *data) { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif @@ -1978,7 +1982,7 @@ bool command_event(enum event_command cmd, void *data) { #ifdef HAVE_CHEEVOS settings_t *settings = config_get_ptr(); - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif @@ -1989,7 +1993,7 @@ bool command_event(enum event_command cmd, void *data) { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif if (settings->bools.rewind_enable) diff --git a/command.h b/command.h index 286383fc83..858fcd820f 100644 --- a/command.h +++ b/command.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2016 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/config.def.h b/config.def.h index cbbffb0ffb..50036db322 100644 --- a/config.def.h +++ b/config.def.h @@ -115,6 +115,11 @@ static const unsigned window_y = 0; static const unsigned fullscreen_x = 0; static const unsigned fullscreen_y = 0; +/* Amount of transparency to use for the main window. + * 1 is the most transparent while 100 is opaque. + */ +static const unsigned window_opacity = 100; + #if defined(RARCH_CONSOLE) || defined(__APPLE__) static const bool load_dummy_on_core_shutdown = false; #else @@ -293,6 +298,12 @@ static bool xmb_show_add = true; #endif #endif +#if defined(HAVE_LIBRETRODB) && !defined(RARCH_CONSOLE) && !defined(EMSCRIPTEN) +static bool automatically_add_content_to_playlist = true; +#else +static bool automatically_add_content_to_playlist = false; +#endif + static float menu_framebuffer_opacity = 0.900; static float menu_wallpaper_opacity = 0.300; @@ -656,11 +667,9 @@ static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/window static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2010/x86/latest/"; #endif #elif _MSC_VER == 1400 -#if defined(__x86_64__) -static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86_64/latest/"; -#elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86/latest/"; -#endif +#elif _MSC_VER == 1310 +static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2003/x86/latest/"; #else #if defined(__x86_64__) static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows/x86_64/latest/"; diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 5ed2203f51..b7f0a32e86 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -22,163 +22,202 @@ /* User 1 */ static const struct retro_keybind retro_keybinds_1[] = { - /* | RetroPad button | enum | keyboard key | js btn | js axis | */ + /* | RetroPad button | enum | keyboard key | m-btn | js btn | js axis | */ #ifdef __QNX__ - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_k, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_i, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_v, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_b, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_e, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_s, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_w, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_d, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_l, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_o, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_f, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_j, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_r, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_u, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_g, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_h, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_k, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_v, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_b, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_e, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_s, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_w, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_d, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_l, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_o, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_f, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_j, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_r, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_u, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_g, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_h, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, #else - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_RSHIFT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_x, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_s, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_q, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_w, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_RSHIFT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_x, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_s, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_q, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_w, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_l, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_F4, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_F2, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_f, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_ESCAPE, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_r, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_p, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_k, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_h, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_m, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_n, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_y, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_t, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_u, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_e, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_KP_MINUS,NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_SCROLLOCK, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_l, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_F4, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_F2, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_f, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_ESCAPE, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_r, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_p, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_k, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_h, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_m, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_n, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_y, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_t, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_u, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_e, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_KP_MINUS,NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_SCROLLOCK, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, NO_BTN, NO_BTN, 0, AXIS_NONE }, #endif }; /* Users 2 to MAX_USERS */ static const struct retro_keybind retro_keybinds_rest[] = { - /* | RetroPad button | desc | keyboard key | js btn | js axis | */ - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + /* | RetroPad button | desc | keyboard key | js btn | js axis | */ + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, }; #endif diff --git a/configuration.c b/configuration.c index 9d95452cdb..db278743c7 100644 --- a/configuration.c +++ b/configuration.c @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -1114,6 +1115,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, unsigned count = 0; global_t *global = global_get_ptr(); + SETTING_BOOL("automatically_add_content_to_playlist", &settings->bools.automatically_add_content_to_playlist, true, automatically_add_content_to_playlist, false); SETTING_BOOL("ui_companion_start_on_boot", &settings->bools.ui_companion_start_on_boot, true, ui_companion_start_on_boot, false); SETTING_BOOL("ui_companion_enable", &settings->bools.ui_companion_enable, true, ui_companion_enable, false); SETTING_BOOL("video_gpu_record", &settings->bools.video_gpu_record, true, gpu_record, false); @@ -1376,6 +1378,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, fullscreen_y, false); SETTING_UINT("video_window_x", &settings->uints.video_window_x, true, fullscreen_x, false); SETTING_UINT("video_window_y", &settings->uints.video_window_y, true, fullscreen_y, false); + SETTING_UINT("video_window_opacity", &settings->uints.video_window_opacity, true, window_opacity, false); #ifdef HAVE_COMMAND SETTING_UINT("network_cmd_port", &settings->uints.network_cmd_port, true, network_cmd_port, false); #endif @@ -1606,9 +1609,9 @@ static void config_set_defaults(void) settings->rewind_buffer_size = rewind_buffer_size; #ifdef HAVE_LAKKA - settings->bools.ssh_enable = path_file_exists(LAKKA_SSH_PATH); - settings->bools.samba_enable = path_file_exists(LAKKA_SAMBA_PATH); - settings->bools.bluetooth_enable = path_file_exists(LAKKA_BLUETOOTH_PATH); + settings->bools.ssh_enable = filestream_exists(LAKKA_SSH_PATH); + settings->bools.samba_enable = filestream_exists(LAKKA_SAMBA_PATH); + settings->bools.bluetooth_enable = filestream_exists(LAKKA_BLUETOOTH_PATH); #endif #ifdef HAVE_MENU @@ -2143,6 +2146,24 @@ static void read_keybinds_axis(config_file_t *conf, unsigned user, input_config_bind_map_get_base(idx), bind); } +static void read_keybinds_mbutton(config_file_t *conf, unsigned user, + unsigned idx, struct retro_keybind *bind) +{ + const char *prefix = NULL; + + if (!input_config_bind_map_get_valid(idx)) + return; + if (!input_config_bind_map_get_base(idx)) + return; + + prefix = input_config_get_prefix(user, + input_config_bind_map_get_meta(idx)); + + if (prefix) + input_config_parse_mouse_button(conf, prefix, + input_config_bind_map_get_base(idx), bind); +} + static void read_keybinds_user(config_file_t *conf, unsigned user) { unsigned i; @@ -2157,6 +2178,7 @@ static void read_keybinds_user(config_file_t *conf, unsigned user) read_keybinds_keyboard(conf, user, i, bind); read_keybinds_button(conf, user, i, bind); read_keybinds_axis(conf, user, i, bind); + read_keybinds_mbutton(conf, user, i, bind); } } @@ -2703,14 +2725,13 @@ static bool config_load_file(const char *path, bool set_defaults, /* Sanitize fastforward_ratio value - previously range was -1 * and up (with 0 being skipped) */ if (settings->floats.fastforward_ratio < 0.0f) - { configuration_set_float(settings, settings->floats.fastforward_ratio, 0.0f); - } + #ifdef HAVE_LAKKA - settings->bools.ssh_enable = path_file_exists(LAKKA_SSH_PATH); - settings->bools.samba_enable = path_file_exists(LAKKA_SAMBA_PATH); - settings->bools.bluetooth_enable = path_file_exists(LAKKA_BLUETOOTH_PATH); + settings->bools.ssh_enable = filestream_exists(LAKKA_SSH_PATH); + settings->bools.samba_enable = filestream_exists(LAKKA_SAMBA_PATH); + settings->bools.bluetooth_enable = filestream_exists(LAKKA_BLUETOOTH_PATH); #endif if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL) && @@ -3349,6 +3370,38 @@ static void save_keybind_axis(config_file_t *conf, const char *prefix, } } +static void save_keybind_mbutton(config_file_t *conf, const char *prefix, + const char *base, const struct retro_keybind *bind, bool save_empty) +{ + char key[64]; + + key[0] = '\0'; + + fill_pathname_join_delim_concat(key, prefix, + base, '_', "_mbtn", sizeof(key)); + + switch ( bind->mbutton ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: config_set_uint64(conf, key, 1); break; + case RETRO_DEVICE_ID_MOUSE_RIGHT: config_set_uint64(conf, key, 2); break; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: config_set_uint64(conf, key, 3); break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: config_set_uint64(conf, key, 4); break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: config_set_uint64(conf, key, 5); break; + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: config_set_string(conf, key, "wu"); break; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: config_set_string(conf, key, "wd"); break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: config_set_string(conf, key, "whu"); break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: config_set_string(conf, key, "whd"); break; + + default: + if ( save_empty ) { + config_set_string(conf, key, file_path_str(FILE_PATH_NUL)); + } + break; + } +} + /** * save_keybind: * @conf : pointer to config file object @@ -3369,6 +3422,7 @@ static void save_keybind(config_file_t *conf, const char *prefix, save_keybind_key(conf, prefix, base, bind); save_keybind_joykey(conf, prefix, base, bind, save_empty); save_keybind_axis(conf, prefix, base, bind, save_empty); + save_keybind_mbutton(conf, prefix, base, bind, save_empty); } /** @@ -3739,17 +3793,23 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->bools.ssh_enable) - filestream_close(filestream_open(LAKKA_SSH_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_SSH_PATH, + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else - path_file_remove(LAKKA_SSH_PATH); + filestream_delete(LAKKA_SSH_PATH); if (settings->bools.samba_enable) - filestream_close(filestream_open(LAKKA_SAMBA_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_SAMBA_PATH, + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else - path_file_remove(LAKKA_SAMBA_PATH); + filestream_delete(LAKKA_SAMBA_PATH); if (settings->bools.bluetooth_enable) - filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else - path_file_remove(LAKKA_BLUETOOTH_PATH); + filestream_delete(LAKKA_BLUETOOTH_PATH); #endif for (i = 0; i < MAX_USERS; i++) @@ -3822,7 +3882,7 @@ bool config_save_overrides(int override_type) fill_pathname_join(override_directory, config_directory, core_name, path_size); - if(!path_file_exists(override_directory)) + if (!filestream_exists(override_directory)) path_mkdir(override_directory); /* Concatenate strings into full paths for core_path, game_path */ diff --git a/configuration.h b/configuration.h index 7dd74b9282..881e94afee 100644 --- a/configuration.h +++ b/configuration.h @@ -29,21 +29,28 @@ #include "input/input_defines.h" #define configuration_set_float(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_bool(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_uint(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_int(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar - + var = newvar; \ +} enum override_type { @@ -243,6 +250,8 @@ typedef struct settings bool ssh_enable; bool samba_enable; bool bluetooth_enable; + + bool automatically_add_content_to_playlist; } bools; struct @@ -316,6 +325,7 @@ typedef struct settings unsigned keymapper_port; unsigned video_window_x; unsigned video_window_y; + unsigned video_window_opacity; unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; diff --git a/core.h b/core.h index 08ec2e1f08..35878206b4 100644 --- a/core.h +++ b/core.h @@ -30,14 +30,14 @@ RETRO_BEGIN_DECLS enum { - /* Polling is performed before + /* Polling is performed before * call to retro_run. */ POLL_TYPE_EARLY = 0, /* Polling is performed when requested. */ POLL_TYPE_NORMAL, - /* Polling is performed on first call to + /* Polling is performed on first call to * retro_input_state per frame. */ POLL_TYPE_LATE }; @@ -65,7 +65,7 @@ typedef struct rarch_system_info const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; char valid_extensions[255]; - struct retro_disk_control_callback disk_control_cb; + struct retro_disk_control_callback disk_control_cb; struct retro_location_callback location_cb; struct @@ -79,7 +79,7 @@ typedef struct rarch_system_info struct retro_controller_info *data; unsigned size; } ports; - + rarch_memory_map_t mmaps; } rarch_system_info_t; diff --git a/core_info.c b/core_info.c index c2989d883b..35f107c715 100644 --- a/core_info.c +++ b/core_info.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -214,7 +215,7 @@ static bool core_info_list_iterate( fill_pathname_join(s, (!string_is_empty(settings->paths.path_libretro_info)) ? - settings->paths.path_libretro_info : + settings->paths.path_libretro_info : settings->paths.directory_libretro, info_path_base, len); @@ -255,9 +256,9 @@ static core_info_list_t *core_info_list_new(const char *path) info_path[0] = '\0'; - if ( + if ( core_info_list_iterate(info_path, info_path_size, - contents, i) + contents, i) && path_is_valid(info_path)) { char *tmp = NULL; @@ -270,14 +271,14 @@ static core_info_list_t *core_info_list_new(const char *path) if (!conf) continue; - if (config_get_string(conf, "display_name", &tmp) + if (config_get_string(conf, "display_name", &tmp) && !string_is_empty(tmp)) { core_info[i].display_name = strdup(tmp); free(tmp); tmp = NULL; } - if (config_get_string(conf, "corename", &tmp) + if (config_get_string(conf, "corename", &tmp) && !string_is_empty(tmp)) { core_info[i].core_name = strdup(tmp); @@ -285,7 +286,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "systemname", &tmp) + if (config_get_string(conf, "systemname", &tmp) && !string_is_empty(tmp)) { core_info[i].systemname = strdup(tmp); @@ -293,7 +294,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "manufacturer", &tmp) + if (config_get_string(conf, "manufacturer", &tmp) && !string_is_empty(tmp)) { core_info[i].system_manufacturer = strdup(tmp); @@ -305,7 +306,7 @@ static core_info_list_t *core_info_list_new(const char *path) core_info[i].firmware_count = count; - if (config_get_string(conf, "supported_extensions", &tmp) + if (config_get_string(conf, "supported_extensions", &tmp) && !string_is_empty(tmp)) { core_info[i].supported_extensions = strdup(tmp); @@ -316,7 +317,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "authors", &tmp) + if (config_get_string(conf, "authors", &tmp) && !string_is_empty(tmp)) { core_info[i].authors = strdup(tmp); @@ -327,7 +328,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "permissions", &tmp) + if (config_get_string(conf, "permissions", &tmp) && !string_is_empty(tmp)) { core_info[i].permissions = strdup(tmp); @@ -338,7 +339,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "license", &tmp) + if (config_get_string(conf, "license", &tmp) && !string_is_empty(tmp)) { core_info[i].licenses = strdup(tmp); @@ -349,7 +350,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "categories", &tmp) + if (config_get_string(conf, "categories", &tmp) && !string_is_empty(tmp)) { core_info[i].categories = strdup(tmp); @@ -360,7 +361,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "database", &tmp) + if (config_get_string(conf, "database", &tmp) && !string_is_empty(tmp)) { core_info[i].databases = strdup(tmp); @@ -371,7 +372,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "notes", &tmp) + if (config_get_string(conf, "notes", &tmp) && !string_is_empty(tmp)) { core_info[i].notes = strdup(tmp); @@ -540,7 +541,7 @@ static bool core_info_list_update_missing_firmware_internal( fill_pathname_join(path, systemdir, info->firmware[i].path, path_size); - info->firmware[i].missing = !path_file_exists(path); + info->firmware[i].missing = !filestream_exists(path); if (info->firmware[i].missing && !info->firmware[i].optional) { rarch_ctl(RARCH_CTL_SET_MISSING_BIOS, NULL); @@ -596,7 +597,7 @@ static void core_info_list_get_missing_firmware( { fill_pathname_join(path, systemdir, info->firmware[i].path, sizeof(path)); - info->firmware[i].missing = !path_file_exists(path); + info->firmware[i].missing = !filestream_exists(path); *num_firmware += info->firmware[i].missing; } diff --git a/core_info.h b/core_info.h index a151091673..c058e8d937 100644 --- a/core_info.h +++ b/core_info.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/core_type.h b/core_type.h index 532b4e4fa6..e4a66058e5 100644 --- a/core_type.h +++ b/core_type.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ #ifndef __CORE_TYPE_H #define __CORE_TYPE_H -enum rarch_core_type +enum rarch_core_type { CORE_TYPE_PLAIN = 0, CORE_TYPE_DUMMY, diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index e5b3397f48..ad61faff97 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 69c698d3f2..aa756ed349 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index f6ba5e51dd..1842f59809 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -214,7 +214,7 @@ void CORE_PREFIX(retro_init)(void) av_register_all(); #if 0 - /* FIXME: Occasionally crashes inside libavdevice + /* FIXME: Occasionally crashes inside libavdevice * for some odd reason on reentrancy. Likely a libavdevice bug. */ avdevice_register_all(); #endif @@ -548,7 +548,7 @@ void CORE_PREFIX(retro_run)(void) frame_cnt++; - /* Have to decode audio before video + /* Have to decode audio before video * incase there are PTS fuckups due * to seeking. */ if (audio_streams_num > 0) @@ -679,20 +679,20 @@ void CORE_PREFIX(retro_run)(void) if (!temporal_interpolation) mix_factor = 1.0f; - + glBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer()); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, media.width, media.height); glUseProgram(prog); - + glUniform1f(mix_loc, mix_factor); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, frames[1].tex); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, frames[0].tex); - - + + glBindBuffer(GL_ARRAY_BUFFER, vbo); glVertexAttribPointer(vertex_loc, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const GLvoid*)(0 * sizeof(GLfloat))); @@ -701,17 +701,17 @@ void CORE_PREFIX(retro_run)(void) glEnableVertexAttribArray(vertex_loc); glEnableVertexAttribArray(tex_loc); glBindBuffer(GL_ARRAY_BUFFER, 0); - + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableVertexAttribArray(vertex_loc); glDisableVertexAttribArray(tex_loc); - + glUseProgram(0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); - + CORE_PREFIX(video_cb)(RETRO_HW_FRAME_BUFFER_VALID, media.width, media.height, media.width * sizeof(uint32_t)); } @@ -731,10 +731,10 @@ void CORE_PREFIX(retro_run)(void) while (frames) { unsigned to_read = frames; - + /* FFT size we use (1 << 11). Really shouldn't happen, * unless we use a crazy high sample rate. */ - if (to_read > (1 << 11)) + if (to_read > (1 << 11)) to_read = 1 << 11; fft_step_fft(fft, buffer, to_read); @@ -861,7 +861,7 @@ static bool open_codecs(void) break; case AVMEDIA_TYPE_VIDEO: - if ( !vctx + if ( !vctx && !codec_is_image(fctx->streams[i]->codec->codec_id)) { if (!open_codec(&vctx, i)) @@ -872,7 +872,7 @@ static bool open_codecs(void) case AVMEDIA_TYPE_SUBTITLE: #ifdef HAVE_SSA - if ( subtitle_streams_num < MAX_STREAMS + if ( subtitle_streams_num < MAX_STREAMS && codec_id_is_ass(fctx->streams[i]->codec->codec_id)) { int size; @@ -923,7 +923,7 @@ static bool init_media_info(void) { media.width = vctx->width; media.height = vctx->height; - media.aspect = (float)vctx->width * + media.aspect = (float)vctx->width * av_q2d(vctx->sample_aspect_ratio) / vctx->height; } @@ -1149,7 +1149,7 @@ static void render_ass_img(AVFrame *conv_frame, ASS_Image *img) dst_g = (g * src_alpha + dst_g * dst_alpha) >> 8; dst_b = (b * src_alpha + dst_b * dst_alpha) >> 8; - dst[x] = (0xffu << 24) | (dst_r << 16) | + dst[x] = (0xffu << 24) | (dst_r << 16) | (dst_g << 8) | (dst_b << 0); } } @@ -1171,7 +1171,7 @@ static void decode_thread(void *data) struct SwsContext *sws = NULL; (void)data; - + if (video_stream >= 0) sws = sws_getCachedContext(NULL, media.width, media.height, vctx->pix_fmt, @@ -1295,7 +1295,7 @@ static void decode_thread(void *data) int stride; unsigned y; const uint8_t *src = NULL; - + fifo_write(video_decode_fifo, &pts, sizeof(pts)); src = conv_frame->data[0]; stride = conv_frame->linesize[0]; @@ -1377,8 +1377,8 @@ static void context_destroy(void) #include "gl_shaders/ffmpeg.glsl.vert.h" -/* OpenGL ES note about main() - Get format as GL_RGBA/GL_UNSIGNED_BYTE. - * Assume little endian, so we get ARGB -> BGRA byte order, and +/* OpenGL ES note about main() - Get format as GL_RGBA/GL_UNSIGNED_BYTE. + * Assume little endian, so we get ARGB -> BGRA byte order, and * we have to swizzle to .BGR. */ #ifdef HAVE_OPENGLES #include "gl_shaders/ffmpeg_es.glsl.frag.h" @@ -1445,7 +1445,7 @@ static void context_reset(void) #if !defined(HAVE_OPENGLES) glGenBuffers(1, &frames[i].pbo); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, frames[i].pbo); - glBufferData(GL_PIXEL_UNPACK_BUFFER, media.width + glBufferData(GL_PIXEL_UNPACK_BUFFER, media.width * media.height * sizeof(uint32_t), NULL, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); #endif @@ -1611,7 +1611,7 @@ bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) if (video_stream >= 0 || is_fft) { - video_decode_fifo = fifo_new(media.width + video_decode_fifo = fifo_new(media.width * media.height * sizeof(uint32_t) * 32); #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) diff --git a/cores/libretro-ffmpeg/ffmpeg_fft.c b/cores/libretro-ffmpeg/ffmpeg_fft.c index 32405a0dea..8d8d22ba12 100644 --- a/cores/libretro-ffmpeg/ffmpeg_fft.c +++ b/cores/libretro-ffmpeg/ffmpeg_fft.c @@ -45,7 +45,7 @@ struct Pass GLuint parameter_tex; }; -struct GLFFT +struct GLFFT { GLuint ms_rb_color; GLuint ms_rb_ds; @@ -102,7 +102,7 @@ static GLuint fft_compile_shader(fft_t *fft, GLenum type, const char *source) glShaderSource(shader, 1, (const GLchar**)&source, NULL); glCompileShader(shader); - + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (!status) @@ -153,7 +153,7 @@ typedef float stub_matrix4x4[4][4]; static INLINE unsigned log2i(unsigned x) { unsigned res; - + for (res = 0; x; x >>= 1) res++; return res - 1; @@ -297,7 +297,7 @@ static void fft_init(fft_t *fft) glUniform1i(glGetUniformLocation(fft->prog_complex, "sTexture"), 0); glUniform1i(glGetUniformLocation(fft->prog_complex, "sParameterTexture"), 1); glUniform4fv(glGetUniformLocation(fft->prog_complex, "uOffsetScale"), 1, unity); - + glUseProgram(fft->prog_resolve); glUniform1i(glGetUniformLocation(fft->prog_resolve, "sFFT"), 0); glUniform4fv(glGetUniformLocation(fft->prog_resolve, "uOffsetScale"), 1, unity); @@ -478,7 +478,7 @@ static bool fft_context_reset(fft_t *fft, unsigned fft_steps, return true; } -/* GLFFT requires either GLES3 or +/* GLFFT requires either GLES3 or * desktop GL with ES3_compat (supported by MESA on Linux) extension. */ fft_t *fft_new(unsigned fft_steps, rglgen_proc_address_t proc) { @@ -621,14 +621,14 @@ void fft_step_fft(fft_t *fft, const GLshort *audio_buffer, unsigned frames) if (i == fft->steps - 1) { glBindFramebuffer(GL_FRAMEBUFFER, fft->output.fbo); - glUniform1i(glGetUniformLocation(i == 0 + glUniform1i(glGetUniformLocation(i == 0 ? fft->prog_real : fft->prog_complex, "uViewportOffset"), fft->output_ptr); glViewport(0, fft->output_ptr, fft->size, 1); } else { - glUniform1i(glGetUniformLocation(i == 0 + glUniform1i(glGetUniformLocation(i == 0 ? fft->prog_real : fft->prog_complex, "uViewportOffset"), 0); glBindFramebuffer(GL_FRAMEBUFFER, fft->passes[i].target.fbo); glClear(GL_COLOR_BUFFER_BIT); diff --git a/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h b/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h index 49f4289a00..012a5c7ff0 100644 --- a/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h +++ b/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h @@ -7,7 +7,7 @@ static const char *fragment_source = GLSL( uniform float uMix; void main() { - gl_FragColor = vec4(pow(mix(pow(texture2D(sTex0, vTex).bgr, vec3(2.2)), pow(texture2D(sTex1, vTex).bgr, vec3(2.2)), uMix), vec3(1.0 / 2.2)), 1.0); + gl_FragColor = vec4(pow(mix(pow(texture2D(sTex0, vTex).bgr, vec3(2.2)), pow(texture2D(sTex1, vTex).bgr, vec3(2.2)), uMix), vec3(1.0 / 2.2)), 1.0); } ); diff --git a/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h b/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h index a5ea0adb2e..85fec8f668 100644 --- a/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h +++ b/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h @@ -21,7 +21,7 @@ static const char *fft_vertex_program_heightmap = GLSL_300( float lod = log2(world_pos.z + 1.0) - 6.0; vec4 heights = textureLod(sHeight, tex_coord, lod); - + float cangle = cos(angle); float sangle = sin(angle); diff --git a/cores/libretro-imageviewer/Makefile b/cores/libretro-imageviewer/Makefile new file mode 100644 index 0000000000..2699b3c5a5 --- /dev/null +++ b/cores/libretro-imageviewer/Makefile @@ -0,0 +1,20 @@ +image_core.so: image_core.c + gcc \ + -g \ + image_core.c \ + ../../libretro-common/file/file_path.c \ + ../../libretro-common/lists/dir_list.c \ + ../../libretro-common/compat/compat_strl.c \ + ../../libretro-common/compat/compat_strcasestr.c \ + ../../libretro-common/lists/string_list.c \ + ../../libretro-common/file/retro_dirent.c \ + ../../libretro-common/streams/file_stream.c \ + ../../libretro-common/vfs/vfs_implementation.c \ + -o image_core.so \ + -DHAVE_STB_IMAGE \ + -I ../../libretro-common/include/ \ + -I../../deps/stb \ + -Wl,--no-undefined \ + -shared \ + -fPIC \ + -lm diff --git a/cores/libretro-imageviewer/image_core.c b/cores/libretro-imageviewer/image_core.c index fdc28b9088..761ffe5ecf 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -10,6 +10,8 @@ #include #include +#include + #if defined(HAVE_RPNG) || defined(HAVE_RJPEG) || defined(HAVE_RTGA) || defined(HAVE_RBMP) #define PREFER_NON_STB_IMAGE #endif @@ -157,10 +159,19 @@ void IMAGE_CORE_PREFIX(retro_set_environment)(retro_environment_t cb) static const struct retro_variable vars[] = { { NULL, NULL }, }; +#ifndef RARCH_INTERNAL + struct retro_vfs_interface_info vfs_iface_info = { 1, NULL }; +#endif IMAGE_CORE_PREFIX(environ_cb) = cb; cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); + +#ifndef RARCH_INTERNAL + /* I don't trust filestream_vfs_init to work inside rarch */ + if (environ_cb(RETRO_ENVIRONMENT_GET_VFS_INTERFACE, &vfs_iface_info)) + filestream_vfs_init(&vfs_iface_info); +#endif } void IMAGE_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb) @@ -227,6 +238,9 @@ static bool imageviewer_load(const char *path, int image_index) { #ifdef STB_IMAGE_IMPLEMENTATION int comp; + RFILE* f; + size_t len; + void* buf; #endif #ifdef RARCH_INTERNAL extern bool video_driver_supports_rgba(void); @@ -235,12 +249,17 @@ static bool imageviewer_load(const char *path, int image_index) imageviewer_free_image(); #ifdef STB_IMAGE_IMPLEMENTATION - image_buffer = (uint32_t*)stbi_load( - path, - &image_width, - &image_height, - &comp, - 4); + f = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); + len = filestream_get_size(f); + buf = malloc(len); + filestream_read(f, buf, len); + filestream_close(f); + + image_buffer = (uint32_t*)stbi_load_from_memory( + buf, len, + &image_width, &image_height, + &comp, 4); + free(buf); #else #ifdef RARCH_INTERNAL image_texture.supports_rgba = video_driver_supports_rgba(); @@ -274,7 +293,7 @@ bool IMAGE_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) dir_list_sort(file_list, false); free(dir); - + if (!IMAGE_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (IMAGE_CORE_PREFIX(log_cb)) @@ -437,7 +456,7 @@ void IMAGE_CORE_PREFIX(retro_run)(void) { uint32_t pixel = *buf; uint32_t a = pixel >> 24; - + if (a == 255) *buf = (pixel & 0x0000ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0x000000ff); else @@ -446,11 +465,11 @@ void IMAGE_CORE_PREFIX(retro_run)(void) uint32_t g = (pixel & 0x00ff00) >> 8; uint32_t b = (pixel & 0xff0000) >> 16; uint32_t bg = ((x & 8) ^ (y & 8)) ? 0x66 : 0x99; - + r = a * r / 255 + (255 - a) * bg / 255; g = a * g / 255 + (255 - a) * bg / 255; b = a * b / 255 + (255 - a) * bg / 255; - + *buf = r << 16 | g << 8 | b; } } diff --git a/cores/libretro-video-processor/video_processor_v4l2.c b/cores/libretro-video-processor/video_processor_v4l2.c index d49d0900aa..d5f0813f19 100644 --- a/cores/libretro-video-processor/video_processor_v4l2.c +++ b/cores/libretro-video-processor/video_processor_v4l2.c @@ -219,7 +219,7 @@ enumerate_audio_devices(char *buf, size_t buflen) name = snd_device_name_get_hint(*n, "NAME"); ioid = snd_device_name_get_hint(*n, "IOID"); if ((ioid == NULL || string_is_equal(ioid, "Input")) && - (!strncmp(name, "hw:", strlen("hw:")) || + (!strncmp(name, "hw:", strlen("hw:")) || !strncmp(name, "default:", strlen("default:")))) { if (ndevs > 0) @@ -368,7 +368,7 @@ static bool open_devices(void) } error = snd_pcm_hw_params_set_format(audio_handle, hw_params, SND_PCM_FORMAT_S16_LE); if (error) - { + { printf("Couldn't set hw param format to SND_PCM_FORMAT_S16_LE: %s\n", snd_strerror(error)); return false; } @@ -460,12 +460,12 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst cc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; error = v4l2_ioctl(video_fd, VIDIOC_CROPCAP, &cc); if (error == 0) - info->geometry.aspect_ratio = (double)cc.pixelaspect.denominator + info->geometry.aspect_ratio = (double)cc.pixelaspect.denominator / (double)cc.pixelaspect.numerator; info->geometry.base_width = info->geometry.max_width = video_format.fmt.pix.width; info->geometry.base_height = info->geometry.max_height = video_format.fmt.pix.height; - info->timing.fps = (double)video_standard.frameperiod.denominator / + info->timing.fps = (double)video_standard.frameperiod.denominator / (double)video_standard.frameperiod.numerator; info->timing.sample_rate = AUDIO_SAMPLE_RATE; @@ -655,7 +655,7 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in buf.index = index; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; - + error = v4l2_ioctl(video_fd, VIDIOC_QBUF, &buf); if (error != 0) { @@ -664,8 +664,8 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in } } - conv_data = (uint16_t*)calloc(1, - video_format.fmt.pix.width * video_format.fmt.pix.height * 2); + conv_data = (uint16_t*)calloc(1, + video_format.fmt.pix.width * video_format.fmt.pix.height * 2); if (!conv_data) { printf("Cannot allocate conversion buffer\n"); @@ -707,7 +707,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) for (index = 0; index < video_nbuffers; index++) v4l2_munmap(video_buffer[index].start, video_buffer[index].len); } - + if (conv_data) free(conv_data); conv_data = NULL; diff --git a/ctr/ctr_system.c b/ctr/ctr_system.c index 5f118dfc7e..29594251e7 100644 --- a/ctr/ctr_system.c +++ b/ctr/ctr_system.c @@ -77,7 +77,10 @@ void __system_allocateHeaps(void) void __attribute__((weak)) __libctru_init(void (*retAddr)(void)) { /* Store the return address */ - __system_retAddr = envIsHomebrew() ? retAddr : NULL; + __system_retAddr = NULL; + if (envIsHomebrew()) { + __system_retAddr = retAddr; + } /* Initialize the synchronization subsystem */ __sync_init(); diff --git a/defaults.h b/defaults.h index 66940f307e..2373d0bf00 100644 --- a/defaults.h +++ b/defaults.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -98,7 +98,7 @@ struct defaults float video_refresh_rate; bool video_threaded_enable; char menu[32]; - } settings; + } settings; #ifndef IS_SALAMANDER playlist_t *content_history; diff --git a/defines/d3d_defines.h b/defines/d3d_defines.h index 2e98aabfee..c4dccb2618 100644 --- a/defines/d3d_defines.h +++ b/defines/d3d_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -65,7 +65,7 @@ #define ID3DSURFACE IDirect3DSurface8 #define D3DCREATE_CTX Direct3DCreate8 -#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX) +#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX) #define D3DLOCK_NOSYSLOCK (0) #endif #define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU diff --git a/defines/gx_defines.h b/defines/gx_defines.h index e472b8231b..c9e7c28e7c 100644 --- a/defines/gx_defines.h +++ b/defines/gx_defines.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/defines/ps3_defines.h b/defines/ps3_defines.h index ac8e6f920c..2b4b0b3d75 100644 --- a/defines/ps3_defines.h +++ b/defines/ps3_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/deps/7zip/7z.h b/deps/7zip/7z.h index 4f2ee95d88..84cd56c152 100644 --- a/deps/7zip/7z.h +++ b/deps/7zip/7z.h @@ -1,207 +1,207 @@ -/* 7z.h -- 7z interface -2010-03-11 : Igor Pavlov : Public domain */ - -#ifndef __7Z_H -#define __7Z_H - -#include "7zBuf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define k7zStartHeaderSize 0x20 -#define k7zSignatureSize 6 -extern uint8_t k7zSignature[k7zSignatureSize]; -#define k7zMajorVersion 0 - -enum EIdEnum -{ - k7zIdEnd, - k7zIdHeader, - k7zIdArchiveProperties, - k7zIdAdditionalStreamsInfo, - k7zIdMainStreamsInfo, - k7zIdFilesInfo, - k7zIdPackInfo, - k7zIdUnpackInfo, - k7zIdSubStreamsInfo, - k7zIdSize, - k7zIdCRC, - k7zIdFolder, - k7zIdCodersUnpackSize, - k7zIdNumUnpackStream, - k7zIdEmptyStream, - k7zIdEmptyFile, - k7zIdAnti, - k7zIdName, - k7zIdCTime, - k7zIdATime, - k7zIdMTime, - k7zIdWinAttributes, - k7zIdComment, - k7zIdEncodedHeader, - k7zIdStartPos, - k7zIdDummy -}; - -typedef struct -{ - uint32_t NumInStreams; - uint32_t NumOutStreams; - uint64_t MethodID; - CBuf Props; -} CSzCoderInfo; - -void SzCoderInfo_Init(CSzCoderInfo *p); -void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); - -typedef struct -{ - uint32_t InIndex; - uint32_t OutIndex; -} CSzBindPair; - -typedef struct -{ - CSzCoderInfo *Coders; - CSzBindPair *BindPairs; - uint32_t *PackStreams; - uint64_t *UnpackSizes; - uint32_t NumCoders; - uint32_t NumBindPairs; - uint32_t NumPackStreams; - int UnpackCRCDefined; - uint32_t UnpackCRC; - - uint32_t NumUnpackStreams; -} CSzFolder; - -void SzFolder_Init(CSzFolder *p); -uint64_t SzFolder_GetUnpackSize(CSzFolder *p); -int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex); -uint32_t SzFolder_GetNumOutStreams(CSzFolder *p); -uint64_t SzFolder_GetUnpackSize(CSzFolder *p); - -SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *stream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain); - -typedef struct -{ - uint32_t Low; - uint32_t High; -} CNtfsFileTime; - -typedef struct -{ - CNtfsFileTime MTime; - uint64_t Size; - uint32_t Crc; - uint32_t Attrib; - uint8_t HasStream; - uint8_t IsDir; - uint8_t IsAnti; - uint8_t CrcDefined; - uint8_t MTimeDefined; - uint8_t AttribDefined; -} CSzFileItem; - -void SzFile_Init(CSzFileItem *p); - -typedef struct -{ - uint64_t *PackSizes; - uint8_t *PackCRCsDefined; - uint32_t *PackCRCs; - CSzFolder *Folders; - CSzFileItem *Files; - uint32_t NumPackStreams; - uint32_t NumFolders; - uint32_t NumFiles; -} CSzAr; - -void SzAr_Init(CSzAr *p); -void SzAr_Free(CSzAr *p, ISzAlloc *alloc); - - -/* - SzExtract extracts file from archive - - *outBuffer must be 0 before first call for each new archive. - - Extracting cache: - If you need to decompress more than one file, you can send - these values from previous call: - *blockIndex, - *outBuffer, - *outBufferSize - You can consider "*outBuffer" as cache of solid block. If your archive is solid, - it will increase decompression speed. - - If you use external function, you can declare these 3 cache variables - (blockIndex, outBuffer, outBufferSize) as static in that external function. - - Free *outBuffer and set *outBuffer to 0, if you want to flush cache. -*/ - -typedef struct -{ - CSzAr db; - - uint64_t startPosAfterHeader; - uint64_t dataPos; - - uint32_t *FolderStartPackStreamIndex; - uint64_t *PackStreamStartPositions; - uint32_t *FolderStartFileIndex; - uint32_t *FileIndexToFolderIndexMap; - - size_t *FileNameOffsets; /* in 2-byte steps */ - CBuf FileNames; /* UTF-16-LE */ -} CSzArEx; - -void SzArEx_Init(CSzArEx *p); -void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc); -uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); - -/* -if dest == NULL, the return value specifies the required size of the buffer, - in 16-bit characters, including the null-terminating character. -if dest != NULL, the return value specifies the number of 16-bit characters that - are written to the dest, including the null-terminating character. */ - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest); - -SRes SzArEx_Extract( - const CSzArEx *db, - ILookInStream *inStream, - uint32_t fileIndex, /* index of file */ - uint32_t *blockIndex, /* index of solid block */ - uint8_t **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - - -/* -SzArEx_Open Errors: -SZ_ERROR_NO_ARCHIVE -SZ_ERROR_ARCHIVE -SZ_ERROR_UNSUPPORTED -SZ_ERROR_MEM -SZ_ERROR_CRC -SZ_ERROR_INPUT_EOF -SZ_ERROR_FAIL -*/ - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7z.h -- 7z interface +2010-03-11 : Igor Pavlov : Public domain */ + +#ifndef __7Z_H +#define __7Z_H + +#include "7zBuf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define k7zStartHeaderSize 0x20 +#define k7zSignatureSize 6 +extern uint8_t k7zSignature[k7zSignatureSize]; +#define k7zMajorVersion 0 + +enum EIdEnum +{ + k7zIdEnd, + k7zIdHeader, + k7zIdArchiveProperties, + k7zIdAdditionalStreamsInfo, + k7zIdMainStreamsInfo, + k7zIdFilesInfo, + k7zIdPackInfo, + k7zIdUnpackInfo, + k7zIdSubStreamsInfo, + k7zIdSize, + k7zIdCRC, + k7zIdFolder, + k7zIdCodersUnpackSize, + k7zIdNumUnpackStream, + k7zIdEmptyStream, + k7zIdEmptyFile, + k7zIdAnti, + k7zIdName, + k7zIdCTime, + k7zIdATime, + k7zIdMTime, + k7zIdWinAttributes, + k7zIdComment, + k7zIdEncodedHeader, + k7zIdStartPos, + k7zIdDummy +}; + +typedef struct +{ + uint32_t NumInStreams; + uint32_t NumOutStreams; + uint64_t MethodID; + CBuf Props; +} CSzCoderInfo; + +void SzCoderInfo_Init(CSzCoderInfo *p); +void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); + +typedef struct +{ + uint32_t InIndex; + uint32_t OutIndex; +} CSzBindPair; + +typedef struct +{ + CSzCoderInfo *Coders; + CSzBindPair *BindPairs; + uint32_t *PackStreams; + uint64_t *UnpackSizes; + uint32_t NumCoders; + uint32_t NumBindPairs; + uint32_t NumPackStreams; + int UnpackCRCDefined; + uint32_t UnpackCRC; + + uint32_t NumUnpackStreams; +} CSzFolder; + +void SzFolder_Init(CSzFolder *p); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex); +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); + +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *stream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain); + +typedef struct +{ + uint32_t Low; + uint32_t High; +} CNtfsFileTime; + +typedef struct +{ + CNtfsFileTime MTime; + uint64_t Size; + uint32_t Crc; + uint32_t Attrib; + uint8_t HasStream; + uint8_t IsDir; + uint8_t IsAnti; + uint8_t CrcDefined; + uint8_t MTimeDefined; + uint8_t AttribDefined; +} CSzFileItem; + +void SzFile_Init(CSzFileItem *p); + +typedef struct +{ + uint64_t *PackSizes; + uint8_t *PackCRCsDefined; + uint32_t *PackCRCs; + CSzFolder *Folders; + CSzFileItem *Files; + uint32_t NumPackStreams; + uint32_t NumFolders; + uint32_t NumFiles; +} CSzAr; + +void SzAr_Init(CSzAr *p); +void SzAr_Free(CSzAr *p, ISzAlloc *alloc); + + +/* + SzExtract extracts file from archive + + *outBuffer must be 0 before first call for each new archive. + + Extracting cache: + If you need to decompress more than one file, you can send + these values from previous call: + *blockIndex, + *outBuffer, + *outBufferSize + You can consider "*outBuffer" as cache of solid block. If your archive is solid, + it will increase decompression speed. + + If you use external function, you can declare these 3 cache variables + (blockIndex, outBuffer, outBufferSize) as static in that external function. + + Free *outBuffer and set *outBuffer to 0, if you want to flush cache. +*/ + +typedef struct +{ + CSzAr db; + + uint64_t startPosAfterHeader; + uint64_t dataPos; + + uint32_t *FolderStartPackStreamIndex; + uint64_t *PackStreamStartPositions; + uint32_t *FolderStartFileIndex; + uint32_t *FileIndexToFolderIndexMap; + + size_t *FileNameOffsets; /* in 2-byte steps */ + CBuf FileNames; /* UTF-16-LE */ +} CSzArEx; + +void SzArEx_Init(CSzArEx *p); +void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc); +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); + +/* +if dest == NULL, the return value specifies the required size of the buffer, + in 16-bit characters, including the null-terminating character. +if dest != NULL, the return value specifies the number of 16-bit characters that + are written to the dest, including the null-terminating character. */ + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest); + +SRes SzArEx_Extract( + const CSzArEx *db, + ILookInStream *inStream, + uint32_t fileIndex, /* index of file */ + uint32_t *blockIndex, /* index of solid block */ + uint8_t **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ + size_t *outBufferSize, /* buffer size for output buffer */ + size_t *offset, /* offset of stream for required file in *outBuffer */ + size_t *outSizeProcessed, /* size of file in *outBuffer */ + ISzAlloc *allocMain, + ISzAlloc *allocTemp); + + +/* +SzArEx_Open Errors: +SZ_ERROR_NO_ARCHIVE +SZ_ERROR_ARCHIVE +SZ_ERROR_UNSUPPORTED +SZ_ERROR_MEM +SZ_ERROR_CRC +SZ_ERROR_INPUT_EOF +SZ_ERROR_FAIL +*/ + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zBuf.c b/deps/7zip/7zBuf.c index 3d30bfd270..832a7a9271 100644 --- a/deps/7zip/7zBuf.c +++ b/deps/7zip/7zBuf.c @@ -1,37 +1,37 @@ -/* 7zBuf.c -- Byte Buffer - 2008-03-28 - Igor Pavlov - Public domain */ - -#include -#include "7zBuf.h" - -void Buf_Init(CBuf *p) -{ - p->data = 0; - p->size = 0; -} - -int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) -{ - p->size = 0; - if (size == 0) - { - p->data = 0; - return 1; - } - p->data = (uint8_t *)alloc->Alloc(alloc, size); - if (p->data != 0) - { - p->size = size; - return 1; - } - return 0; -} - -void Buf_Free(CBuf *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->data); - p->data = 0; - p->size = 0; -} +/* 7zBuf.c -- Byte Buffer + 2008-03-28 + Igor Pavlov + Public domain */ + +#include +#include "7zBuf.h" + +void Buf_Init(CBuf *p) +{ + p->data = 0; + p->size = 0; +} + +int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) +{ + p->size = 0; + if (size == 0) + { + p->data = 0; + return 1; + } + p->data = (uint8_t *)alloc->Alloc(alloc, size); + if (p->data != 0) + { + p->size = size; + return 1; + } + return 0; +} + +void Buf_Free(CBuf *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->data); + p->data = 0; + p->size = 0; +} diff --git a/deps/7zip/7zBuf.h b/deps/7zip/7zBuf.h index 485ec12610..4ce09cb767 100644 --- a/deps/7zip/7zBuf.h +++ b/deps/7zip/7zBuf.h @@ -1,27 +1,27 @@ -/* 7zBuf.h -- Byte Buffer -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __7Z_BUF_H -#define __7Z_BUF_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - uint8_t *data; - size_t size; -} CBuf; - -void Buf_Init(CBuf *p); -int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); -void Buf_Free(CBuf *p, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zBuf.h -- Byte Buffer +2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __7Z_BUF_H +#define __7Z_BUF_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + uint8_t *data; + size_t size; +} CBuf; + +void Buf_Init(CBuf *p); +int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); +void Buf_Free(CBuf *p, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zCrc.c b/deps/7zip/7zCrc.c index 0e95f17a34..02728d23d6 100644 --- a/deps/7zip/7zCrc.c +++ b/deps/7zip/7zCrc.c @@ -1,76 +1,76 @@ -/* 7zCrc.c -- CRC32 calculation - 2009-11-23 : Igor Pavlov : Public domain */ - -#include -#include "7zCrc.h" -#include "CpuArch.h" - -#define kCrcPoly 0xEDB88320 - -#ifdef MSB_FIRST -#define CRC_NUM_TABLES 1 -#else -#define CRC_NUM_TABLES 8 -#endif - -typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); - -static CRC_FUNC g_CrcUpdate; -uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; - -#if CRC_NUM_TABLES == 1 - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -static uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - const uint8_t *p = (const uint8_t *)data; - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -#else - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); - -#endif - -uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) -{ - return g_CrcUpdate(v, data, size, g_CrcTable); -} - -uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) -{ - return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; -} - -void MY_FAST_CALL CrcGenerateTable(void) -{ - uint32_t i; - for (i = 0; i < 256; i++) - { - uint32_t r = i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); - g_CrcTable[i] = r; - } -#if CRC_NUM_TABLES == 1 - g_CrcUpdate = CrcUpdateT1; -#else - for (; i < 256 * CRC_NUM_TABLES; i++) - { - uint32_t r = g_CrcTable[i - 256]; - g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); - } - -#ifdef MY_CPU_X86_OR_AMD64 - g_CrcUpdate = CrcUpdateT8; -#else - g_CrcUpdate = CrcUpdateT4; -#endif -#endif -} +/* 7zCrc.c -- CRC32 calculation + 2009-11-23 : Igor Pavlov : Public domain */ + +#include +#include "7zCrc.h" +#include "CpuArch.h" + +#define kCrcPoly 0xEDB88320 + +#ifdef MSB_FIRST +#define CRC_NUM_TABLES 1 +#else +#define CRC_NUM_TABLES 8 +#endif + +typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); + +static CRC_FUNC g_CrcUpdate; +uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; + +#if CRC_NUM_TABLES == 1 + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +static uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + const uint8_t *p = (const uint8_t *)data; + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +#else + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); + +#endif + +uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) +{ + return g_CrcUpdate(v, data, size, g_CrcTable); +} + +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) +{ + return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; +} + +void MY_FAST_CALL CrcGenerateTable(void) +{ + uint32_t i; + for (i = 0; i < 256; i++) + { + uint32_t r = i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); + g_CrcTable[i] = r; + } +#if CRC_NUM_TABLES == 1 + g_CrcUpdate = CrcUpdateT1; +#else + for (; i < 256 * CRC_NUM_TABLES; i++) + { + uint32_t r = g_CrcTable[i - 256]; + g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); + } + +#ifdef MY_CPU_X86_OR_AMD64 + g_CrcUpdate = CrcUpdateT8; +#else + g_CrcUpdate = CrcUpdateT4; +#endif +#endif +} diff --git a/deps/7zip/7zCrc.h b/deps/7zip/7zCrc.h index 4b56a1c506..30890b8035 100644 --- a/deps/7zip/7zCrc.h +++ b/deps/7zip/7zCrc.h @@ -1,29 +1,29 @@ -/* 7zCrc.h -- CRC32 calculation - 2009-11-21 : Igor Pavlov : Public domain */ - -#ifndef __7Z_CRC_H -#define __7Z_CRC_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern uint32_t g_CrcTable[]; - -/* Call CrcGenerateTable one time before other CRC functions */ -void MY_FAST_CALL CrcGenerateTable(void); - -#define CRC_INIT_VAL 0xFFFFFFFF -#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) -#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); -uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zCrc.h -- CRC32 calculation + 2009-11-21 : Igor Pavlov : Public domain */ + +#ifndef __7Z_CRC_H +#define __7Z_CRC_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t g_CrcTable[]; + +/* Call CrcGenerateTable one time before other CRC functions */ +void MY_FAST_CALL CrcGenerateTable(void); + +#define CRC_INIT_VAL 0xFFFFFFFF +#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) +#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zCrcOpt.c b/deps/7zip/7zCrcOpt.c index d2f18b372b..22bd4b1196 100644 --- a/deps/7zip/7zCrcOpt.c +++ b/deps/7zip/7zCrcOpt.c @@ -1,38 +1,38 @@ -/* 7zCrcOpt.c -- CRC32 calculation : optimized version - 2009-11-23 : Igor Pavlov : Public domain */ - -#include -#include "CpuArch.h" - -#ifndef MSB_FIRST - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - const uint8_t *p = (const uint8_t*)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - v ^= *(const uint32_t *)p; - v = - table[0x300 + (v & 0xFF)] ^ - table[0x200 + ((v >> 8) & 0xFF)] ^ - table[0x100 + ((v >> 16) & 0xFF)] ^ - table[0x000 + ((v >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - return CrcUpdateT4(v, data, size, table); -} - -#endif +/* 7zCrcOpt.c -- CRC32 calculation : optimized version + 2009-11-23 : Igor Pavlov : Public domain */ + +#include +#include "CpuArch.h" + +#ifndef MSB_FIRST + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + const uint8_t *p = (const uint8_t*)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + v ^= *(const uint32_t *)p; + v = + table[0x300 + (v & 0xFF)] ^ + table[0x200 + ((v >> 8) & 0xFF)] ^ + table[0x100 + ((v >> 16) & 0xFF)] ^ + table[0x000 + ((v >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + return CrcUpdateT4(v, data, size, table); +} + +#endif diff --git a/deps/7zip/7zDec.c b/deps/7zip/7zDec.c index 34eac2a832..4ed17b2340 100644 --- a/deps/7zip/7zDec.c +++ b/deps/7zip/7zDec.c @@ -1,360 +1,360 @@ -/* 7zDec.c -- Decoding from 7z folder -2010-11-02 : Igor Pavlov : Public domain */ - -#include -#include -#include - -#include "7z.h" - -#include "Bcj2.h" -#include "Bra.h" -#include "CpuArch.h" -#include "LzmaDec.h" -#include "Lzma2Dec.h" - -#define k_Copy 0 -#define k_LZMA2 0x21 -#define k_LZMA 0x30101 -#define k_BCJ 0x03030103 -#define k_PPC 0x03030205 -#define k_ARM 0x03030501 -#define k_ARMT 0x03030701 -#define k_SPARC 0x03030805 -#define k_BCJ2 0x0303011B - -static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - CLzmaDec state; - SRes res = SZ_OK; - - LzmaDec_Construct(&state); - RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain)); - state.dic = outBuffer; - state.dicBufSize = outSize; - LzmaDec_Init(&state); - - for (;;) - { - uint8_t *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - size_t inProcessed = (size_t)lookahead, dicPos = state.dicPos; - ELzmaStatus status; - res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos)) - { - if (state.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK && - status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - LzmaDec_FreeProbs(&state, allocMain); - return res; -} - -static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - CLzma2Dec state; - SRes res = SZ_OK; - - Lzma2Dec_Construct(&state); - if (coder->Props.size != 1) - return SZ_ERROR_DATA; - RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); - state.decoder.dic = outBuffer; - state.decoder.dicBufSize = outSize; - Lzma2Dec_Init(&state); - - for (;;) - { - uint8_t *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - size_t inProcessed = (size_t)lookahead, dicPos = state.decoder.dicPos; - ELzmaStatus status; - res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos)) - { - if (state.decoder.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - Lzma2Dec_FreeProbs(&state, allocMain); - return res; -} - -static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer) -{ - while (inSize > 0) - { - void *inBuf; - size_t curSize = (1 << 18); - if (curSize > inSize) - curSize = (size_t)inSize; - RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); - if (curSize == 0) - return SZ_ERROR_INPUT_EOF; - memcpy(outBuffer, inBuf, curSize); - outBuffer += curSize; - inSize -= curSize; - RINOK(inStream->Skip((void *)inStream, curSize)); - } - return SZ_OK; -} - -static bool IS_MAIN_METHOD(uint32_t m) -{ - switch(m) - { - case k_Copy: - case k_LZMA: - case k_LZMA2: - return true; - } - return false; -} - -static bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) -{ - return - c->NumInStreams == 1 && - c->NumOutStreams == 1 && - c->MethodID <= (uint32_t)0xFFFFFFFF && - IS_MAIN_METHOD((uint32_t)c->MethodID); -} - -#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) - -static SRes CheckSupportedFolder(const CSzFolder *f) -{ - if (f->NumCoders < 1 || f->NumCoders > 4) - return SZ_ERROR_UNSUPPORTED; - if (!IS_SUPPORTED_CODER(&f->Coders[0])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumCoders == 1) - { - if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - if (f->NumCoders == 2) - { - CSzCoderInfo *c = &f->Coders[1]; - if (c->MethodID > (uint32_t)0xFFFFFFFF || - c->NumInStreams != 1 || - c->NumOutStreams != 1 || - f->NumPackStreams != 1 || - f->PackStreams[0] != 0 || - f->NumBindPairs != 1 || - f->BindPairs[0].InIndex != 1 || - f->BindPairs[0].OutIndex != 0) - return SZ_ERROR_UNSUPPORTED; - switch ((uint32_t)c->MethodID) - { - case k_BCJ: - case k_ARM: - break; - default: - return SZ_ERROR_UNSUPPORTED; - } - return SZ_OK; - } - if (f->NumCoders == 4) - { - if (!IS_SUPPORTED_CODER(&f->Coders[1]) || - !IS_SUPPORTED_CODER(&f->Coders[2]) || - !IS_BCJ2(&f->Coders[3])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumPackStreams != 4 || - f->PackStreams[0] != 2 || - f->PackStreams[1] != 6 || - f->PackStreams[2] != 1 || - f->PackStreams[3] != 0 || - f->NumBindPairs != 3 || - f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || - f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || - f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - return SZ_ERROR_UNSUPPORTED; -} - -static uint64_t GetSum(const uint64_t *values, uint32_t idx) -{ - uint64_t sum = 0; - uint32_t i; - for (i = 0; i < idx; i++) - sum += values[i]; - return sum; -} - -#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; - -static SRes SzFolder_Decode2(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *inStream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain, - uint8_t *tempBuf[]) -{ - uint32_t ci; - size_t tempSizes[3] = { 0, 0, 0}; - size_t tempSize3 = 0; - uint8_t *tempBuf3 = 0; - - RINOK(CheckSupportedFolder(folder)); - - for (ci = 0; ci < folder->NumCoders; ci++) - { - CSzCoderInfo *coder = &folder->Coders[ci]; - - if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) - { - uint32_t si = 0; - uint64_t offset; - uint64_t inSize; - uint8_t *outBufCur = outBuffer; - size_t outSizeCur = outSize; - if (folder->NumCoders == 4) - { - uint32_t indices[] = { 3, 2, 0 }; - uint64_t unpackSize = folder->UnpackSizes[ci]; - si = indices[ci]; - if (ci < 2) - { - uint8_t *temp; - outSizeCur = (size_t)unpackSize; - if (outSizeCur != unpackSize) - return SZ_ERROR_MEM; - temp = (uint8_t *)IAlloc_Alloc(allocMain, outSizeCur); - if (temp == 0 && outSizeCur != 0) - return SZ_ERROR_MEM; - outBufCur = tempBuf[1 - ci] = temp; - tempSizes[1 - ci] = outSizeCur; - } - else if (ci == 2) - { - if (unpackSize > outSize) /* check it */ - return SZ_ERROR_PARAM; - tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); - tempSize3 = outSizeCur = (size_t)unpackSize; - } - else - return SZ_ERROR_UNSUPPORTED; - } - offset = GetSum(packSizes, si); - inSize = packSizes[si]; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - - if (coder->MethodID == k_Copy) - { - if (inSize != outSizeCur) /* check it */ - return SZ_ERROR_DATA; - RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); - } - else if (coder->MethodID == k_LZMA) - { - RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else if (coder->MethodID == k_LZMA2) - { - RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else - return SZ_ERROR_UNSUPPORTED; - } - else if (coder->MethodID == k_BCJ2) - { - uint64_t offset = GetSum(packSizes, 1); - uint64_t s3Size = packSizes[1]; - SRes res; - if (ci != 3) - return SZ_ERROR_UNSUPPORTED; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - tempSizes[2] = (size_t)s3Size; - if (tempSizes[2] != s3Size) - return SZ_ERROR_MEM; - tempBuf[2] = (uint8_t *)IAlloc_Alloc(allocMain, tempSizes[2]); - if (tempBuf[2] == 0 && tempSizes[2] != 0) - return SZ_ERROR_MEM; - res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); - RINOK(res) - - res = Bcj2_Decode( - tempBuf3, tempSize3, - tempBuf[0], tempSizes[0], - tempBuf[1], tempSizes[1], - tempBuf[2], tempSizes[2], - outBuffer, outSize); - RINOK(res) - } - else - { - if (ci != 1) - return SZ_ERROR_UNSUPPORTED; - switch(coder->MethodID) - { - case k_BCJ: - { - uint32_t state; - x86_Convert_Init(state); - x86_Convert(outBuffer, outSize, 0, &state, 0); - break; - } - CASE_BRA_CONV(ARM) - default: - return SZ_ERROR_UNSUPPORTED; - } - } - } - return SZ_OK; -} - -SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *inStream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - uint8_t *tempBuf[3] = { 0, 0, 0}; - int i; - SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, - outBuffer, (size_t)outSize, allocMain, tempBuf); - for (i = 0; i < 3; i++) - IAlloc_Free(allocMain, tempBuf[i]); - return res; -} +/* 7zDec.c -- Decoding from 7z folder +2010-11-02 : Igor Pavlov : Public domain */ + +#include +#include +#include + +#include "7z.h" + +#include "Bcj2.h" +#include "Bra.h" +#include "CpuArch.h" +#include "LzmaDec.h" +#include "Lzma2Dec.h" + +#define k_Copy 0 +#define k_LZMA2 0x21 +#define k_LZMA 0x30101 +#define k_BCJ 0x03030103 +#define k_PPC 0x03030205 +#define k_ARM 0x03030501 +#define k_ARMT 0x03030701 +#define k_SPARC 0x03030805 +#define k_BCJ2 0x0303011B + +static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + CLzmaDec state; + SRes res = SZ_OK; + + LzmaDec_Construct(&state); + RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain)); + state.dic = outBuffer; + state.dicBufSize = outSize; + LzmaDec_Init(&state); + + for (;;) + { + uint8_t *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + size_t inProcessed = (size_t)lookahead, dicPos = state.dicPos; + ELzmaStatus status; + res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos)) + { + if (state.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK && + status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + LzmaDec_FreeProbs(&state, allocMain); + return res; +} + +static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + CLzma2Dec state; + SRes res = SZ_OK; + + Lzma2Dec_Construct(&state); + if (coder->Props.size != 1) + return SZ_ERROR_DATA; + RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); + state.decoder.dic = outBuffer; + state.decoder.dicBufSize = outSize; + Lzma2Dec_Init(&state); + + for (;;) + { + uint8_t *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + size_t inProcessed = (size_t)lookahead, dicPos = state.decoder.dicPos; + ELzmaStatus status; + res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos)) + { + if (state.decoder.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + Lzma2Dec_FreeProbs(&state, allocMain); + return res; +} + +static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer) +{ + while (inSize > 0) + { + void *inBuf; + size_t curSize = (1 << 18); + if (curSize > inSize) + curSize = (size_t)inSize; + RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); + if (curSize == 0) + return SZ_ERROR_INPUT_EOF; + memcpy(outBuffer, inBuf, curSize); + outBuffer += curSize; + inSize -= curSize; + RINOK(inStream->Skip((void *)inStream, curSize)); + } + return SZ_OK; +} + +static bool IS_MAIN_METHOD(uint32_t m) +{ + switch(m) + { + case k_Copy: + case k_LZMA: + case k_LZMA2: + return true; + } + return false; +} + +static bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) +{ + return + c->NumInStreams == 1 && + c->NumOutStreams == 1 && + c->MethodID <= (uint32_t)0xFFFFFFFF && + IS_MAIN_METHOD((uint32_t)c->MethodID); +} + +#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) + +static SRes CheckSupportedFolder(const CSzFolder *f) +{ + if (f->NumCoders < 1 || f->NumCoders > 4) + return SZ_ERROR_UNSUPPORTED; + if (!IS_SUPPORTED_CODER(&f->Coders[0])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumCoders == 1) + { + if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + if (f->NumCoders == 2) + { + CSzCoderInfo *c = &f->Coders[1]; + if (c->MethodID > (uint32_t)0xFFFFFFFF || + c->NumInStreams != 1 || + c->NumOutStreams != 1 || + f->NumPackStreams != 1 || + f->PackStreams[0] != 0 || + f->NumBindPairs != 1 || + f->BindPairs[0].InIndex != 1 || + f->BindPairs[0].OutIndex != 0) + return SZ_ERROR_UNSUPPORTED; + switch ((uint32_t)c->MethodID) + { + case k_BCJ: + case k_ARM: + break; + default: + return SZ_ERROR_UNSUPPORTED; + } + return SZ_OK; + } + if (f->NumCoders == 4) + { + if (!IS_SUPPORTED_CODER(&f->Coders[1]) || + !IS_SUPPORTED_CODER(&f->Coders[2]) || + !IS_BCJ2(&f->Coders[3])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumPackStreams != 4 || + f->PackStreams[0] != 2 || + f->PackStreams[1] != 6 || + f->PackStreams[2] != 1 || + f->PackStreams[3] != 0 || + f->NumBindPairs != 3 || + f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || + f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || + f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + return SZ_ERROR_UNSUPPORTED; +} + +static uint64_t GetSum(const uint64_t *values, uint32_t idx) +{ + uint64_t sum = 0; + uint32_t i; + for (i = 0; i < idx; i++) + sum += values[i]; + return sum; +} + +#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; + +static SRes SzFolder_Decode2(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain, + uint8_t *tempBuf[]) +{ + uint32_t ci; + size_t tempSizes[3] = { 0, 0, 0}; + size_t tempSize3 = 0; + uint8_t *tempBuf3 = 0; + + RINOK(CheckSupportedFolder(folder)); + + for (ci = 0; ci < folder->NumCoders; ci++) + { + CSzCoderInfo *coder = &folder->Coders[ci]; + + if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) + { + uint32_t si = 0; + uint64_t offset; + uint64_t inSize; + uint8_t *outBufCur = outBuffer; + size_t outSizeCur = outSize; + if (folder->NumCoders == 4) + { + uint32_t indices[] = { 3, 2, 0 }; + uint64_t unpackSize = folder->UnpackSizes[ci]; + si = indices[ci]; + if (ci < 2) + { + uint8_t *temp; + outSizeCur = (size_t)unpackSize; + if (outSizeCur != unpackSize) + return SZ_ERROR_MEM; + temp = (uint8_t *)IAlloc_Alloc(allocMain, outSizeCur); + if (temp == 0 && outSizeCur != 0) + return SZ_ERROR_MEM; + outBufCur = tempBuf[1 - ci] = temp; + tempSizes[1 - ci] = outSizeCur; + } + else if (ci == 2) + { + if (unpackSize > outSize) /* check it */ + return SZ_ERROR_PARAM; + tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); + tempSize3 = outSizeCur = (size_t)unpackSize; + } + else + return SZ_ERROR_UNSUPPORTED; + } + offset = GetSum(packSizes, si); + inSize = packSizes[si]; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + + if (coder->MethodID == k_Copy) + { + if (inSize != outSizeCur) /* check it */ + return SZ_ERROR_DATA; + RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); + } + else if (coder->MethodID == k_LZMA) + { + RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + else if (coder->MethodID == k_LZMA2) + { + RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + else + return SZ_ERROR_UNSUPPORTED; + } + else if (coder->MethodID == k_BCJ2) + { + uint64_t offset = GetSum(packSizes, 1); + uint64_t s3Size = packSizes[1]; + SRes res; + if (ci != 3) + return SZ_ERROR_UNSUPPORTED; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + tempSizes[2] = (size_t)s3Size; + if (tempSizes[2] != s3Size) + return SZ_ERROR_MEM; + tempBuf[2] = (uint8_t *)IAlloc_Alloc(allocMain, tempSizes[2]); + if (tempBuf[2] == 0 && tempSizes[2] != 0) + return SZ_ERROR_MEM; + res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); + RINOK(res) + + res = Bcj2_Decode( + tempBuf3, tempSize3, + tempBuf[0], tempSizes[0], + tempBuf[1], tempSizes[1], + tempBuf[2], tempSizes[2], + outBuffer, outSize); + RINOK(res) + } + else + { + if (ci != 1) + return SZ_ERROR_UNSUPPORTED; + switch(coder->MethodID) + { + case k_BCJ: + { + uint32_t state; + x86_Convert_Init(state); + x86_Convert(outBuffer, outSize, 0, &state, 0); + break; + } + CASE_BRA_CONV(ARM) + default: + return SZ_ERROR_UNSUPPORTED; + } + } + } + return SZ_OK; +} + +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + uint8_t *tempBuf[3] = { 0, 0, 0}; + int i; + SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, + outBuffer, (size_t)outSize, allocMain, tempBuf); + for (i = 0; i < 3; i++) + IAlloc_Free(allocMain, tempBuf[i]); + return res; +} diff --git a/deps/7zip/7zFile.c b/deps/7zip/7zFile.c index 8f0b628fff..6dc10da40c 100644 --- a/deps/7zip/7zFile.c +++ b/deps/7zip/7zFile.c @@ -1,285 +1,285 @@ -/* 7zFile.c -- File IO - 2009-11-24 : Igor Pavlov : Public domain */ - -#include -#include "7zFile.h" - -#ifndef USE_WINDOWS_FILE - -#ifndef UNDER_CE -#include -#endif - -#else - -/* - ReadFile and WriteFile functions in Windows have BUG: - If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) - from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES - (Insufficient system resources exist to complete the requested service). - Probably in some version of Windows there are problems with other sizes: - for 32 MB (maybe also for 16 MB). - And message can be "Network connection was lost" - */ - -#define kChunkSizeMax (1 << 22) - -#endif - -void File_Construct(CSzFile *p) -{ -#ifdef USE_WINDOWS_FILE - p->handle = INVALID_HANDLE_VALUE; -#else - p->file = NULL; -#endif -} - -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -static WRes File_Open(CSzFile *p, const char *name, int writeMode) -{ -#ifdef USE_WINDOWS_FILE - p->handle = CreateFileA(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); -#else - p->file = fopen(name, writeMode ? "wb+" : "rb"); - return (p->file != 0) ? 0 : -#ifdef UNDER_CE - 2; /* ENOENT */ -#else - errno; -#endif -#endif -} - -WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } -WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); } -#endif - -#ifdef USE_WINDOWS_FILE -static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) -{ - p->handle = CreateFileW(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); -} -WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } -#endif - -WRes File_Close(CSzFile *p) -{ -#ifdef USE_WINDOWS_FILE - if (p->handle != INVALID_HANDLE_VALUE) - { - if (!CloseHandle(p->handle)) - return GetLastError(); - p->handle = INVALID_HANDLE_VALUE; - } -#else - if (p->file != NULL) - { - int res = fclose(p->file); - if (res != 0) - return res; - p->file = NULL; - } -#endif - return 0; -} - -WRes File_Read(CSzFile *p, void *data, size_t *size) -{ - size_t originalSize = *size; - if (originalSize == 0) - return 0; - -#ifdef USE_WINDOWS_FILE - - *size = 0; - do - { - DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); - data = (void *)((uint8_t*)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - if (processed == 0) - break; - } - while (originalSize > 0); - return 0; - -#else - - *size = fread(data, 1, originalSize, p->file); - if (*size == originalSize) - return 0; - return ferror(p->file); - -#endif -} - -WRes File_Write(CSzFile *p, const void *data, size_t *size) -{ - size_t originalSize = *size; - if (originalSize == 0) - return 0; - -#ifdef USE_WINDOWS_FILE - - *size = 0; - do - { - DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); - data = (void *)((uint8_t*)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - if (processed == 0) - break; - } - while (originalSize > 0); - return 0; - -#else - - *size = fwrite(data, 1, originalSize, p->file); - if (*size == originalSize) - return 0; - return ferror(p->file); - -#endif -} - -WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin) -{ -#ifdef USE_WINDOWS_FILE - - LARGE_INTEGER value; - DWORD moveMethod; - value.LowPart = (DWORD)*pos; - value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ - switch (origin) - { - case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; - case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; - case SZ_SEEK_END: moveMethod = FILE_END; break; - default: return ERROR_INVALID_PARAMETER; - } - value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod); - if (value.LowPart == 0xFFFFFFFF) - { - WRes res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *pos = ((int64_t)value.HighPart << 32) | value.LowPart; - return 0; - -#else - - int moveMethod; - int res; - switch (origin) - { - case SZ_SEEK_SET: moveMethod = SEEK_SET; break; - case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; - case SZ_SEEK_END: moveMethod = SEEK_END; break; - default: return 1; - } - res = fseek(p->file, (long)*pos, moveMethod); - *pos = ftell(p->file); - return res; - -#endif -} - -WRes File_GetLength(CSzFile *p, uint64_t *length) -{ -#ifdef USE_WINDOWS_FILE - - DWORD sizeHigh; - DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); - if (sizeLow == 0xFFFFFFFF) - { - DWORD res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *length = (((uint64_t)sizeHigh) << 32) + sizeLow; - return 0; - -#else - - long pos = ftell(p->file); - int res = fseek(p->file, 0, SEEK_END); - *length = ftell(p->file); - fseek(p->file, pos, SEEK_SET); - return res; - -#endif -} - - -/* ---------- FileSeqInStream ---------- */ - -static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size) -{ - CFileSeqInStream *p = (CFileSeqInStream *)pp; - return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ; -} - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p) -{ - p->s.Read = FileSeqInStream_Read; -} - - -/* ---------- FileInStream ---------- */ - -static SRes FileInStream_Read(void *pp, void *buf, size_t *size) -{ - CFileInStream *p = (CFileInStream *)pp; - return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ; -} - -static SRes FileInStream_Seek(void *pp, int64_t *pos, ESzSeek origin) -{ - CFileInStream *p = (CFileInStream *)pp; - return File_Seek(&p->file, pos, origin); -} - -void FileInStream_CreateVTable(CFileInStream *p) -{ - p->s.Read = FileInStream_Read; - p->s.Seek = FileInStream_Seek; -} - - -/* ---------- FileOutStream ---------- */ - -static size_t FileOutStream_Write(void *pp, const void *data, size_t size) -{ - CFileOutStream *p = (CFileOutStream *)pp; - File_Write(&p->file, data, &size); - return size; -} - -void FileOutStream_CreateVTable(CFileOutStream *p) -{ - p->s.Write = FileOutStream_Write; -} +/* 7zFile.c -- File IO + 2009-11-24 : Igor Pavlov : Public domain */ + +#include +#include "7zFile.h" + +#ifndef USE_WINDOWS_FILE + +#ifndef UNDER_CE +#include +#endif + +#else + +/* + ReadFile and WriteFile functions in Windows have BUG: + If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) + from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES + (Insufficient system resources exist to complete the requested service). + Probably in some version of Windows there are problems with other sizes: + for 32 MB (maybe also for 16 MB). + And message can be "Network connection was lost" + */ + +#define kChunkSizeMax (1 << 22) + +#endif + +void File_Construct(CSzFile *p) +{ +#ifdef USE_WINDOWS_FILE + p->handle = INVALID_HANDLE_VALUE; +#else + p->file = NULL; +#endif +} + +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) +static WRes File_Open(CSzFile *p, const char *name, int writeMode) +{ +#ifdef USE_WINDOWS_FILE + p->handle = CreateFileA(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); +#else + p->file = fopen(name, writeMode ? "wb+" : "rb"); + return (p->file != 0) ? 0 : +#ifdef UNDER_CE + 2; /* ENOENT */ +#else + errno; +#endif +#endif +} + +WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } +WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); } +#endif + +#ifdef USE_WINDOWS_FILE +static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) +{ + p->handle = CreateFileW(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); +} +WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } +#endif + +WRes File_Close(CSzFile *p) +{ +#ifdef USE_WINDOWS_FILE + if (p->handle != INVALID_HANDLE_VALUE) + { + if (!CloseHandle(p->handle)) + return GetLastError(); + p->handle = INVALID_HANDLE_VALUE; + } +#else + if (p->file != NULL) + { + int res = fclose(p->file); + if (res != 0) + return res; + p->file = NULL; + } +#endif + return 0; +} + +WRes File_Read(CSzFile *p, void *data, size_t *size) +{ + size_t originalSize = *size; + if (originalSize == 0) + return 0; + +#ifdef USE_WINDOWS_FILE + + *size = 0; + do + { + DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); + data = (void *)((uint8_t*)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + if (processed == 0) + break; + } + while (originalSize > 0); + return 0; + +#else + + *size = fread(data, 1, originalSize, p->file); + if (*size == originalSize) + return 0; + return ferror(p->file); + +#endif +} + +WRes File_Write(CSzFile *p, const void *data, size_t *size) +{ + size_t originalSize = *size; + if (originalSize == 0) + return 0; + +#ifdef USE_WINDOWS_FILE + + *size = 0; + do + { + DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); + data = (void *)((uint8_t*)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + if (processed == 0) + break; + } + while (originalSize > 0); + return 0; + +#else + + *size = fwrite(data, 1, originalSize, p->file); + if (*size == originalSize) + return 0; + return ferror(p->file); + +#endif +} + +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin) +{ +#ifdef USE_WINDOWS_FILE + + LARGE_INTEGER value; + DWORD moveMethod; + value.LowPart = (DWORD)*pos; + value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ + switch (origin) + { + case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; + case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; + case SZ_SEEK_END: moveMethod = FILE_END; break; + default: return ERROR_INVALID_PARAMETER; + } + value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod); + if (value.LowPart == 0xFFFFFFFF) + { + WRes res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *pos = ((int64_t)value.HighPart << 32) | value.LowPart; + return 0; + +#else + + int moveMethod; + int res; + switch (origin) + { + case SZ_SEEK_SET: moveMethod = SEEK_SET; break; + case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; + case SZ_SEEK_END: moveMethod = SEEK_END; break; + default: return 1; + } + res = fseek(p->file, (long)*pos, moveMethod); + *pos = ftell(p->file); + return res; + +#endif +} + +WRes File_GetLength(CSzFile *p, uint64_t *length) +{ +#ifdef USE_WINDOWS_FILE + + DWORD sizeHigh; + DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); + if (sizeLow == 0xFFFFFFFF) + { + DWORD res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *length = (((uint64_t)sizeHigh) << 32) + sizeLow; + return 0; + +#else + + long pos = ftell(p->file); + int res = fseek(p->file, 0, SEEK_END); + *length = ftell(p->file); + fseek(p->file, pos, SEEK_SET); + return res; + +#endif +} + + +/* ---------- FileSeqInStream ---------- */ + +static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size) +{ + CFileSeqInStream *p = (CFileSeqInStream *)pp; + return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ; +} + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p) +{ + p->s.Read = FileSeqInStream_Read; +} + + +/* ---------- FileInStream ---------- */ + +static SRes FileInStream_Read(void *pp, void *buf, size_t *size) +{ + CFileInStream *p = (CFileInStream *)pp; + return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ; +} + +static SRes FileInStream_Seek(void *pp, int64_t *pos, ESzSeek origin) +{ + CFileInStream *p = (CFileInStream *)pp; + return File_Seek(&p->file, pos, origin); +} + +void FileInStream_CreateVTable(CFileInStream *p) +{ + p->s.Read = FileInStream_Read; + p->s.Seek = FileInStream_Seek; +} + + +/* ---------- FileOutStream ---------- */ + +static size_t FileOutStream_Write(void *pp, const void *data, size_t size) +{ + CFileOutStream *p = (CFileOutStream *)pp; + File_Write(&p->file, data, &size); + return size; +} + +void FileOutStream_CreateVTable(CFileOutStream *p) +{ + p->s.Write = FileOutStream_Write; +} diff --git a/deps/7zip/7zFile.h b/deps/7zip/7zFile.h index 86c3ed1060..33910ec420 100644 --- a/deps/7zip/7zFile.h +++ b/deps/7zip/7zFile.h @@ -1,87 +1,87 @@ -/* 7zFile.h -- File IO -2009-11-24 : Igor Pavlov : Public domain */ - -#ifndef __7Z_FILE_H -#define __7Z_FILE_H - -#ifdef _WIN32 -#define USE_WINDOWS_FILE -#endif - -#ifdef USE_WINDOWS_FILE -#include -#else -#include -#endif - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- File ---------- */ - -typedef struct -{ - #ifdef USE_WINDOWS_FILE - HANDLE handle; - #else - FILE *file; - #endif -} CSzFile; - -void File_Construct(CSzFile *p); -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -WRes InFile_Open(CSzFile *p, const char *name); -WRes OutFile_Open(CSzFile *p, const char *name); -#endif -#ifdef USE_WINDOWS_FILE -WRes InFile_OpenW(CSzFile *p, const WCHAR *name); -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); -#endif -WRes File_Close(CSzFile *p); - -/* reads max(*size, remain file's size) bytes */ -WRes File_Read(CSzFile *p, void *data, size_t *size); - -/* writes *size bytes */ -WRes File_Write(CSzFile *p, const void *data, size_t *size); - -WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, uint64_t *length); - - -/* ---------- FileInStream ---------- */ - -typedef struct -{ - ISeqInStream s; - CSzFile file; -} CFileSeqInStream; - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p); - - -typedef struct -{ - ISeekInStream s; - CSzFile file; -} CFileInStream; - -void FileInStream_CreateVTable(CFileInStream *p); - - -typedef struct -{ - ISeqOutStream s; - CSzFile file; -} CFileOutStream; - -void FileOutStream_CreateVTable(CFileOutStream *p); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zFile.h -- File IO +2009-11-24 : Igor Pavlov : Public domain */ + +#ifndef __7Z_FILE_H +#define __7Z_FILE_H + +#ifdef _WIN32 +#define USE_WINDOWS_FILE +#endif + +#ifdef USE_WINDOWS_FILE +#include +#else +#include +#endif + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- File ---------- */ + +typedef struct +{ + #ifdef USE_WINDOWS_FILE + HANDLE handle; + #else + FILE *file; + #endif +} CSzFile; + +void File_Construct(CSzFile *p); +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) +WRes InFile_Open(CSzFile *p, const char *name); +WRes OutFile_Open(CSzFile *p, const char *name); +#endif +#ifdef USE_WINDOWS_FILE +WRes InFile_OpenW(CSzFile *p, const WCHAR *name); +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); +#endif +WRes File_Close(CSzFile *p); + +/* reads max(*size, remain file's size) bytes */ +WRes File_Read(CSzFile *p, void *data, size_t *size); + +/* writes *size bytes */ +WRes File_Write(CSzFile *p, const void *data, size_t *size); + +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); +WRes File_GetLength(CSzFile *p, uint64_t *length); + + +/* ---------- FileInStream ---------- */ + +typedef struct +{ + ISeqInStream s; + CSzFile file; +} CFileSeqInStream; + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p); + + +typedef struct +{ + ISeekInStream s; + CSzFile file; +} CFileInStream; + +void FileInStream_CreateVTable(CFileInStream *p); + + +typedef struct +{ + ISeqOutStream s; + CSzFile file; +} CFileOutStream; + +void FileOutStream_CreateVTable(CFileOutStream *p); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zIn.c b/deps/7zip/7zIn.c index b2b67b063b..62c1d5eb82 100644 --- a/deps/7zip/7zIn.c +++ b/deps/7zip/7zIn.c @@ -1,1371 +1,1371 @@ -/* 7zIn.c -- 7z Input functions - 2010-10-29 : Igor Pavlov : Public domain */ - -#include -#include - -#include "7z.h" -#include "7zCrc.h" -#include "CpuArch.h" - -uint8_t k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - -#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } - -#define NUM_FOLDER_CODERS_MAX 32 -#define NUM_CODER_STREAMS_MAX 32 - -void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); -int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex); - -void SzCoderInfo_Init(CSzCoderInfo *p) -{ - Buf_Init(&p->Props); -} - -void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc) -{ - Buf_Free(&p->Props, alloc); - SzCoderInfo_Init(p); -} - -void SzFolder_Init(CSzFolder *p) -{ - p->Coders = 0; - p->BindPairs = 0; - p->PackStreams = 0; - p->UnpackSizes = 0; - p->NumCoders = 0; - p->NumBindPairs = 0; - p->NumPackStreams = 0; - p->UnpackCRCDefined = 0; - p->UnpackCRC = 0; - p->NumUnpackStreams = 0; -} - -void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) -{ - uint32_t i; - if (p->Coders) - for (i = 0; i < p->NumCoders; i++) - SzCoderInfo_Free(&p->Coders[i], alloc); - IAlloc_Free(alloc, p->Coders); - IAlloc_Free(alloc, p->BindPairs); - IAlloc_Free(alloc, p->PackStreams); - IAlloc_Free(alloc, p->UnpackSizes); - SzFolder_Init(p); -} - -uint32_t SzFolder_GetNumOutStreams(CSzFolder *p) -{ - uint32_t result = 0; - uint32_t i; - for (i = 0; i < p->NumCoders; i++) - result += p->Coders[i].NumOutStreams; - return result; -} - -int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex) -{ - uint32_t i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].InIndex == inStreamIndex) - return i; - return -1; -} - - -int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex) -{ - uint32_t i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].OutIndex == outStreamIndex) - return i; - return -1; -} - -uint64_t SzFolder_GetUnpackSize(CSzFolder *p) -{ - int i = (int)SzFolder_GetNumOutStreams(p); - if (i == 0) - return 0; - for (i--; i >= 0; i--) - if (SzFolder_FindBindPairForOutStream(p, i) < 0) - return p->UnpackSizes[i]; - /* throw 1; */ - return 0; -} - -void SzFile_Init(CSzFileItem *p) -{ - p->HasStream = 1; - p->IsDir = 0; - p->IsAnti = 0; - p->CrcDefined = 0; - p->MTimeDefined = 0; -} - -void SzAr_Init(CSzAr *p) -{ - p->PackSizes = 0; - p->PackCRCsDefined = 0; - p->PackCRCs = 0; - p->Folders = 0; - p->Files = 0; - p->NumPackStreams = 0; - p->NumFolders = 0; - p->NumFiles = 0; -} - -void SzAr_Free(CSzAr *p, ISzAlloc *alloc) -{ - uint32_t i; - if (p->Folders) - for (i = 0; i < p->NumFolders; i++) - SzFolder_Free(&p->Folders[i], alloc); - - IAlloc_Free(alloc, p->PackSizes); - IAlloc_Free(alloc, p->PackCRCsDefined); - IAlloc_Free(alloc, p->PackCRCs); - IAlloc_Free(alloc, p->Folders); - IAlloc_Free(alloc, p->Files); - SzAr_Init(p); -} - - -void SzArEx_Init(CSzArEx *p) -{ - SzAr_Init(&p->db); - p->FolderStartPackStreamIndex = 0; - p->PackStreamStartPositions = 0; - p->FolderStartFileIndex = 0; - p->FileIndexToFolderIndexMap = 0; - p->FileNameOffsets = 0; - Buf_Init(&p->FileNames); -} - -void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) -{ - IAlloc_Free(alloc, p->FolderStartPackStreamIndex); - IAlloc_Free(alloc, p->PackStreamStartPositions); - IAlloc_Free(alloc, p->FolderStartFileIndex); - IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); - - IAlloc_Free(alloc, p->FileNameOffsets); - Buf_Free(&p->FileNames, alloc); - - SzAr_Free(&p->db, alloc); - SzArEx_Init(p); -} - -/* - uint64_t GetFolderPackStreamSize(int folderIndex, int streamIndex) const - { - return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; - } - - uint64_t GetFilePackSize(int fileIndex) const - { - int folderIndex = FileIndexToFolderIndexMap[fileIndex]; - if (folderIndex >= 0) - { - const CSzFolder &folderInfo = Folders[folderIndex]; - if (FolderStartFileIndex[folderIndex] == fileIndex) - return GetFolderFullPackSize(folderIndex); - } - return 0; - } - */ - -#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \ - if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; } - -static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) -{ - uint32_t startPos = 0; - uint64_t startPosSize = 0; - uint32_t i; - uint32_t folderIndex = 0; - uint32_t indexInFolder = 0; - MY_ALLOC(uint32_t, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); - for (i = 0; i < p->db.NumFolders; i++) - { - p->FolderStartPackStreamIndex[i] = startPos; - startPos += p->db.Folders[i].NumPackStreams; - } - - MY_ALLOC(uint64_t, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); - - for (i = 0; i < p->db.NumPackStreams; i++) - { - p->PackStreamStartPositions[i] = startPosSize; - startPosSize += p->db.PackSizes[i]; - } - - MY_ALLOC(uint32_t, p->FolderStartFileIndex, p->db.NumFolders, alloc); - MY_ALLOC(uint32_t, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); - - for (i = 0; i < p->db.NumFiles; i++) - { - CSzFileItem *file = p->db.Files + i; - int emptyStream = !file->HasStream; - if (emptyStream && indexInFolder == 0) - { - p->FileIndexToFolderIndexMap[i] = (uint32_t)-1; - continue; - } - if (indexInFolder == 0) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: Loop for skipping empty folders - */ - for (;;) - { - if (folderIndex >= p->db.NumFolders) - return SZ_ERROR_ARCHIVE; - p->FolderStartFileIndex[folderIndex] = i; - if (p->db.Folders[folderIndex].NumUnpackStreams != 0) - break; - folderIndex++; - } - } - p->FileIndexToFolderIndexMap[i] = folderIndex; - if (emptyStream) - continue; - indexInFolder++; - if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) - { - folderIndex++; - indexInFolder = 0; - } - } - return SZ_OK; -} - - -uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder) -{ - return p->dataPos + - p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; -} - -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize) -{ - uint32_t packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; - CSzFolder *folder = p->db.Folders + folderIndex; - uint64_t size = 0; - uint32_t i; - for (i = 0; i < folder->NumPackStreams; i++) - { - uint64_t t = size + p->db.PackSizes[packStreamIndex + i]; - if (t < size) /* check it */ - return SZ_ERROR_FAIL; - size = t; - } - *resSize = size; - return SZ_OK; -} - - -static int TestSignatureCandidate(uint8_t *testuint8_ts) -{ - size_t i; - for (i = 0; i < k7zSignatureSize; i++) - if (testuint8_ts[i] != k7zSignature[i]) - return 0; - return 1; -} - -typedef struct _CSzState -{ - uint8_t *Data; - size_t Size; -}CSzData; - -static SRes SzReaduint8_t(CSzData *sd, uint8_t *b) -{ - if (sd->Size == 0) - return SZ_ERROR_ARCHIVE; - sd->Size--; - *b = *sd->Data++; - return SZ_OK; -} - -static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) -{ - size_t i; - for (i = 0; i < size; i++) - { - RINOK(SzReaduint8_t(sd, data + i)); - } - return SZ_OK; -} - -static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) -{ - int i; - *value = 0; - for (i = 0; i < 4; i++) - { - uint8_t b; - RINOK(SzReaduint8_t(sd, &b)); - *value |= ((uint32_t)(b) << (8 * i)); - } - return SZ_OK; -} - -static SRes SzReadNumber(CSzData *sd, uint64_t *value) -{ - uint8_t firstuint8_t; - uint8_t mask = 0x80; - int i; - RINOK(SzReaduint8_t(sd, &firstuint8_t)); - *value = 0; - for (i = 0; i < 8; i++) - { - uint8_t b; - if ((firstuint8_t & mask) == 0) - { - uint64_t highPart = firstuint8_t & (mask - 1); - *value += (highPart << (8 * i)); - return SZ_OK; - } - RINOK(SzReaduint8_t(sd, &b)); - *value |= ((uint64_t)b << (8 * i)); - mask >>= 1; - } - return SZ_OK; -} - -static SRes SzReadNumber32(CSzData *sd, uint32_t *value) -{ - uint64_t value64; - RINOK(SzReadNumber(sd, &value64)); - if (value64 >= 0x80000000) - return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 2))) - return SZ_ERROR_UNSUPPORTED; - *value = (uint32_t)value64; - return SZ_OK; -} - -static SRes SzReadID(CSzData *sd, uint64_t *value) -{ - return SzReadNumber(sd, value); -} - -static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) -{ - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - sd->Size -= (size_t)size; - sd->Data += (size_t)size; - return SZ_OK; -} - -static SRes SzSkeepData(CSzData *sd) -{ - uint64_t size; - RINOK(SzReadNumber(sd, &size)); - return SzSkeepDataSize(sd, size); -} - -static SRes SzReadArchiveProperties(CSzData *sd) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - SzSkeepData(sd); - } - return SZ_OK; -} - -static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == attribute) - return SZ_OK; - if (type == k7zIdEnd) - return SZ_ERROR_ARCHIVE; - RINOK(SzSkeepData(sd)); - } -} - -static SRes SzReadBoolVector(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) -{ - uint8_t b = 0; - uint8_t mask = 0; - size_t i; - MY_ALLOC(uint8_t, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - { - if (mask == 0) - { - RINOK(SzReaduint8_t(sd, &b)); - mask = 0x80; - } - (*v)[i] = (uint8_t)(((b & mask) != 0) ? 1 : 0); - mask >>= 1; - } - return SZ_OK; -} - -static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) -{ - uint8_t allAreDefined; - size_t i; - RINOK(SzReaduint8_t(sd, &allAreDefined)); - if (allAreDefined == 0) - return SzReadBoolVector(sd, numItems, v, alloc); - MY_ALLOC(uint8_t, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - (*v)[i] = 1; - return SZ_OK; -} - -static SRes SzReadHashDigests( - CSzData *sd, - size_t numItems, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *alloc) -{ - size_t i; - RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); - MY_ALLOC(uint32_t, *digests, numItems, alloc); - for (i = 0; i < numItems; i++) - if ((*digestsDefined)[i]) - { - RINOK(SzReaduint32_t(sd, (*digests) + i)); - } - return SZ_OK; -} - -static SRes SzReadPackInfo( - CSzData *sd, - uint64_t *dataOffset, - uint32_t *numPackStreams, - uint64_t **packSizes, - uint8_t **packCRCsDefined, - uint32_t **packCRCs, - ISzAlloc *alloc) -{ - uint32_t i; - RINOK(SzReadNumber(sd, dataOffset)); - RINOK(SzReadNumber32(sd, numPackStreams)); - - RINOK(SzWaitAttribute(sd, k7zIdSize)); - - MY_ALLOC(uint64_t, *packSizes, (size_t)*numPackStreams, alloc); - - for (i = 0; i < *numPackStreams; i++) - { - RINOK(SzReadNumber(sd, (*packSizes) + i)); - } - - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - if (type == k7zIdCRC) - { - RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, alloc)); - continue; - } - RINOK(SzSkeepData(sd)); - } - if (*packCRCsDefined == 0) - { - MY_ALLOC(uint8_t, *packCRCsDefined, (size_t)*numPackStreams, alloc); - MY_ALLOC(uint32_t, *packCRCs, (size_t)*numPackStreams, alloc); - for (i = 0; i < *numPackStreams; i++) - { - (*packCRCsDefined)[i] = 0; - (*packCRCs)[i] = 0; - } - } - return SZ_OK; -} - -static SRes SzReadSwitch(CSzData *sd) -{ - uint8_t external; - RINOK(SzReaduint8_t(sd, &external)); - return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; -} - -static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) -{ - uint32_t numCoders, numBindPairs, numPackStreams, i; - uint32_t numInStreams = 0, numOutStreams = 0; - - RINOK(SzReadNumber32(sd, &numCoders)); - if (numCoders > NUM_FOLDER_CODERS_MAX) - return SZ_ERROR_UNSUPPORTED; - folder->NumCoders = numCoders; - - MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); - - for (i = 0; i < numCoders; i++) - SzCoderInfo_Init(folder->Coders + i); - - for (i = 0; i < numCoders; i++) - { - uint8_t mainuint8_t; - CSzCoderInfo *coder = folder->Coders + i; - { - unsigned idSize, j; - uint8_t longID[15]; - RINOK(SzReaduint8_t(sd, &mainuint8_t)); - idSize = (unsigned)(mainuint8_t & 0xF); - RINOK(SzReaduint8_ts(sd, longID, idSize)); - if (idSize > sizeof(coder->MethodID)) - return SZ_ERROR_UNSUPPORTED; - coder->MethodID = 0; - for (j = 0; j < idSize; j++) - coder->MethodID |= (uint64_t)longID[idSize - 1 - j] << (8 * j); - - if ((mainuint8_t & 0x10) != 0) - { - RINOK(SzReadNumber32(sd, &coder->NumInStreams)); - RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); - if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || - coder->NumOutStreams > NUM_CODER_STREAMS_MAX) - return SZ_ERROR_UNSUPPORTED; - } - else - { - coder->NumInStreams = 1; - coder->NumOutStreams = 1; - } - if ((mainuint8_t & 0x20) != 0) - { - uint64_t propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) - return SZ_ERROR_MEM; - RINOK(SzReaduint8_ts(sd, coder->Props.data, (size_t)propertiesSize)); - } - } - while ((mainuint8_t & 0x80) != 0) - { - RINOK(SzReaduint8_t(sd, &mainuint8_t)); - RINOK(SzSkeepDataSize(sd, (mainuint8_t & 0xF))); - if ((mainuint8_t & 0x10) != 0) - { - uint32_t n; - RINOK(SzReadNumber32(sd, &n)); - RINOK(SzReadNumber32(sd, &n)); - } - if ((mainuint8_t & 0x20) != 0) - { - uint64_t propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - RINOK(SzSkeepDataSize(sd, propertiesSize)); - } - } - numInStreams += coder->NumInStreams; - numOutStreams += coder->NumOutStreams; - } - - if (numOutStreams == 0) - return SZ_ERROR_UNSUPPORTED; - - folder->NumBindPairs = numBindPairs = numOutStreams - 1; - MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); - - for (i = 0; i < numBindPairs; i++) - { - CSzBindPair *bp = folder->BindPairs + i; - RINOK(SzReadNumber32(sd, &bp->InIndex)); - RINOK(SzReadNumber32(sd, &bp->OutIndex)); - } - - if (numInStreams < numBindPairs) - return SZ_ERROR_UNSUPPORTED; - - folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; - MY_ALLOC(uint32_t, folder->PackStreams, (size_t)numPackStreams, alloc); - - if (numPackStreams == 1) - { - for (i = 0; i < numInStreams ; i++) - if (SzFolder_FindBindPairForInStream(folder, i) < 0) - break; - if (i == numInStreams) - return SZ_ERROR_UNSUPPORTED; - folder->PackStreams[0] = i; - } - else - for (i = 0; i < numPackStreams; i++) - { - RINOK(SzReadNumber32(sd, folder->PackStreams + i)); - } - return SZ_OK; -} - -static SRes SzReadUnpackInfo( - CSzData *sd, - uint32_t *numFolders, - CSzFolder **folders, /* for alloc */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - uint32_t i; - RINOK(SzWaitAttribute(sd, k7zIdFolder)); - RINOK(SzReadNumber32(sd, numFolders)); - { - RINOK(SzReadSwitch(sd)); - - MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); - - for (i = 0; i < *numFolders; i++) - SzFolder_Init((*folders) + i); - - for (i = 0; i < *numFolders; i++) - { - RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); - } - } - - RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); - - for (i = 0; i < *numFolders; i++) - { - uint32_t j; - CSzFolder *folder = (*folders) + i; - uint32_t numOutStreams = SzFolder_GetNumOutStreams(folder); - - MY_ALLOC(uint64_t, folder->UnpackSizes, (size_t)numOutStreams, alloc); - - for (j = 0; j < numOutStreams; j++) - { - RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); - } - } - - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - SRes res; - uint8_t *crcsDefined = 0; - uint32_t *crcs = 0; - res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < *numFolders; i++) - { - CSzFolder *folder = (*folders) + i; - folder->UnpackCRCDefined = crcsDefined[i]; - folder->UnpackCRC = crcs[i]; - } - } - IAlloc_Free(allocTemp, crcs); - IAlloc_Free(allocTemp, crcsDefined); - RINOK(res); - continue; - } - RINOK(SzSkeepData(sd)); - } -} - -static SRes SzReadSubStreamsInfo( - CSzData *sd, - uint32_t numFolders, - CSzFolder *folders, - uint32_t *numUnpackStreams, - uint64_t **unpackSizes, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *allocTemp) -{ - uint64_t type = 0; - uint32_t i; - uint32_t si = 0; - uint32_t numDigests = 0; - - for (i = 0; i < numFolders; i++) - folders[i].NumUnpackStreams = 1; - *numUnpackStreams = numFolders; - - for (;;) - { - RINOK(SzReadID(sd, &type)); - if (type == k7zIdNumUnpackStream) - { - *numUnpackStreams = 0; - for (i = 0; i < numFolders; i++) - { - uint32_t numStreams; - RINOK(SzReadNumber32(sd, &numStreams)); - folders[i].NumUnpackStreams = numStreams; - *numUnpackStreams += numStreams; - } - continue; - } - if (type == k7zIdCRC || type == k7zIdSize) - break; - if (type == k7zIdEnd) - break; - RINOK(SzSkeepData(sd)); - } - - if (*numUnpackStreams == 0) - { - *unpackSizes = 0; - *digestsDefined = 0; - *digests = 0; - } - else - { - *unpackSizes = (uint64_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint64_t)); - RINOM(*unpackSizes); - *digestsDefined = (uint8_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint8_t)); - RINOM(*digestsDefined); - *digests = (uint32_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint32_t)); - RINOM(*digests); - } - - for (i = 0; i < numFolders; i++) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: we check that folder is empty - */ - uint64_t sum = 0; - uint32_t j; - uint32_t numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams == 0) - continue; - if (type == k7zIdSize) - for (j = 1; j < numSubstreams; j++) - { - uint64_t size; - RINOK(SzReadNumber(sd, &size)); - (*unpackSizes)[si++] = size; - sum += size; - } - (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; - } - if (type == k7zIdSize) - { - RINOK(SzReadID(sd, &type)); - } - - for (i = 0; i < *numUnpackStreams; i++) - { - (*digestsDefined)[i] = 0; - (*digests)[i] = 0; - } - - - for (i = 0; i < numFolders; i++) - { - uint32_t numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) - numDigests += numSubstreams; - } - - - si = 0; - for (;;) - { - if (type == k7zIdCRC) - { - int digestIndex = 0; - uint8_t *digestsDefined2 = 0; - uint32_t *digests2 = 0; - SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < numFolders; i++) - { - CSzFolder *folder = folders + i; - uint32_t numSubstreams = folder->NumUnpackStreams; - if (numSubstreams == 1 && folder->UnpackCRCDefined) - { - (*digestsDefined)[si] = 1; - (*digests)[si] = folder->UnpackCRC; - si++; - } - else - { - uint32_t j; - for (j = 0; j < numSubstreams; j++, digestIndex++) - { - (*digestsDefined)[si] = digestsDefined2[digestIndex]; - (*digests)[si] = digests2[digestIndex]; - si++; - } - } - } - } - IAlloc_Free(allocTemp, digestsDefined2); - IAlloc_Free(allocTemp, digests2); - RINOK(res); - } - else if (type == k7zIdEnd) - return SZ_OK; - else - { - RINOK(SzSkeepData(sd)); - } - RINOK(SzReadID(sd, &type)); - } -} - - -static SRes SzReadStreamsInfo( - CSzData *sd, - uint64_t *dataOffset, - CSzAr *p, - uint32_t *numUnpackStreams, - uint64_t **unpackSizes, /* allocTemp */ - uint8_t **digestsDefined, /* allocTemp */ - uint32_t **digests, /* allocTemp */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if ((uint64_t)(int)type != type) - return SZ_ERROR_UNSUPPORTED; - switch((int)type) - { - case k7zIdEnd: - return SZ_OK; - case k7zIdPackInfo: - { - RINOK(SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, - &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc)); - break; - } - case k7zIdUnpackInfo: - { - RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); - break; - } - case k7zIdSubStreamsInfo: - { - RINOK(SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, - numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp)); - break; - } - default: - return SZ_ERROR_UNSUPPORTED; - } - } -} - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest) -{ - size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - if (dest != 0) - { - size_t i; - const uint8_t *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); - for (i = 0; i < len; i++) - dest[i] = GetUi16(src + i * 2); - } - return len; -} - -static SRes SzReadFileNames(const uint8_t *p, size_t size, uint32_t numFiles, size_t *sizes) -{ - uint32_t i; - size_t pos = 0; - for (i = 0; i < numFiles; i++) - { - sizes[i] = pos; - for (;;) - { - if (pos >= size) - return SZ_ERROR_ARCHIVE; - if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) - break; - pos++; - } - pos++; - } - sizes[i] = pos; - return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; -} - -static SRes SzReadHeader2( - CSzArEx *p, /* allocMain */ - CSzData *sd, - uint64_t **unpackSizes, /* allocTemp */ - uint8_t **digestsDefined, /* allocTemp */ - uint32_t **digests, /* allocTemp */ - uint8_t **emptyStreamVector, /* allocTemp */ - uint8_t **emptyFileVector, /* allocTemp */ - uint8_t **lwtVector, /* allocTemp */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint64_t type; - uint32_t numUnpackStreams = 0; - uint32_t numFiles = 0; - CSzFileItem *files = 0; - uint32_t numEmptyStreams = 0; - uint32_t i; - - RINOK(SzReadID(sd, &type)); - - if (type == k7zIdArchiveProperties) - { - RINOK(SzReadArchiveProperties(sd)); - RINOK(SzReadID(sd, &type)); - } - - - if (type == k7zIdMainStreamsInfo) - { - RINOK(SzReadStreamsInfo(sd, - &p->dataPos, - &p->db, - &numUnpackStreams, - unpackSizes, - digestsDefined, - digests, allocMain, allocTemp)); - p->dataPos += p->startPosAfterHeader; - RINOK(SzReadID(sd, &type)); - } - - if (type == k7zIdEnd) - return SZ_OK; - if (type != k7zIdFilesInfo) - return SZ_ERROR_ARCHIVE; - - RINOK(SzReadNumber32(sd, &numFiles)); - p->db.NumFiles = numFiles; - - MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); - - p->db.Files = files; - for (i = 0; i < numFiles; i++) - SzFile_Init(files + i); - - for (;;) - { - uint64_t size; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(SzReadNumber(sd, &size)); - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - if ((uint64_t)(int)type != type) - { - RINOK(SzSkeepDataSize(sd, size)); - } - else - switch((int)type) - { - case k7zIdName: - { - size_t namesSize; - RINOK(SzReadSwitch(sd)); - namesSize = (size_t)size - 1; - if ((namesSize & 1) != 0) - return SZ_ERROR_ARCHIVE; - if (!Buf_Create(&p->FileNames, namesSize, allocMain)) - return SZ_ERROR_MEM; - MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); - memcpy(p->FileNames.data, sd->Data, namesSize); - RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets)) - RINOK(SzSkeepDataSize(sd, namesSize)); - break; - } - case k7zIdEmptyStream: - { - RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); - numEmptyStreams = 0; - for (i = 0; i < numFiles; i++) - if ((*emptyStreamVector)[i]) - numEmptyStreams++; - break; - } - case k7zIdEmptyFile: - { - RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp)); - break; - } - case k7zIdWinAttributes: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); - for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - uint8_t defined = (*lwtVector)[i]; - f->AttribDefined = defined; - f->Attrib = 0; - if (defined) - { - RINOK(SzReaduint32_t(sd, &f->Attrib)); - } - } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - case k7zIdMTime: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); - for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - uint8_t defined = (*lwtVector)[i]; - f->MTimeDefined = defined; - f->MTime.Low = f->MTime.High = 0; - if (defined) - { - RINOK(SzReaduint32_t(sd, &f->MTime.Low)); - RINOK(SzReaduint32_t(sd, &f->MTime.High)); - } - } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - default: - { - RINOK(SzSkeepDataSize(sd, size)); - } - } - } - - { - uint32_t emptyFileIndex = 0; - uint32_t sizeIndex = 0; - for (i = 0; i < numFiles; i++) - { - CSzFileItem *file = files + i; - file->IsAnti = 0; - if (*emptyStreamVector == 0) - file->HasStream = 1; - else - file->HasStream = (uint8_t)((*emptyStreamVector)[i] ? 0 : 1); - if (file->HasStream) - { - file->IsDir = 0; - file->Size = (*unpackSizes)[sizeIndex]; - file->Crc = (*digests)[sizeIndex]; - file->CrcDefined = (uint8_t)(*digestsDefined)[sizeIndex]; - sizeIndex++; - } - else - { - if (*emptyFileVector == 0) - file->IsDir = 1; - else - file->IsDir = (uint8_t)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); - emptyFileIndex++; - file->Size = 0; - file->Crc = 0; - file->CrcDefined = 0; - } - } - } - return SzArEx_Fill(p, allocMain); -} - -static SRes SzReadHeader( - CSzArEx *p, - CSzData *sd, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint64_t *unpackSizes = 0; - uint8_t *digestsDefined = 0; - uint32_t *digests = 0; - uint8_t *emptyStreamVector = 0; - uint8_t *emptyFileVector = 0; - uint8_t *lwtVector = 0; - SRes res = SzReadHeader2(p, sd, - &unpackSizes, &digestsDefined, &digests, - &emptyStreamVector, &emptyFileVector, &lwtVector, - allocMain, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - IAlloc_Free(allocTemp, emptyStreamVector); - IAlloc_Free(allocTemp, emptyFileVector); - IAlloc_Free(allocTemp, lwtVector); - return res; -} - -static SRes SzReadAndDecodePackedStreams2( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - uint64_t baseOffset, - CSzAr *p, - uint64_t **unpackSizes, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *allocTemp) -{ - - uint32_t numUnpackStreams = 0; - uint64_t dataStartPos; - CSzFolder *folder; - uint64_t unpackSize; - SRes res; - - RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, - &numUnpackStreams, unpackSizes, digestsDefined, digests, - allocTemp, allocTemp)); - - dataStartPos += baseOffset; - if (p->NumFolders != 1) - return SZ_ERROR_ARCHIVE; - - folder = p->Folders; - unpackSize = SzFolder_GetUnpackSize(folder); - - RINOK(LookInStream_SeekTo(inStream, dataStartPos)); - - if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) - return SZ_ERROR_MEM; - - res = SzFolder_Decode(folder, p->PackSizes, - inStream, dataStartPos, - outBuffer->data, (size_t)unpackSize, allocTemp); - RINOK(res); - if (folder->UnpackCRCDefined) - if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) - return SZ_ERROR_CRC; - return SZ_OK; -} - -static SRes SzReadAndDecodePackedStreams( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - uint64_t baseOffset, - ISzAlloc *allocTemp) -{ - CSzAr p; - uint64_t *unpackSizes = 0; - uint8_t *digestsDefined = 0; - uint32_t *digests = 0; - SRes res; - SzAr_Init(&p); - res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, - &p, &unpackSizes, &digestsDefined, &digests, - allocTemp); - SzAr_Free(&p, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - return res; -} - -static SRes SzArEx_Open2( - CSzArEx *p, - ILookInStream *inStream, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint8_t header[k7zStartHeaderSize]; - int64_t startArcPos; - uint64_t nextHeaderOffset, nextHeaderSize; - size_t nextHeaderSizeT; - uint32_t nextHeaderCRC; - CBuf buffer; - SRes res; - - startArcPos = 0; - RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); - - RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); - - if (!TestSignatureCandidate(header)) - return SZ_ERROR_NO_ARCHIVE; - if (header[6] != k7zMajorVersion) - return SZ_ERROR_UNSUPPORTED; - - nextHeaderOffset = GetUi64(header + 12); - nextHeaderSize = GetUi64(header + 20); - nextHeaderCRC = GetUi32(header + 28); - - p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; - - if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) - return SZ_ERROR_CRC; - - nextHeaderSizeT = (size_t)nextHeaderSize; - if (nextHeaderSizeT != nextHeaderSize) - return SZ_ERROR_MEM; - if (nextHeaderSizeT == 0) - return SZ_OK; - if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || - nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) - return SZ_ERROR_NO_ARCHIVE; - - { - int64_t pos = 0; - RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); - if ((uint64_t)pos < startArcPos + nextHeaderOffset || - (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) - return SZ_ERROR_INPUT_EOF; - } - - RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); - - if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) - return SZ_ERROR_MEM; - - res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); - if (res == SZ_OK) - { - res = SZ_ERROR_ARCHIVE; - if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) - { - CSzData sd; - uint64_t type; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - if (res == SZ_OK) - { - if (type == k7zIdEncodedHeader) - { - CBuf outBuffer; - Buf_Init(&outBuffer); - res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, p->startPosAfterHeader, allocTemp); - if (res != SZ_OK) - Buf_Free(&outBuffer, allocTemp); - else - { - Buf_Free(&buffer, allocTemp); - buffer.data = outBuffer.data; - buffer.size = outBuffer.size; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - } - } - } - if (res == SZ_OK) - { - if (type == k7zIdHeader) - res = SzReadHeader(p, &sd, allocMain, allocTemp); - else - res = SZ_ERROR_UNSUPPORTED; - } - } - } - Buf_Free(&buffer, allocTemp); - return res; -} - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp) -{ - SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); - if (res != SZ_OK) - SzArEx_Free(p, allocMain); - return res; -} - -SRes SzArEx_Extract( - const CSzArEx *p, - ILookInStream *inStream, - uint32_t fileIndex, - uint32_t *blockIndex, - uint8_t **outBuffer, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint32_t folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; - SRes res = SZ_OK; - *offset = 0; - *outSizeProcessed = 0; - if (folderIndex == (uint32_t)-1) - { - IAlloc_Free(allocMain, *outBuffer); - *blockIndex = folderIndex; - *outBuffer = 0; - *outBufferSize = 0; - return SZ_OK; - } - - if (*outBuffer == 0 || *blockIndex != folderIndex) - { - CSzFolder *folder = p->db.Folders + folderIndex; - uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); - size_t unpackSize = (size_t)unpackSizeSpec; - uint64_t startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); - - if (unpackSize != unpackSizeSpec) - return SZ_ERROR_MEM; - *blockIndex = folderIndex; - IAlloc_Free(allocMain, *outBuffer); - *outBuffer = 0; - - RINOK(LookInStream_SeekTo(inStream, startOffset)); - - if (res == SZ_OK) - { - *outBufferSize = unpackSize; - if (unpackSize != 0) - { - *outBuffer = (uint8_t *)IAlloc_Alloc(allocMain, unpackSize); - if (*outBuffer == 0) - res = SZ_ERROR_MEM; - } - if (res == SZ_OK) - { - res = SzFolder_Decode(folder, - p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], - inStream, startOffset, - *outBuffer, unpackSize, allocTemp); - if (res == SZ_OK) - { - if (folder->UnpackCRCDefined) - { - if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC) - res = SZ_ERROR_CRC; - } - } - } - } - } - if (res == SZ_OK) - { - uint32_t i; - CSzFileItem *fileItem = p->db.Files + fileIndex; - *offset = 0; - for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) - *offset += (uint32_t)p->db.Files[i].Size; - *outSizeProcessed = (size_t)fileItem->Size; - if (*offset + *outSizeProcessed > *outBufferSize) - return SZ_ERROR_FAIL; - if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) - res = SZ_ERROR_CRC; - } - return res; -} +/* 7zIn.c -- 7z Input functions + 2010-10-29 : Igor Pavlov : Public domain */ + +#include +#include + +#include "7z.h" +#include "7zCrc.h" +#include "CpuArch.h" + +uint8_t k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; + +#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } + +#define NUM_FOLDER_CODERS_MAX 32 +#define NUM_CODER_STREAMS_MAX 32 + +void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex); + +void SzCoderInfo_Init(CSzCoderInfo *p) +{ + Buf_Init(&p->Props); +} + +void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc) +{ + Buf_Free(&p->Props, alloc); + SzCoderInfo_Init(p); +} + +void SzFolder_Init(CSzFolder *p) +{ + p->Coders = 0; + p->BindPairs = 0; + p->PackStreams = 0; + p->UnpackSizes = 0; + p->NumCoders = 0; + p->NumBindPairs = 0; + p->NumPackStreams = 0; + p->UnpackCRCDefined = 0; + p->UnpackCRC = 0; + p->NumUnpackStreams = 0; +} + +void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) +{ + uint32_t i; + if (p->Coders) + for (i = 0; i < p->NumCoders; i++) + SzCoderInfo_Free(&p->Coders[i], alloc); + IAlloc_Free(alloc, p->Coders); + IAlloc_Free(alloc, p->BindPairs); + IAlloc_Free(alloc, p->PackStreams); + IAlloc_Free(alloc, p->UnpackSizes); + SzFolder_Init(p); +} + +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p) +{ + uint32_t result = 0; + uint32_t i; + for (i = 0; i < p->NumCoders; i++) + result += p->Coders[i].NumOutStreams; + return result; +} + +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex) +{ + uint32_t i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].InIndex == inStreamIndex) + return i; + return -1; +} + + +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex) +{ + uint32_t i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].OutIndex == outStreamIndex) + return i; + return -1; +} + +uint64_t SzFolder_GetUnpackSize(CSzFolder *p) +{ + int i = (int)SzFolder_GetNumOutStreams(p); + if (i == 0) + return 0; + for (i--; i >= 0; i--) + if (SzFolder_FindBindPairForOutStream(p, i) < 0) + return p->UnpackSizes[i]; + /* throw 1; */ + return 0; +} + +void SzFile_Init(CSzFileItem *p) +{ + p->HasStream = 1; + p->IsDir = 0; + p->IsAnti = 0; + p->CrcDefined = 0; + p->MTimeDefined = 0; +} + +void SzAr_Init(CSzAr *p) +{ + p->PackSizes = 0; + p->PackCRCsDefined = 0; + p->PackCRCs = 0; + p->Folders = 0; + p->Files = 0; + p->NumPackStreams = 0; + p->NumFolders = 0; + p->NumFiles = 0; +} + +void SzAr_Free(CSzAr *p, ISzAlloc *alloc) +{ + uint32_t i; + if (p->Folders) + for (i = 0; i < p->NumFolders; i++) + SzFolder_Free(&p->Folders[i], alloc); + + IAlloc_Free(alloc, p->PackSizes); + IAlloc_Free(alloc, p->PackCRCsDefined); + IAlloc_Free(alloc, p->PackCRCs); + IAlloc_Free(alloc, p->Folders); + IAlloc_Free(alloc, p->Files); + SzAr_Init(p); +} + + +void SzArEx_Init(CSzArEx *p) +{ + SzAr_Init(&p->db); + p->FolderStartPackStreamIndex = 0; + p->PackStreamStartPositions = 0; + p->FolderStartFileIndex = 0; + p->FileIndexToFolderIndexMap = 0; + p->FileNameOffsets = 0; + Buf_Init(&p->FileNames); +} + +void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) +{ + IAlloc_Free(alloc, p->FolderStartPackStreamIndex); + IAlloc_Free(alloc, p->PackStreamStartPositions); + IAlloc_Free(alloc, p->FolderStartFileIndex); + IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); + + IAlloc_Free(alloc, p->FileNameOffsets); + Buf_Free(&p->FileNames, alloc); + + SzAr_Free(&p->db, alloc); + SzArEx_Init(p); +} + +/* + uint64_t GetFolderPackStreamSize(int folderIndex, int streamIndex) const + { + return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; + } + + uint64_t GetFilePackSize(int fileIndex) const + { + int folderIndex = FileIndexToFolderIndexMap[fileIndex]; + if (folderIndex >= 0) + { + const CSzFolder &folderInfo = Folders[folderIndex]; + if (FolderStartFileIndex[folderIndex] == fileIndex) + return GetFolderFullPackSize(folderIndex); + } + return 0; + } + */ + +#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \ + if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; } + +static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) +{ + uint32_t startPos = 0; + uint64_t startPosSize = 0; + uint32_t i; + uint32_t folderIndex = 0; + uint32_t indexInFolder = 0; + MY_ALLOC(uint32_t, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); + for (i = 0; i < p->db.NumFolders; i++) + { + p->FolderStartPackStreamIndex[i] = startPos; + startPos += p->db.Folders[i].NumPackStreams; + } + + MY_ALLOC(uint64_t, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); + + for (i = 0; i < p->db.NumPackStreams; i++) + { + p->PackStreamStartPositions[i] = startPosSize; + startPosSize += p->db.PackSizes[i]; + } + + MY_ALLOC(uint32_t, p->FolderStartFileIndex, p->db.NumFolders, alloc); + MY_ALLOC(uint32_t, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); + + for (i = 0; i < p->db.NumFiles; i++) + { + CSzFileItem *file = p->db.Files + i; + int emptyStream = !file->HasStream; + if (emptyStream && indexInFolder == 0) + { + p->FileIndexToFolderIndexMap[i] = (uint32_t)-1; + continue; + } + if (indexInFolder == 0) + { + /* + v3.13 incorrectly worked with empty folders + v4.07: Loop for skipping empty folders + */ + for (;;) + { + if (folderIndex >= p->db.NumFolders) + return SZ_ERROR_ARCHIVE; + p->FolderStartFileIndex[folderIndex] = i; + if (p->db.Folders[folderIndex].NumUnpackStreams != 0) + break; + folderIndex++; + } + } + p->FileIndexToFolderIndexMap[i] = folderIndex; + if (emptyStream) + continue; + indexInFolder++; + if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) + { + folderIndex++; + indexInFolder = 0; + } + } + return SZ_OK; +} + + +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder) +{ + return p->dataPos + + p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; +} + +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize) +{ + uint32_t packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; + CSzFolder *folder = p->db.Folders + folderIndex; + uint64_t size = 0; + uint32_t i; + for (i = 0; i < folder->NumPackStreams; i++) + { + uint64_t t = size + p->db.PackSizes[packStreamIndex + i]; + if (t < size) /* check it */ + return SZ_ERROR_FAIL; + size = t; + } + *resSize = size; + return SZ_OK; +} + + +static int TestSignatureCandidate(uint8_t *testuint8_ts) +{ + size_t i; + for (i = 0; i < k7zSignatureSize; i++) + if (testuint8_ts[i] != k7zSignature[i]) + return 0; + return 1; +} + +typedef struct _CSzState +{ + uint8_t *Data; + size_t Size; +}CSzData; + +static SRes SzReaduint8_t(CSzData *sd, uint8_t *b) +{ + if (sd->Size == 0) + return SZ_ERROR_ARCHIVE; + sd->Size--; + *b = *sd->Data++; + return SZ_OK; +} + +static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) +{ + size_t i; + for (i = 0; i < size; i++) + { + RINOK(SzReaduint8_t(sd, data + i)); + } + return SZ_OK; +} + +static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) +{ + int i; + *value = 0; + for (i = 0; i < 4; i++) + { + uint8_t b; + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint32_t)(b) << (8 * i)); + } + return SZ_OK; +} + +static SRes SzReadNumber(CSzData *sd, uint64_t *value) +{ + uint8_t firstuint8_t; + uint8_t mask = 0x80; + int i; + RINOK(SzReaduint8_t(sd, &firstuint8_t)); + *value = 0; + for (i = 0; i < 8; i++) + { + uint8_t b; + if ((firstuint8_t & mask) == 0) + { + uint64_t highPart = firstuint8_t & (mask - 1); + *value += (highPart << (8 * i)); + return SZ_OK; + } + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint64_t)b << (8 * i)); + mask >>= 1; + } + return SZ_OK; +} + +static SRes SzReadNumber32(CSzData *sd, uint32_t *value) +{ + uint64_t value64; + RINOK(SzReadNumber(sd, &value64)); + if (value64 >= 0x80000000) + return SZ_ERROR_UNSUPPORTED; + if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 2))) + return SZ_ERROR_UNSUPPORTED; + *value = (uint32_t)value64; + return SZ_OK; +} + +static SRes SzReadID(CSzData *sd, uint64_t *value) +{ + return SzReadNumber(sd, value); +} + +static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) +{ + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + sd->Size -= (size_t)size; + sd->Data += (size_t)size; + return SZ_OK; +} + +static SRes SzSkeepData(CSzData *sd) +{ + uint64_t size; + RINOK(SzReadNumber(sd, &size)); + return SzSkeepDataSize(sd, size); +} + +static SRes SzReadArchiveProperties(CSzData *sd) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + SzSkeepData(sd); + } + return SZ_OK; +} + +static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == attribute) + return SZ_OK; + if (type == k7zIdEnd) + return SZ_ERROR_ARCHIVE; + RINOK(SzSkeepData(sd)); + } +} + +static SRes SzReadBoolVector(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) +{ + uint8_t b = 0; + uint8_t mask = 0; + size_t i; + MY_ALLOC(uint8_t, *v, numItems, alloc); + for (i = 0; i < numItems; i++) + { + if (mask == 0) + { + RINOK(SzReaduint8_t(sd, &b)); + mask = 0x80; + } + (*v)[i] = (uint8_t)(((b & mask) != 0) ? 1 : 0); + mask >>= 1; + } + return SZ_OK; +} + +static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) +{ + uint8_t allAreDefined; + size_t i; + RINOK(SzReaduint8_t(sd, &allAreDefined)); + if (allAreDefined == 0) + return SzReadBoolVector(sd, numItems, v, alloc); + MY_ALLOC(uint8_t, *v, numItems, alloc); + for (i = 0; i < numItems; i++) + (*v)[i] = 1; + return SZ_OK; +} + +static SRes SzReadHashDigests( + CSzData *sd, + size_t numItems, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *alloc) +{ + size_t i; + RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); + MY_ALLOC(uint32_t, *digests, numItems, alloc); + for (i = 0; i < numItems; i++) + if ((*digestsDefined)[i]) + { + RINOK(SzReaduint32_t(sd, (*digests) + i)); + } + return SZ_OK; +} + +static SRes SzReadPackInfo( + CSzData *sd, + uint64_t *dataOffset, + uint32_t *numPackStreams, + uint64_t **packSizes, + uint8_t **packCRCsDefined, + uint32_t **packCRCs, + ISzAlloc *alloc) +{ + uint32_t i; + RINOK(SzReadNumber(sd, dataOffset)); + RINOK(SzReadNumber32(sd, numPackStreams)); + + RINOK(SzWaitAttribute(sd, k7zIdSize)); + + MY_ALLOC(uint64_t, *packSizes, (size_t)*numPackStreams, alloc); + + for (i = 0; i < *numPackStreams; i++) + { + RINOK(SzReadNumber(sd, (*packSizes) + i)); + } + + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + if (type == k7zIdCRC) + { + RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, alloc)); + continue; + } + RINOK(SzSkeepData(sd)); + } + if (*packCRCsDefined == 0) + { + MY_ALLOC(uint8_t, *packCRCsDefined, (size_t)*numPackStreams, alloc); + MY_ALLOC(uint32_t, *packCRCs, (size_t)*numPackStreams, alloc); + for (i = 0; i < *numPackStreams; i++) + { + (*packCRCsDefined)[i] = 0; + (*packCRCs)[i] = 0; + } + } + return SZ_OK; +} + +static SRes SzReadSwitch(CSzData *sd) +{ + uint8_t external; + RINOK(SzReaduint8_t(sd, &external)); + return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; +} + +static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) +{ + uint32_t numCoders, numBindPairs, numPackStreams, i; + uint32_t numInStreams = 0, numOutStreams = 0; + + RINOK(SzReadNumber32(sd, &numCoders)); + if (numCoders > NUM_FOLDER_CODERS_MAX) + return SZ_ERROR_UNSUPPORTED; + folder->NumCoders = numCoders; + + MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); + + for (i = 0; i < numCoders; i++) + SzCoderInfo_Init(folder->Coders + i); + + for (i = 0; i < numCoders; i++) + { + uint8_t mainuint8_t; + CSzCoderInfo *coder = folder->Coders + i; + { + unsigned idSize, j; + uint8_t longID[15]; + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + idSize = (unsigned)(mainuint8_t & 0xF); + RINOK(SzReaduint8_ts(sd, longID, idSize)); + if (idSize > sizeof(coder->MethodID)) + return SZ_ERROR_UNSUPPORTED; + coder->MethodID = 0; + for (j = 0; j < idSize; j++) + coder->MethodID |= (uint64_t)longID[idSize - 1 - j] << (8 * j); + + if ((mainuint8_t & 0x10) != 0) + { + RINOK(SzReadNumber32(sd, &coder->NumInStreams)); + RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); + if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || + coder->NumOutStreams > NUM_CODER_STREAMS_MAX) + return SZ_ERROR_UNSUPPORTED; + } + else + { + coder->NumInStreams = 1; + coder->NumOutStreams = 1; + } + if ((mainuint8_t & 0x20) != 0) + { + uint64_t propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) + return SZ_ERROR_MEM; + RINOK(SzReaduint8_ts(sd, coder->Props.data, (size_t)propertiesSize)); + } + } + while ((mainuint8_t & 0x80) != 0) + { + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + RINOK(SzSkeepDataSize(sd, (mainuint8_t & 0xF))); + if ((mainuint8_t & 0x10) != 0) + { + uint32_t n; + RINOK(SzReadNumber32(sd, &n)); + RINOK(SzReadNumber32(sd, &n)); + } + if ((mainuint8_t & 0x20) != 0) + { + uint64_t propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + RINOK(SzSkeepDataSize(sd, propertiesSize)); + } + } + numInStreams += coder->NumInStreams; + numOutStreams += coder->NumOutStreams; + } + + if (numOutStreams == 0) + return SZ_ERROR_UNSUPPORTED; + + folder->NumBindPairs = numBindPairs = numOutStreams - 1; + MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); + + for (i = 0; i < numBindPairs; i++) + { + CSzBindPair *bp = folder->BindPairs + i; + RINOK(SzReadNumber32(sd, &bp->InIndex)); + RINOK(SzReadNumber32(sd, &bp->OutIndex)); + } + + if (numInStreams < numBindPairs) + return SZ_ERROR_UNSUPPORTED; + + folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; + MY_ALLOC(uint32_t, folder->PackStreams, (size_t)numPackStreams, alloc); + + if (numPackStreams == 1) + { + for (i = 0; i < numInStreams ; i++) + if (SzFolder_FindBindPairForInStream(folder, i) < 0) + break; + if (i == numInStreams) + return SZ_ERROR_UNSUPPORTED; + folder->PackStreams[0] = i; + } + else + for (i = 0; i < numPackStreams; i++) + { + RINOK(SzReadNumber32(sd, folder->PackStreams + i)); + } + return SZ_OK; +} + +static SRes SzReadUnpackInfo( + CSzData *sd, + uint32_t *numFolders, + CSzFolder **folders, /* for alloc */ + ISzAlloc *alloc, + ISzAlloc *allocTemp) +{ + uint32_t i; + RINOK(SzWaitAttribute(sd, k7zIdFolder)); + RINOK(SzReadNumber32(sd, numFolders)); + { + RINOK(SzReadSwitch(sd)); + + MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); + + for (i = 0; i < *numFolders; i++) + SzFolder_Init((*folders) + i); + + for (i = 0; i < *numFolders; i++) + { + RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); + } + } + + RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); + + for (i = 0; i < *numFolders; i++) + { + uint32_t j; + CSzFolder *folder = (*folders) + i; + uint32_t numOutStreams = SzFolder_GetNumOutStreams(folder); + + MY_ALLOC(uint64_t, folder->UnpackSizes, (size_t)numOutStreams, alloc); + + for (j = 0; j < numOutStreams; j++) + { + RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); + } + } + + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + return SZ_OK; + if (type == k7zIdCRC) + { + SRes res; + uint8_t *crcsDefined = 0; + uint32_t *crcs = 0; + res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); + if (res == SZ_OK) + { + for (i = 0; i < *numFolders; i++) + { + CSzFolder *folder = (*folders) + i; + folder->UnpackCRCDefined = crcsDefined[i]; + folder->UnpackCRC = crcs[i]; + } + } + IAlloc_Free(allocTemp, crcs); + IAlloc_Free(allocTemp, crcsDefined); + RINOK(res); + continue; + } + RINOK(SzSkeepData(sd)); + } +} + +static SRes SzReadSubStreamsInfo( + CSzData *sd, + uint32_t numFolders, + CSzFolder *folders, + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *allocTemp) +{ + uint64_t type = 0; + uint32_t i; + uint32_t si = 0; + uint32_t numDigests = 0; + + for (i = 0; i < numFolders; i++) + folders[i].NumUnpackStreams = 1; + *numUnpackStreams = numFolders; + + for (;;) + { + RINOK(SzReadID(sd, &type)); + if (type == k7zIdNumUnpackStream) + { + *numUnpackStreams = 0; + for (i = 0; i < numFolders; i++) + { + uint32_t numStreams; + RINOK(SzReadNumber32(sd, &numStreams)); + folders[i].NumUnpackStreams = numStreams; + *numUnpackStreams += numStreams; + } + continue; + } + if (type == k7zIdCRC || type == k7zIdSize) + break; + if (type == k7zIdEnd) + break; + RINOK(SzSkeepData(sd)); + } + + if (*numUnpackStreams == 0) + { + *unpackSizes = 0; + *digestsDefined = 0; + *digests = 0; + } + else + { + *unpackSizes = (uint64_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint64_t)); + RINOM(*unpackSizes); + *digestsDefined = (uint8_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint8_t)); + RINOM(*digestsDefined); + *digests = (uint32_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint32_t)); + RINOM(*digests); + } + + for (i = 0; i < numFolders; i++) + { + /* + v3.13 incorrectly worked with empty folders + v4.07: we check that folder is empty + */ + uint64_t sum = 0; + uint32_t j; + uint32_t numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams == 0) + continue; + if (type == k7zIdSize) + for (j = 1; j < numSubstreams; j++) + { + uint64_t size; + RINOK(SzReadNumber(sd, &size)); + (*unpackSizes)[si++] = size; + sum += size; + } + (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; + } + if (type == k7zIdSize) + { + RINOK(SzReadID(sd, &type)); + } + + for (i = 0; i < *numUnpackStreams; i++) + { + (*digestsDefined)[i] = 0; + (*digests)[i] = 0; + } + + + for (i = 0; i < numFolders; i++) + { + uint32_t numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) + numDigests += numSubstreams; + } + + + si = 0; + for (;;) + { + if (type == k7zIdCRC) + { + int digestIndex = 0; + uint8_t *digestsDefined2 = 0; + uint32_t *digests2 = 0; + SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); + if (res == SZ_OK) + { + for (i = 0; i < numFolders; i++) + { + CSzFolder *folder = folders + i; + uint32_t numSubstreams = folder->NumUnpackStreams; + if (numSubstreams == 1 && folder->UnpackCRCDefined) + { + (*digestsDefined)[si] = 1; + (*digests)[si] = folder->UnpackCRC; + si++; + } + else + { + uint32_t j; + for (j = 0; j < numSubstreams; j++, digestIndex++) + { + (*digestsDefined)[si] = digestsDefined2[digestIndex]; + (*digests)[si] = digests2[digestIndex]; + si++; + } + } + } + } + IAlloc_Free(allocTemp, digestsDefined2); + IAlloc_Free(allocTemp, digests2); + RINOK(res); + } + else if (type == k7zIdEnd) + return SZ_OK; + else + { + RINOK(SzSkeepData(sd)); + } + RINOK(SzReadID(sd, &type)); + } +} + + +static SRes SzReadStreamsInfo( + CSzData *sd, + uint64_t *dataOffset, + CSzAr *p, + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ + ISzAlloc *alloc, + ISzAlloc *allocTemp) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if ((uint64_t)(int)type != type) + return SZ_ERROR_UNSUPPORTED; + switch((int)type) + { + case k7zIdEnd: + return SZ_OK; + case k7zIdPackInfo: + { + RINOK(SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, + &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc)); + break; + } + case k7zIdUnpackInfo: + { + RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); + break; + } + case k7zIdSubStreamsInfo: + { + RINOK(SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, + numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp)); + break; + } + default: + return SZ_ERROR_UNSUPPORTED; + } + } +} + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest) +{ + size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; + if (dest != 0) + { + size_t i; + const uint8_t *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); + for (i = 0; i < len; i++) + dest[i] = GetUi16(src + i * 2); + } + return len; +} + +static SRes SzReadFileNames(const uint8_t *p, size_t size, uint32_t numFiles, size_t *sizes) +{ + uint32_t i; + size_t pos = 0; + for (i = 0; i < numFiles; i++) + { + sizes[i] = pos; + for (;;) + { + if (pos >= size) + return SZ_ERROR_ARCHIVE; + if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) + break; + pos++; + } + pos++; + } + sizes[i] = pos; + return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; +} + +static SRes SzReadHeader2( + CSzArEx *p, /* allocMain */ + CSzData *sd, + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ + uint8_t **emptyStreamVector, /* allocTemp */ + uint8_t **emptyFileVector, /* allocTemp */ + uint8_t **lwtVector, /* allocTemp */ + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint64_t type; + uint32_t numUnpackStreams = 0; + uint32_t numFiles = 0; + CSzFileItem *files = 0; + uint32_t numEmptyStreams = 0; + uint32_t i; + + RINOK(SzReadID(sd, &type)); + + if (type == k7zIdArchiveProperties) + { + RINOK(SzReadArchiveProperties(sd)); + RINOK(SzReadID(sd, &type)); + } + + + if (type == k7zIdMainStreamsInfo) + { + RINOK(SzReadStreamsInfo(sd, + &p->dataPos, + &p->db, + &numUnpackStreams, + unpackSizes, + digestsDefined, + digests, allocMain, allocTemp)); + p->dataPos += p->startPosAfterHeader; + RINOK(SzReadID(sd, &type)); + } + + if (type == k7zIdEnd) + return SZ_OK; + if (type != k7zIdFilesInfo) + return SZ_ERROR_ARCHIVE; + + RINOK(SzReadNumber32(sd, &numFiles)); + p->db.NumFiles = numFiles; + + MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); + + p->db.Files = files; + for (i = 0; i < numFiles; i++) + SzFile_Init(files + i); + + for (;;) + { + uint64_t size; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + RINOK(SzReadNumber(sd, &size)); + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + if ((uint64_t)(int)type != type) + { + RINOK(SzSkeepDataSize(sd, size)); + } + else + switch((int)type) + { + case k7zIdName: + { + size_t namesSize; + RINOK(SzReadSwitch(sd)); + namesSize = (size_t)size - 1; + if ((namesSize & 1) != 0) + return SZ_ERROR_ARCHIVE; + if (!Buf_Create(&p->FileNames, namesSize, allocMain)) + return SZ_ERROR_MEM; + MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); + memcpy(p->FileNames.data, sd->Data, namesSize); + RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets)) + RINOK(SzSkeepDataSize(sd, namesSize)); + break; + } + case k7zIdEmptyStream: + { + RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); + numEmptyStreams = 0; + for (i = 0; i < numFiles; i++) + if ((*emptyStreamVector)[i]) + numEmptyStreams++; + break; + } + case k7zIdEmptyFile: + { + RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp)); + break; + } + case k7zIdWinAttributes: + { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) + { + CSzFileItem *f = &files[i]; + uint8_t defined = (*lwtVector)[i]; + f->AttribDefined = defined; + f->Attrib = 0; + if (defined) + { + RINOK(SzReaduint32_t(sd, &f->Attrib)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + case k7zIdMTime: + { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) + { + CSzFileItem *f = &files[i]; + uint8_t defined = (*lwtVector)[i]; + f->MTimeDefined = defined; + f->MTime.Low = f->MTime.High = 0; + if (defined) + { + RINOK(SzReaduint32_t(sd, &f->MTime.Low)); + RINOK(SzReaduint32_t(sd, &f->MTime.High)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + default: + { + RINOK(SzSkeepDataSize(sd, size)); + } + } + } + + { + uint32_t emptyFileIndex = 0; + uint32_t sizeIndex = 0; + for (i = 0; i < numFiles; i++) + { + CSzFileItem *file = files + i; + file->IsAnti = 0; + if (*emptyStreamVector == 0) + file->HasStream = 1; + else + file->HasStream = (uint8_t)((*emptyStreamVector)[i] ? 0 : 1); + if (file->HasStream) + { + file->IsDir = 0; + file->Size = (*unpackSizes)[sizeIndex]; + file->Crc = (*digests)[sizeIndex]; + file->CrcDefined = (uint8_t)(*digestsDefined)[sizeIndex]; + sizeIndex++; + } + else + { + if (*emptyFileVector == 0) + file->IsDir = 1; + else + file->IsDir = (uint8_t)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); + emptyFileIndex++; + file->Size = 0; + file->Crc = 0; + file->CrcDefined = 0; + } + } + } + return SzArEx_Fill(p, allocMain); +} + +static SRes SzReadHeader( + CSzArEx *p, + CSzData *sd, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; + uint8_t *emptyStreamVector = 0; + uint8_t *emptyFileVector = 0; + uint8_t *lwtVector = 0; + SRes res = SzReadHeader2(p, sd, + &unpackSizes, &digestsDefined, &digests, + &emptyStreamVector, &emptyFileVector, &lwtVector, + allocMain, allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + IAlloc_Free(allocTemp, emptyStreamVector); + IAlloc_Free(allocTemp, emptyFileVector); + IAlloc_Free(allocTemp, lwtVector); + return res; +} + +static SRes SzReadAndDecodePackedStreams2( + ILookInStream *inStream, + CSzData *sd, + CBuf *outBuffer, + uint64_t baseOffset, + CSzAr *p, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *allocTemp) +{ + + uint32_t numUnpackStreams = 0; + uint64_t dataStartPos; + CSzFolder *folder; + uint64_t unpackSize; + SRes res; + + RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, + &numUnpackStreams, unpackSizes, digestsDefined, digests, + allocTemp, allocTemp)); + + dataStartPos += baseOffset; + if (p->NumFolders != 1) + return SZ_ERROR_ARCHIVE; + + folder = p->Folders; + unpackSize = SzFolder_GetUnpackSize(folder); + + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); + + if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) + return SZ_ERROR_MEM; + + res = SzFolder_Decode(folder, p->PackSizes, + inStream, dataStartPos, + outBuffer->data, (size_t)unpackSize, allocTemp); + RINOK(res); + if (folder->UnpackCRCDefined) + if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) + return SZ_ERROR_CRC; + return SZ_OK; +} + +static SRes SzReadAndDecodePackedStreams( + ILookInStream *inStream, + CSzData *sd, + CBuf *outBuffer, + uint64_t baseOffset, + ISzAlloc *allocTemp) +{ + CSzAr p; + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; + SRes res; + SzAr_Init(&p); + res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, + &p, &unpackSizes, &digestsDefined, &digests, + allocTemp); + SzAr_Free(&p, allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + return res; +} + +static SRes SzArEx_Open2( + CSzArEx *p, + ILookInStream *inStream, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint8_t header[k7zStartHeaderSize]; + int64_t startArcPos; + uint64_t nextHeaderOffset, nextHeaderSize; + size_t nextHeaderSizeT; + uint32_t nextHeaderCRC; + CBuf buffer; + SRes res; + + startArcPos = 0; + RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); + + RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); + + if (!TestSignatureCandidate(header)) + return SZ_ERROR_NO_ARCHIVE; + if (header[6] != k7zMajorVersion) + return SZ_ERROR_UNSUPPORTED; + + nextHeaderOffset = GetUi64(header + 12); + nextHeaderSize = GetUi64(header + 20); + nextHeaderCRC = GetUi32(header + 28); + + p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; + + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) + return SZ_ERROR_CRC; + + nextHeaderSizeT = (size_t)nextHeaderSize; + if (nextHeaderSizeT != nextHeaderSize) + return SZ_ERROR_MEM; + if (nextHeaderSizeT == 0) + return SZ_OK; + if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || + nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) + return SZ_ERROR_NO_ARCHIVE; + + { + int64_t pos = 0; + RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); + if ((uint64_t)pos < startArcPos + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + return SZ_ERROR_INPUT_EOF; + } + + RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); + + if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) + return SZ_ERROR_MEM; + + res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); + if (res == SZ_OK) + { + res = SZ_ERROR_ARCHIVE; + if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) + { + CSzData sd; + uint64_t type; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + if (res == SZ_OK) + { + if (type == k7zIdEncodedHeader) + { + CBuf outBuffer; + Buf_Init(&outBuffer); + res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, p->startPosAfterHeader, allocTemp); + if (res != SZ_OK) + Buf_Free(&outBuffer, allocTemp); + else + { + Buf_Free(&buffer, allocTemp); + buffer.data = outBuffer.data; + buffer.size = outBuffer.size; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + } + } + } + if (res == SZ_OK) + { + if (type == k7zIdHeader) + res = SzReadHeader(p, &sd, allocMain, allocTemp); + else + res = SZ_ERROR_UNSUPPORTED; + } + } + } + Buf_Free(&buffer, allocTemp); + return res; +} + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp) +{ + SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); + if (res != SZ_OK) + SzArEx_Free(p, allocMain); + return res; +} + +SRes SzArEx_Extract( + const CSzArEx *p, + ILookInStream *inStream, + uint32_t fileIndex, + uint32_t *blockIndex, + uint8_t **outBuffer, + size_t *outBufferSize, + size_t *offset, + size_t *outSizeProcessed, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint32_t folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; + SRes res = SZ_OK; + *offset = 0; + *outSizeProcessed = 0; + if (folderIndex == (uint32_t)-1) + { + IAlloc_Free(allocMain, *outBuffer); + *blockIndex = folderIndex; + *outBuffer = 0; + *outBufferSize = 0; + return SZ_OK; + } + + if (*outBuffer == 0 || *blockIndex != folderIndex) + { + CSzFolder *folder = p->db.Folders + folderIndex; + uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); + size_t unpackSize = (size_t)unpackSizeSpec; + uint64_t startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); + + if (unpackSize != unpackSizeSpec) + return SZ_ERROR_MEM; + *blockIndex = folderIndex; + IAlloc_Free(allocMain, *outBuffer); + *outBuffer = 0; + + RINOK(LookInStream_SeekTo(inStream, startOffset)); + + if (res == SZ_OK) + { + *outBufferSize = unpackSize; + if (unpackSize != 0) + { + *outBuffer = (uint8_t *)IAlloc_Alloc(allocMain, unpackSize); + if (*outBuffer == 0) + res = SZ_ERROR_MEM; + } + if (res == SZ_OK) + { + res = SzFolder_Decode(folder, + p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], + inStream, startOffset, + *outBuffer, unpackSize, allocTemp); + if (res == SZ_OK) + { + if (folder->UnpackCRCDefined) + { + if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC) + res = SZ_ERROR_CRC; + } + } + } + } + } + if (res == SZ_OK) + { + uint32_t i; + CSzFileItem *fileItem = p->db.Files + fileIndex; + *offset = 0; + for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) + *offset += (uint32_t)p->db.Files[i].Size; + *outSizeProcessed = (size_t)fileItem->Size; + if (*offset + *outSizeProcessed > *outBufferSize) + return SZ_ERROR_FAIL; + if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) + res = SZ_ERROR_CRC; + } + return res; +} diff --git a/deps/7zip/7zStream.c b/deps/7zip/7zStream.c index c205fbe200..1fc86d064c 100644 --- a/deps/7zip/7zStream.c +++ b/deps/7zip/7zStream.c @@ -1,173 +1,173 @@ -/* 7zStream.c -- 7z Stream functions - 2010-03-11 : Igor Pavlov : Public domain */ - -#include -#include -#include - -#include "7zTypes.h" - -SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf); - -SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((uint8_t *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) -{ - return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - -SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) -{ - size_t processed = 1; - RINOK(stream->Read(stream, buf, &processed)); - return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; -} - -SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) -{ - int64_t t = offset; - return stream->Seek(stream, &t, SZ_SEEK_SET); -} - -SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) -{ - const void *lookBuf; - if (*size == 0) - return SZ_OK; - RINOK(stream->Look(stream, &lookBuf, size)); - memcpy(buf, lookBuf, *size); - return stream->Skip(stream, *size); -} - -SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((uint8_t *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) -{ - return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - -static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - size2 = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, &size2); - p->size = size2; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - if (*size > LookToRead_BUF_SIZE) - *size = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, size); - size2 = p->size = *size; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead_Skip(void *pp, size_t offset) -{ - CLookToRead *p = (CLookToRead *)pp; - p->pos += offset; - return SZ_OK; -} - -static SRes LookToRead_Read(void *pp, void *buf, size_t *size) -{ - CLookToRead *p = (CLookToRead *)pp; - size_t rem = p->size - p->pos; - if (rem == 0) - return p->realStream->Read(p->realStream, buf, size); - if (rem > *size) - rem = *size; - memcpy(buf, p->buf + p->pos, rem); - p->pos += rem; - *size = rem; - return SZ_OK; -} - -static SRes LookToRead_Seek(void *pp, int64_t *pos, ESzSeek origin) -{ - CLookToRead *p = (CLookToRead *)pp; - p->pos = p->size = 0; - return p->realStream->Seek(p->realStream, pos, origin); -} - -void LookToRead_CreateVTable(CLookToRead *p, int lookahead) -{ - p->s.Look = lookahead ? - LookToRead_Look_Lookahead : - LookToRead_Look_Exact; - p->s.Skip = LookToRead_Skip; - p->s.Read = LookToRead_Read; - p->s.Seek = LookToRead_Seek; -} - -void LookToRead_Init(CLookToRead *p) -{ - p->pos = p->size = 0; -} - -static SRes SecToLook_Read(void *pp, void *buf, size_t *size) -{ - CSecToLook *p = (CSecToLook *)pp; - return LookInStream_LookRead(p->realStream, buf, size); -} - -void SecToLook_CreateVTable(CSecToLook *p) -{ - p->s.Read = SecToLook_Read; -} - -static SRes SecToRead_Read(void *pp, void *buf, size_t *size) -{ - CSecToRead *p = (CSecToRead *)pp; - return p->realStream->Read(p->realStream, buf, size); -} - -void SecToRead_CreateVTable(CSecToRead *p) -{ - p->s.Read = SecToRead_Read; -} +/* 7zStream.c -- 7z Stream functions + 2010-03-11 : Igor Pavlov : Public domain */ + +#include +#include +#include + +#include "7zTypes.h" + +SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf); + +SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((uint8_t *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) +{ + return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + +SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) +{ + size_t processed = 1; + RINOK(stream->Read(stream, buf, &processed)); + return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; +} + +SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) +{ + int64_t t = offset; + return stream->Seek(stream, &t, SZ_SEEK_SET); +} + +SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) +{ + const void *lookBuf; + if (*size == 0) + return SZ_OK; + RINOK(stream->Look(stream, &lookBuf, size)); + memcpy(buf, lookBuf, *size); + return stream->Skip(stream, *size); +} + +SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((uint8_t *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) +{ + return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + +static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) + { + p->pos = 0; + size2 = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, &size2); + p->size = size2; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) + { + p->pos = 0; + if (*size > LookToRead_BUF_SIZE) + *size = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, size); + size2 = p->size = *size; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead_Skip(void *pp, size_t offset) +{ + CLookToRead *p = (CLookToRead *)pp; + p->pos += offset; + return SZ_OK; +} + +static SRes LookToRead_Read(void *pp, void *buf, size_t *size) +{ + CLookToRead *p = (CLookToRead *)pp; + size_t rem = p->size - p->pos; + if (rem == 0) + return p->realStream->Read(p->realStream, buf, size); + if (rem > *size) + rem = *size; + memcpy(buf, p->buf + p->pos, rem); + p->pos += rem; + *size = rem; + return SZ_OK; +} + +static SRes LookToRead_Seek(void *pp, int64_t *pos, ESzSeek origin) +{ + CLookToRead *p = (CLookToRead *)pp; + p->pos = p->size = 0; + return p->realStream->Seek(p->realStream, pos, origin); +} + +void LookToRead_CreateVTable(CLookToRead *p, int lookahead) +{ + p->s.Look = lookahead ? + LookToRead_Look_Lookahead : + LookToRead_Look_Exact; + p->s.Skip = LookToRead_Skip; + p->s.Read = LookToRead_Read; + p->s.Seek = LookToRead_Seek; +} + +void LookToRead_Init(CLookToRead *p) +{ + p->pos = p->size = 0; +} + +static SRes SecToLook_Read(void *pp, void *buf, size_t *size) +{ + CSecToLook *p = (CSecToLook *)pp; + return LookInStream_LookRead(p->realStream, buf, size); +} + +void SecToLook_CreateVTable(CSecToLook *p) +{ + p->s.Read = SecToLook_Read; +} + +static SRes SecToRead_Read(void *pp, void *buf, size_t *size) +{ + CSecToRead *p = (CSecToRead *)pp; + return p->realStream->Read(p->realStream, buf, size); +} + +void SecToRead_CreateVTable(CSecToRead *p) +{ + p->s.Read = SecToRead_Read; +} diff --git a/deps/7zip/7zVersion.h b/deps/7zip/7zVersion.h index d4ac470e23..9d99c5dff2 100644 --- a/deps/7zip/7zVersion.h +++ b/deps/7zip/7zVersion.h @@ -1,7 +1,7 @@ -#define MY_VER_MAJOR 9 -#define MY_VER_MINOR 20 -#define MY_VER_BUILD 0 -#define MY_VERSION "9.20" -#define MY_DATE "2010-11-18" -#define MY_COPYRIGHT ": Igor Pavlov : Public domain" -#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE +#define MY_VER_MAJOR 9 +#define MY_VER_MINOR 20 +#define MY_VER_BUILD 0 +#define MY_VERSION "9.20" +#define MY_DATE "2010-11-18" +#define MY_COPYRIGHT ": Igor Pavlov : Public domain" +#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE diff --git a/deps/7zip/Bcj2.c b/deps/7zip/Bcj2.c index 7c55cae3d1..13991b7698 100644 --- a/deps/7zip/Bcj2.c +++ b/deps/7zip/Bcj2.c @@ -1,149 +1,149 @@ -/* Bcj2.c -- Converter for x86 code (BCJ2) - 2008-10-04 : Igor Pavlov : Public domain */ - -#include -#include "Bcj2.h" - -#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) -#define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) - -#define kNumTopBits 24 -#define kTopValue ((uint32_t)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_READ_BYTE (*buffer++) - -int Bcj2_Decode( - const uint8_t *buf0, size_t size0, - const uint8_t *buf1, size_t size1, - const uint8_t *buf2, size_t size2, - const uint8_t *buf3, size_t size3, - uint8_t *outBuf, size_t outSize) -{ - uint16_t p[256 + 2]; - size_t inPos = 0, outPos = 0; - - const uint8_t *buffer, *bufferLim; - uint32_t range, codes = 0; - uint8_t prevuint8_t = 0; - - unsigned int i; - for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) - p[i] = kBitModelTotal >> 1; - - buffer = buf3; - bufferLim = buffer + size3; - range = 0xFFFFFFFF; - - for (i = 0; i < 5; i++) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - codes = (codes << 8) | RC_READ_BYTE; - } - - if (outSize == 0) - return SZ_OK; - - for (;;) - { - uint8_t b; - uint16_t *prob; - uint32_t bound; - uint32_t ttt; - - size_t limit = size0 - inPos; - if (outSize - outPos < limit) - limit = outSize - outPos; - while (limit != 0) - { - b = buf0[inPos]; - outBuf[outPos++] = b; - if (IsJ(prevuint8_t, b)) - break; - inPos++; - prevuint8_t = b; - limit--; - } - - if (limit == 0 || outPos == outSize) - break; - - b = buf0[inPos++]; - - if (b == 0xE8) - prob = p + prevuint8_t; - else if (b == 0xE9) - prob = p + 256; - else - prob = p + 257; - - ttt = *(prob); - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - range = bound; - *(prob) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); - - if (range < kTopValue) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - range <<= 8; - codes = (codes << 8) | RC_READ_BYTE; - } - prevuint8_t = b; - } - else - { - uint32_t dest; - const uint8_t *v; - - range -= bound; - codes -= bound; - *(prob) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); - - if (range < kTopValue) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - range <<= 8; - codes = (codes << 8) | RC_READ_BYTE; - } - - if (b == 0xE8) - { - v = buf1; - if (size1 < 4) - return SZ_ERROR_DATA; - buf1 += 4; - size1 -= 4; - } - else - { - v = buf2; - if (size2 < 4) - return SZ_ERROR_DATA; - buf2 += 4; - size2 -= 4; - } - dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | - ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)outPos + 4); - outBuf[outPos++] = (uint8_t)dest; - if (outPos == outSize) - break; - outBuf[outPos++] = (uint8_t)(dest >> 8); - if (outPos == outSize) - break; - outBuf[outPos++] = (uint8_t)(dest >> 16); - if (outPos == outSize) - break; - outBuf[outPos++] = prevuint8_t = (uint8_t)(dest >> 24); - } - } - return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; -} +/* Bcj2.c -- Converter for x86 code (BCJ2) + 2008-10-04 : Igor Pavlov : Public domain */ + +#include +#include "Bcj2.h" + +#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) +#define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) + +#define kNumTopBits 24 +#define kTopValue ((uint32_t)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_READ_BYTE (*buffer++) + +int Bcj2_Decode( + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize) +{ + uint16_t p[256 + 2]; + size_t inPos = 0, outPos = 0; + + const uint8_t *buffer, *bufferLim; + uint32_t range, codes = 0; + uint8_t prevuint8_t = 0; + + unsigned int i; + for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) + p[i] = kBitModelTotal >> 1; + + buffer = buf3; + bufferLim = buffer + size3; + range = 0xFFFFFFFF; + + for (i = 0; i < 5; i++) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + codes = (codes << 8) | RC_READ_BYTE; + } + + if (outSize == 0) + return SZ_OK; + + for (;;) + { + uint8_t b; + uint16_t *prob; + uint32_t bound; + uint32_t ttt; + + size_t limit = size0 - inPos; + if (outSize - outPos < limit) + limit = outSize - outPos; + while (limit != 0) + { + b = buf0[inPos]; + outBuf[outPos++] = b; + if (IsJ(prevuint8_t, b)) + break; + inPos++; + prevuint8_t = b; + limit--; + } + + if (limit == 0 || outPos == outSize) + break; + + b = buf0[inPos++]; + + if (b == 0xE8) + prob = p + prevuint8_t; + else if (b == 0xE9) + prob = p + 256; + else + prob = p + 257; + + ttt = *(prob); + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + range = bound; + *(prob) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); + + if (range < kTopValue) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + range <<= 8; + codes = (codes << 8) | RC_READ_BYTE; + } + prevuint8_t = b; + } + else + { + uint32_t dest; + const uint8_t *v; + + range -= bound; + codes -= bound; + *(prob) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); + + if (range < kTopValue) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + range <<= 8; + codes = (codes << 8) | RC_READ_BYTE; + } + + if (b == 0xE8) + { + v = buf1; + if (size1 < 4) + return SZ_ERROR_DATA; + buf1 += 4; + size1 -= 4; + } + else + { + v = buf2; + if (size2 < 4) + return SZ_ERROR_DATA; + buf2 += 4; + size2 -= 4; + } + dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | + ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)outPos + 4); + outBuf[outPos++] = (uint8_t)dest; + if (outPos == outSize) + break; + outBuf[outPos++] = (uint8_t)(dest >> 8); + if (outPos == outSize) + break; + outBuf[outPos++] = (uint8_t)(dest >> 16); + if (outPos == outSize) + break; + outBuf[outPos++] = prevuint8_t = (uint8_t)(dest >> 24); + } + } + return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; +} diff --git a/deps/7zip/Bcj2.h b/deps/7zip/Bcj2.h index a7651499f7..edca41e0a9 100644 --- a/deps/7zip/Bcj2.h +++ b/deps/7zip/Bcj2.h @@ -1,38 +1,38 @@ -/* Bcj2.h -- Converter for x86 code (BCJ2) -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __BCJ2_H -#define __BCJ2_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* -Conditions: - outSize <= FullOutputSize, - where FullOutputSize is full size of output stream of x86_2 filter. - -If buf0 overlaps outBuf, there are two required conditions: - 1) (buf0 >= outBuf) - 2) (buf0 + size0 >= outBuf + FullOutputSize). - -Returns: - SZ_OK - SZ_ERROR_DATA - Data error -*/ - -int Bcj2_Decode( - const uint8_t *buf0, size_t size0, - const uint8_t *buf1, size_t size1, - const uint8_t *buf2, size_t size2, - const uint8_t *buf3, size_t size3, - uint8_t *outBuf, size_t outSize); - -#ifdef __cplusplus -} -#endif - -#endif +/* Bcj2.h -- Converter for x86 code (BCJ2) +2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __BCJ2_H +#define __BCJ2_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +Conditions: + outSize <= FullOutputSize, + where FullOutputSize is full size of output stream of x86_2 filter. + +If buf0 overlaps outBuf, there are two required conditions: + 1) (buf0 >= outBuf) + 2) (buf0 + size0 >= outBuf + FullOutputSize). + +Returns: + SZ_OK + SZ_ERROR_DATA - Data error +*/ + +int Bcj2_Decode( + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/Bra.c b/deps/7zip/Bra.c index 40a0e5f9ed..49df0831b3 100644 --- a/deps/7zip/Bra.c +++ b/deps/7zip/Bra.c @@ -1,134 +1,134 @@ -/* Bra.c -- Converters for RISC code - 2010-04-16 : Igor Pavlov : Public domain */ - -#include -#include "Bra.h" - -size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - ip += 8; - for (i = 0; i <= size; i += 4) - { - if (data[i + 3] == 0xEB) - { - uint32_t dest; - uint32_t src = ((uint32_t)data[i + 2] << 16) | ((uint32_t)data[i + 1] << 8) | (data[i + 0]); - src <<= 2; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - dest >>= 2; - data[i + 2] = (uint8_t)(dest >> 16); - data[i + 1] = (uint8_t)(dest >> 8); - data[i + 0] = (uint8_t)dest; - } - } - return i; -} - -size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - ip += 4; - for (i = 0; i <= size; i += 2) - { - if ((data[i + 1] & 0xF8) == 0xF0 && - (data[i + 3] & 0xF8) == 0xF8) - { - uint32_t dest; - uint32_t src = - (((uint32_t)data[i + 1] & 0x7) << 19) | - ((uint32_t)data[i + 0] << 11) | - (((uint32_t)data[i + 3] & 0x7) << 8) | - (data[i + 2]); - - src <<= 1; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - dest >>= 1; - - data[i + 1] = (uint8_t)(0xF0 | ((dest >> 19) & 0x7)); - data[i + 0] = (uint8_t)(dest >> 11); - data[i + 3] = (uint8_t)(0xF8 | ((dest >> 8) & 0x7)); - data[i + 2] = (uint8_t)dest; - i += 2; - } - } - return i; -} - -size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) - { - uint32_t src = ((uint32_t)(data[i + 0] & 3) << 24) | - ((uint32_t)data[i + 1] << 16) | - ((uint32_t)data[i + 2] << 8) | - ((uint32_t)data[i + 3] & (~3)); - - uint32_t dest; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - data[i + 0] = (uint8_t)(0x48 | ((dest >> 24) & 0x3)); - data[i + 1] = (uint8_t)(dest >> 16); - data[i + 2] = (uint8_t)(dest >> 8); - data[i + 3] &= 0x3; - data[i + 3] |= dest; - } - } - return i; -} - -size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - uint32_t i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || - (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) - { - uint32_t src = - ((uint32_t)data[i + 0] << 24) | - ((uint32_t)data[i + 1] << 16) | - ((uint32_t)data[i + 2] << 8) | - ((uint32_t)data[i + 3]); - uint32_t dest; - - src <<= 2; - if (encoding) - dest = ip + i + src; - else - dest = src - (ip + i); - dest >>= 2; - - dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; - - data[i + 0] = (uint8_t)(dest >> 24); - data[i + 1] = (uint8_t)(dest >> 16); - data[i + 2] = (uint8_t)(dest >> 8); - data[i + 3] = (uint8_t)dest; - } - } - return i; -} +/* Bra.c -- Converters for RISC code + 2010-04-16 : Igor Pavlov : Public domain */ + +#include +#include "Bra.h" + +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + ip += 8; + for (i = 0; i <= size; i += 4) + { + if (data[i + 3] == 0xEB) + { + uint32_t dest; + uint32_t src = ((uint32_t)data[i + 2] << 16) | ((uint32_t)data[i + 1] << 8) | (data[i + 0]); + src <<= 2; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + dest >>= 2; + data[i + 2] = (uint8_t)(dest >> 16); + data[i + 1] = (uint8_t)(dest >> 8); + data[i + 0] = (uint8_t)dest; + } + } + return i; +} + +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + ip += 4; + for (i = 0; i <= size; i += 2) + { + if ((data[i + 1] & 0xF8) == 0xF0 && + (data[i + 3] & 0xF8) == 0xF8) + { + uint32_t dest; + uint32_t src = + (((uint32_t)data[i + 1] & 0x7) << 19) | + ((uint32_t)data[i + 0] << 11) | + (((uint32_t)data[i + 3] & 0x7) << 8) | + (data[i + 2]); + + src <<= 1; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + dest >>= 1; + + data[i + 1] = (uint8_t)(0xF0 | ((dest >> 19) & 0x7)); + data[i + 0] = (uint8_t)(dest >> 11); + data[i + 3] = (uint8_t)(0xF8 | ((dest >> 8) & 0x7)); + data[i + 2] = (uint8_t)dest; + i += 2; + } + } + return i; +} + +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) + { + if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) + { + uint32_t src = ((uint32_t)(data[i + 0] & 3) << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3] & (~3)); + + uint32_t dest; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + data[i + 0] = (uint8_t)(0x48 | ((dest >> 24) & 0x3)); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); + data[i + 3] &= 0x3; + data[i + 3] |= dest; + } + } + return i; +} + +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + uint32_t i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) + { + if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || + (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) + { + uint32_t src = + ((uint32_t)data[i + 0] << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3]); + uint32_t dest; + + src <<= 2; + if (encoding) + dest = ip + i + src; + else + dest = src - (ip + i); + dest >>= 2; + + dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; + + data[i + 0] = (uint8_t)(dest >> 24); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); + data[i + 3] = (uint8_t)dest; + } + } + return i; +} diff --git a/deps/7zip/Bra.h b/deps/7zip/Bra.h index 3e9d9d9a30..52fa0b30b1 100644 --- a/deps/7zip/Bra.h +++ b/deps/7zip/Bra.h @@ -1,68 +1,68 @@ -/* Bra.h -- Branch converters for executables - 2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __BRA_H -#define __BRA_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - - /* - These functions convert relative addresses to absolute addresses - in CALL instructions to increase the compression ratio. - -In: -data - data buffer -size - size of data -ip - current virtual Instruction Pinter (IP) value -state - state variable for x86 converter -encoding - 0 (for decoding), 1 (for encoding) - -Out: -state - state variable for x86 converter - -Returns: -The number of processed bytes. If you call these functions with multiple calls, -you must start next call with first byte after block of processed bytes. - -Type Endian Alignment LookAhead - -x86 little 1 4 -ARMT little 2 2 -ARM little 4 0 -PPC big 4 0 -SPARC big 4 0 -IA64 little 16 0 - -size must be >= Alignment + LookAhead, if it's not last block. -If (size < Alignment + LookAhead), converter returns 0. - -Example: - -uint32_t ip = 0; -for () -{ -; size must be >= Alignment + LookAhead, if it's not last block -size_t processed = Convert(data, size, ip, 1); -data += processed; -size -= processed; -ip += processed; -} -*/ - -#define x86_Convert_Init(state) { state = 0; } -size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding); -size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t IA64_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); - -#ifdef __cplusplus -} -#endif - -#endif +/* Bra.h -- Branch converters for executables + 2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __BRA_H +#define __BRA_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* + These functions convert relative addresses to absolute addresses + in CALL instructions to increase the compression ratio. + +In: +data - data buffer +size - size of data +ip - current virtual Instruction Pinter (IP) value +state - state variable for x86 converter +encoding - 0 (for decoding), 1 (for encoding) + +Out: +state - state variable for x86 converter + +Returns: +The number of processed bytes. If you call these functions with multiple calls, +you must start next call with first byte after block of processed bytes. + +Type Endian Alignment LookAhead + +x86 little 1 4 +ARMT little 2 2 +ARM little 4 0 +PPC big 4 0 +SPARC big 4 0 +IA64 little 16 0 + +size must be >= Alignment + LookAhead, if it's not last block. +If (size < Alignment + LookAhead), converter returns 0. + +Example: + +uint32_t ip = 0; +for () +{ +; size must be >= Alignment + LookAhead, if it's not last block +size_t processed = Convert(data, size, ip, 1); +data += processed; +size -= processed; +ip += processed; +} +*/ + +#define x86_Convert_Init(state) { state = 0; } +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding); +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t IA64_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/Bra86.c b/deps/7zip/Bra86.c index 6cb7bb17f5..d404527199 100644 --- a/deps/7zip/Bra86.c +++ b/deps/7zip/Bra86.c @@ -1,86 +1,86 @@ -/* Bra86.c -- Converter for x86 code (BCJ) - 2008-10-04 : Igor Pavlov : Public domain */ - -#include -#include "Bra.h" - -#define Test86MSuint8_t(b) ((b) == 0 || (b) == 0xFF) - -const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; -const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; - -size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding) -{ - size_t bufferPos = 0, prevPosT; - uint32_t prevMask = *state & 0x7; - if (size < 5) - return 0; - ip += 5; - prevPosT = (size_t)0 - 1; - - for (;;) - { - uint8_t *p = data + bufferPos; - uint8_t *limit = data + size - 4; - for (; p < limit; p++) - if ((*p & 0xFE) == 0xE8) - break; - bufferPos = (size_t)(p - data); - if (p >= limit) - break; - prevPosT = bufferPos - prevPosT; - if (prevPosT > 3) - prevMask = 0; - else - { - prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; - if (prevMask != 0) - { - uint8_t b = p[4 - kMaskToBitNumber[prevMask]]; - if (!kMaskToAllowedStatus[prevMask] || Test86MSuint8_t(b)) - { - prevPosT = bufferPos; - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - continue; - } - } - } - prevPosT = bufferPos; - - if (Test86MSuint8_t(p[4])) - { - uint32_t src = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); - uint32_t dest; - for (;;) - { - uint8_t b; - int idx; - if (encoding) - dest = (ip + (uint32_t)bufferPos) + src; - else - dest = src - (ip + (uint32_t)bufferPos); - if (prevMask == 0) - break; - idx = kMaskToBitNumber[prevMask] * 8; - b = (uint8_t)(dest >> (24 - idx)); - if (!Test86MSuint8_t(b)) - break; - src = dest ^ ((1 << (32 - idx)) - 1); - } - p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1)); - p[3] = (uint8_t)(dest >> 16); - p[2] = (uint8_t)(dest >> 8); - p[1] = (uint8_t)dest; - bufferPos += 5; - } - else - { - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - } - } - prevPosT = bufferPos - prevPosT; - *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); - return bufferPos; -} +/* Bra86.c -- Converter for x86 code (BCJ) + 2008-10-04 : Igor Pavlov : Public domain */ + +#include +#include "Bra.h" + +#define Test86MSuint8_t(b) ((b) == 0 || (b) == 0xFF) + +const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; +const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; + +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding) +{ + size_t bufferPos = 0, prevPosT; + uint32_t prevMask = *state & 0x7; + if (size < 5) + return 0; + ip += 5; + prevPosT = (size_t)0 - 1; + + for (;;) + { + uint8_t *p = data + bufferPos; + uint8_t *limit = data + size - 4; + for (; p < limit; p++) + if ((*p & 0xFE) == 0xE8) + break; + bufferPos = (size_t)(p - data); + if (p >= limit) + break; + prevPosT = bufferPos - prevPosT; + if (prevPosT > 3) + prevMask = 0; + else + { + prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; + if (prevMask != 0) + { + uint8_t b = p[4 - kMaskToBitNumber[prevMask]]; + if (!kMaskToAllowedStatus[prevMask] || Test86MSuint8_t(b)) + { + prevPosT = bufferPos; + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + continue; + } + } + } + prevPosT = bufferPos; + + if (Test86MSuint8_t(p[4])) + { + uint32_t src = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); + uint32_t dest; + for (;;) + { + uint8_t b; + int idx; + if (encoding) + dest = (ip + (uint32_t)bufferPos) + src; + else + dest = src - (ip + (uint32_t)bufferPos); + if (prevMask == 0) + break; + idx = kMaskToBitNumber[prevMask] * 8; + b = (uint8_t)(dest >> (24 - idx)); + if (!Test86MSuint8_t(b)) + break; + src = dest ^ ((1 << (32 - idx)) - 1); + } + p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1)); + p[3] = (uint8_t)(dest >> 16); + p[2] = (uint8_t)(dest >> 8); + p[1] = (uint8_t)dest; + bufferPos += 5; + } + else + { + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + } + } + prevPosT = bufferPos - prevPosT; + *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); + return bufferPos; +} diff --git a/deps/7zip/CpuArch.h b/deps/7zip/CpuArch.h index 700945f617..b223f1a7cb 100644 --- a/deps/7zip/CpuArch.h +++ b/deps/7zip/CpuArch.h @@ -1,71 +1,71 @@ -/* CpuArch.h -- CPU specific code -2010-10-26: Igor Pavlov : Public domain */ - -#ifndef __CPU_ARCH_H -#define __CPU_ARCH_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* -MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. -If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. -*/ - -#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) -#define MY_CPU_AMD64 -#endif - -#if defined(MY_CPU_AMD64) || defined(_M_IA64) -#define MY_CPU_64BIT -#endif - -#if defined(_M_IX86) || defined(__i386__) -#define MY_CPU_X86 -#endif - -#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) -#define MY_CPU_X86_OR_AMD64 -#endif - -#if defined(MY_CPU_X86) || defined(_M_ARM) -#define MY_CPU_32BIT -#endif - -#if defined(_WIN32) && defined(_M_ARM) -#define MY_CPU_ARM_LE -#endif - -#if defined(_WIN32) && defined(_M_IA64) -#define MY_CPU_IA64_LE -#endif - -#if defined(MY_CPU_X86_OR_AMD64) -#define MY_CPU_LE_UNALIGN -#endif - -#ifdef MY_CPU_LE_UNALIGN - -#define GetUi16(p) (*(const uint16_t *)(p)) -#define GetUi32(p) (*(const uint32_t *)(p)) -#define GetUi64(p) (*(const uint64_t *)(p)) -#else -#define GetUi16(p) (((const uint8_t *)(p))[0] | ((uint16_t)((const uint8_t *)(p))[1] << 8)) - -#define GetUi32(p) ( \ - ((const uint8_t *)(p))[0] | \ - ((uint32_t)((const uint8_t *)(p))[1] << 8) | \ - ((uint32_t)((const uint8_t *)(p))[2] << 16) | \ - ((uint32_t)((const uint8_t *)(p))[3] << 24)) - -#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const uint8_t *)(p)) + 4) << 32)) -#endif - -#ifdef __cplusplus -} -#endif - -#endif +/* CpuArch.h -- CPU specific code +2010-10-26: Igor Pavlov : Public domain */ + +#ifndef __CPU_ARCH_H +#define __CPU_ARCH_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. +If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. +*/ + +#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) +#define MY_CPU_AMD64 +#endif + +#if defined(MY_CPU_AMD64) || defined(_M_IA64) +#define MY_CPU_64BIT +#endif + +#if defined(_M_IX86) || defined(__i386__) +#define MY_CPU_X86 +#endif + +#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) +#define MY_CPU_X86_OR_AMD64 +#endif + +#if defined(MY_CPU_X86) || defined(_M_ARM) +#define MY_CPU_32BIT +#endif + +#if defined(_WIN32) && defined(_M_ARM) +#define MY_CPU_ARM_LE +#endif + +#if defined(_WIN32) && defined(_M_IA64) +#define MY_CPU_IA64_LE +#endif + +#if defined(MY_CPU_X86_OR_AMD64) +#define MY_CPU_LE_UNALIGN +#endif + +#ifdef MY_CPU_LE_UNALIGN + +#define GetUi16(p) (*(const uint16_t *)(p)) +#define GetUi32(p) (*(const uint32_t *)(p)) +#define GetUi64(p) (*(const uint64_t *)(p)) +#else +#define GetUi16(p) (((const uint8_t *)(p))[0] | ((uint16_t)((const uint8_t *)(p))[1] << 8)) + +#define GetUi32(p) ( \ + ((const uint8_t *)(p))[0] | \ + ((uint32_t)((const uint8_t *)(p))[1] << 8) | \ + ((uint32_t)((const uint8_t *)(p))[2] << 16) | \ + ((uint32_t)((const uint8_t *)(p))[3] << 24)) + +#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const uint8_t *)(p)) + 4) << 32)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzFind.c b/deps/7zip/LzFind.c index e41014e65f..0ad8c2c733 100644 --- a/deps/7zip/LzFind.c +++ b/deps/7zip/LzFind.c @@ -73,7 +73,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) p->streamEndWasReached = 1; return; } - + for (;;) { unsigned char *dest = p->buffer + (p->streamPos - p->pos); @@ -179,24 +179,24 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, ISzAlloc *alloc) { uint32_t sizeReserv; - + if (historySize > LzFindkMaxHistorySize) { MatchFinder_Free(p, alloc); return 0; } - + sizeReserv = historySize >> 1; if (historySize >= ((uint32_t)3 << 30)) sizeReserv = historySize >> 3; else if (historySize >= ((uint32_t)2 << 30)) sizeReserv = historySize >> 2; - + sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); p->keepSizeBefore = historySize + keepAddBufferBefore + 1; p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; - + /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ - + if (LzInWindow_Create(p, sizeReserv, alloc)) { uint32_t newCyclicBufferSize = historySize + 1; @@ -238,7 +238,7 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, p->historySize = historySize; p->hashSizeSum = hs; p->cyclicBufferSize = newCyclicBufferSize; - + numSons = newCyclicBufferSize; if (p->btMode) numSons <<= 1; @@ -246,11 +246,11 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, if (p->hash && p->numRefs == newSize) return 1; - + MatchFinder_FreeThisClassMemory(p, alloc); p->numRefs = newSize; p->hash = AllocRefs(newSize, alloc); - + if (p->hash) { p->son = p->hash + p->hashSizeSum; @@ -267,11 +267,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p) { uint32_t limit = kMaxValForNormalize - p->pos; uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos; - + if (limit2 < limit) limit = limit2; limit2 = p->streamPos - p->pos; - + if (limit2 <= p->keepSizeAfter) { if (limit2 > 0) @@ -279,10 +279,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p) } else limit2 -= p->keepSizeAfter; - + if (limit2 < limit) limit = limit2; - + { uint32_t lenLimit = p->streamPos - p->pos; if (lenLimit > p->matchMaxLen) @@ -299,16 +299,16 @@ void MatchFinder_Init_2(CMatchFinder *p, int readData) uint32_t num = p->hashSizeSum; for (i = 0; i < num; i++) hash[i] = kEmptyHashValue; - + p->cyclicBufferPos = 0; p->buffer = p->bufferBase; p->pos = p->streamPos = p->cyclicBufferSize; p->result = SZ_OK; p->streamEndWasReached = 0; - + if (readData) MatchFinder_ReadBlock(p); - + MatchFinder_SetLimits(p); } @@ -316,7 +316,7 @@ void MatchFinder_Init(CMatchFinder *p) { MatchFinder_Init_2(p, true); } - + static uint32_t MatchFinder_GetSubValue(CMatchFinder *p) { return (p->pos - p->historySize - 1) & kNormalizeMask; @@ -559,7 +559,7 @@ static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) d2 = pos - hash[h2]; curMatch = hash[kFix3HashSize + hv]; - + hash[h2] = pos; hash[kFix3HashSize + hv] = pos; @@ -578,7 +578,7 @@ static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -604,14 +604,14 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) maxLen = 0; offset = 0; - + if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) { distances[0] = maxLen = 2; distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -619,7 +619,7 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -630,10 +630,10 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -647,10 +647,10 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) hash = p->hash; pos = p->pos; - + d2 = pos - hash[ h2]; d3 = pos - hash[kFix3HashSize + h3]; - + curMatch = hash[kFix4HashSize + hv]; hash[ h2] = pos; @@ -666,7 +666,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -674,7 +674,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -685,7 +685,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; diff --git a/deps/7zip/LzFind.h b/deps/7zip/LzFind.h index a7fc117536..063eceb5e4 100644 --- a/deps/7zip/LzFind.h +++ b/deps/7zip/LzFind.h @@ -34,7 +34,7 @@ typedef struct _CMatchFinder unsigned char *bufferBase; ISeqInStream *stream; - + uint32_t blockSize; uint32_t keepSizeBefore; uint32_t keepSizeAfter; @@ -57,7 +57,7 @@ typedef struct _CMatchFinder ((p)->streamEndWasReached \ && (p)->streamPos == (p)->pos \ && (!(p)->directInput || (p)->directInputRem == 0)) - + int MatchFinder_NeedMove(CMatchFinder *p); unsigned char *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); void MatchFinder_MoveBlock(CMatchFinder *p); diff --git a/deps/7zip/Lzma2Dec.c b/deps/7zip/Lzma2Dec.c index a99b1f91b3..5b8a61c7d5 100644 --- a/deps/7zip/Lzma2Dec.c +++ b/deps/7zip/Lzma2Dec.c @@ -1,347 +1,347 @@ -/* Lzma2Dec.c -- LZMA2 Decoder - 2009-05-03 : Igor Pavlov : Public domain */ - -#include -#include - -#include "Lzma2Dec.h" - -/* - 00000000 - EOS - 00000001 U U - Uncompressed Reset Dic - 00000010 U U - Uncompressed No Reset - 100uuuuu U U P P - LZMA no reset - 101uuuuu U U P P - LZMA reset state - 110uuuuu U U P P S - LZMA reset state + new prop - 111uuuuu U U P P S - LZMA reset state + new prop + reset dic - - u, U - Unpack Size - P - Pack Size - S - Props - */ - -#define LZMA2_CONTROL_LZMA (1 << 7) -#define LZMA2_CONTROL_COPY_NO_RESET 2 -#define LZMA2_CONTROL_COPY_RESET_DIC 1 -#define LZMA2_CONTROL_EOF 0 - -#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0) - -#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3) -#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) - -#define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) - -#define PRF(x) - -typedef enum -{ - LZMA2_STATE_CONTROL, - LZMA2_STATE_UNPACK0, - LZMA2_STATE_UNPACK1, - LZMA2_STATE_PACK0, - LZMA2_STATE_PACK1, - LZMA2_STATE_PROP, - LZMA2_STATE_DATA, - LZMA2_STATE_DATA_CONT, - LZMA2_STATE_FINISHED, - LZMA2_STATE_ERROR -} ELzma2State; - -static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) -{ - uint32_t dicSize; - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); - props[0] = (uint8_t)LZMA2_LCLP_MAX; - props[1] = (uint8_t)(dicSize); - props[2] = (uint8_t)(dicSize >> 8); - props[3] = (uint8_t)(dicSize >> 16); - props[4] = (uint8_t)(dicSize >> 24); - return SZ_OK; -} - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) -{ - uint8_t props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) -{ - uint8_t props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -void Lzma2Dec_Init(CLzma2Dec *p) -{ - p->state = LZMA2_STATE_CONTROL; - p->needInitDic = true; - p->needInitState = true; - p->needInitProp = true; - LzmaDec_Init(&p->decoder); -} - -static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, uint8_t b) -{ - switch(p->state) - { - case LZMA2_STATE_CONTROL: - p->control = b; - PRF(printf("\n %4X ", p->decoder.dicPos)); - PRF(printf(" %2X", b)); - if (p->control == 0) - return LZMA2_STATE_FINISHED; - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if ((p->control & 0x7F) > 2) - return LZMA2_STATE_ERROR; - p->unpackSize = 0; - } - else - p->unpackSize = (uint32_t)(p->control & 0x1F) << 16; - return LZMA2_STATE_UNPACK0; - - case LZMA2_STATE_UNPACK0: - p->unpackSize |= (uint32_t)b << 8; - return LZMA2_STATE_UNPACK1; - - case LZMA2_STATE_UNPACK1: - p->unpackSize |= (uint32_t)b; - p->unpackSize++; - PRF(printf(" %8d", p->unpackSize)); - return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - - case LZMA2_STATE_PACK0: - p->packSize = (uint32_t)b << 8; - return LZMA2_STATE_PACK1; - - case LZMA2_STATE_PACK1: - p->packSize |= (uint32_t)b; - p->packSize++; - PRF(printf(" %8d", p->packSize)); - return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: - (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); - - case LZMA2_STATE_PROP: - { - int lc, lp; - if (b >= (9 * 5 * 5)) - return LZMA2_STATE_ERROR; - lc = b % 9; - b /= 9; - p->decoder.prop.pb = b / 5; - lp = b % 5; - if (lc + lp > LZMA2_LCLP_MAX) - return LZMA2_STATE_ERROR; - p->decoder.prop.lc = lc; - p->decoder.prop.lp = lp; - p->needInitProp = false; - return LZMA2_STATE_DATA; - } - } - return LZMA2_STATE_ERROR; -} - -static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const uint8_t *src, size_t size) -{ - memcpy(p->dic + p->dicPos, src, size); - p->dicPos += size; - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) - p->checkDicSize = p->prop.dicSize; - p->processedPos += (uint32_t)size; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t inSize = *srcLen; - *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->state != LZMA2_STATE_FINISHED) - { - size_t dicPos = p->decoder.dicPos; - if (p->state == LZMA2_STATE_ERROR) - return SZ_ERROR_DATA; - if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - (*srcLen)++; - p->state = Lzma2Dec_UpdateState(p, *src++); - continue; - } - { - size_t destSizeCur = dicLimit - dicPos; - size_t srcSizeCur = inSize - *srcLen; - ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - - if (p->unpackSize <= destSizeCur) - { - destSizeCur = (size_t)p->unpackSize; - curFinishMode = LZMA_FINISH_END; - } - - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - if (p->state == LZMA2_STATE_DATA) - { - bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); - if (initDic) - p->needInitProp = p->needInitState = true; - else if (p->needInitDic) - return SZ_ERROR_DATA; - p->needInitDic = false; - LzmaDec_InitDicAndState(&p->decoder, initDic, false); - } - - if (srcSizeCur > destSizeCur) - srcSizeCur = destSizeCur; - - if (srcSizeCur == 0) - return SZ_ERROR_DATA; - - LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->unpackSize -= (uint32_t)srcSizeCur; - p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; - } - else - { - size_t outSizeProcessed; - SRes res; - - if (p->state == LZMA2_STATE_DATA) - { - int mode = LZMA2_GET_LZMA_MODE(p); - bool initDic = (mode == 3); - bool initState = (mode > 0); - if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) - return SZ_ERROR_DATA; - - LzmaDec_InitDicAndState(&p->decoder, initDic, initState); - p->needInitDic = false; - p->needInitState = false; - p->state = LZMA2_STATE_DATA_CONT; - } - if (srcSizeCur > p->packSize) - srcSizeCur = (size_t)p->packSize; - - res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->packSize -= (uint32_t)srcSizeCur; - - outSizeProcessed = p->decoder.dicPos - dicPos; - p->unpackSize -= (uint32_t)outSizeProcessed; - - RINOK(res); - if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) - return res; - - if (srcSizeCur == 0 && outSizeProcessed == 0) - { - if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || - p->unpackSize != 0 || p->packSize != 0) - return SZ_ERROR_DATA; - p->state = LZMA2_STATE_CONTROL; - } - if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) - *status = LZMA_STATUS_NOT_FINISHED; - } - } - } - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; -} - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t outSize = *destLen, inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - size_t srcSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->decoder.dicPos == p->decoder.dicBufSize) - p->decoder.dicPos = 0; - dicPos = p->decoder.dicPos; - if (outSize > p->decoder.dicBufSize - dicPos) - { - outSizeCur = p->decoder.dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); - src += srcSizeCur; - inSize -= srcSizeCur; - *srcLen += srcSizeCur; - outSizeCur = p->decoder.dicPos - dicPos; - memcpy(dest, p->decoder.dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzma2Dec decoder; - SRes res; - size_t outSize = *destLen, inSize = *srcLen; - uint8_t props[LZMA_PROPS_SIZE]; - - Lzma2Dec_Construct(&decoder); - - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - decoder.decoder.dic = dest; - decoder.decoder.dicBufSize = outSize; - - RINOK(Lzma2Dec_GetOldProps(prop, props)); - RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); - - *srcLen = inSize; - res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); - *destLen = decoder.decoder.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - LzmaDec_FreeProbs(&decoder.decoder, alloc); - return res; -} +/* Lzma2Dec.c -- LZMA2 Decoder + 2009-05-03 : Igor Pavlov : Public domain */ + +#include +#include + +#include "Lzma2Dec.h" + +/* + 00000000 - EOS + 00000001 U U - Uncompressed Reset Dic + 00000010 U U - Uncompressed No Reset + 100uuuuu U U P P - LZMA no reset + 101uuuuu U U P P - LZMA reset state + 110uuuuu U U P P S - LZMA reset state + new prop + 111uuuuu U U P P S - LZMA reset state + new prop + reset dic + + u, U - Unpack Size + P - Pack Size + S - Props + */ + +#define LZMA2_CONTROL_LZMA (1 << 7) +#define LZMA2_CONTROL_COPY_NO_RESET 2 +#define LZMA2_CONTROL_COPY_RESET_DIC 1 +#define LZMA2_CONTROL_EOF 0 + +#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0) + +#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3) +#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) + +#define LZMA2_LCLP_MAX 4 +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) + +#define PRF(x) + +typedef enum +{ + LZMA2_STATE_CONTROL, + LZMA2_STATE_UNPACK0, + LZMA2_STATE_UNPACK1, + LZMA2_STATE_PACK0, + LZMA2_STATE_PACK1, + LZMA2_STATE_PROP, + LZMA2_STATE_DATA, + LZMA2_STATE_DATA_CONT, + LZMA2_STATE_FINISHED, + LZMA2_STATE_ERROR +} ELzma2State; + +static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) +{ + uint32_t dicSize; + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); + props[0] = (uint8_t)LZMA2_LCLP_MAX; + props[1] = (uint8_t)(dicSize); + props[2] = (uint8_t)(dicSize >> 8); + props[3] = (uint8_t)(dicSize >> 16); + props[4] = (uint8_t)(dicSize >> 24); + return SZ_OK; +} + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) +{ + uint8_t props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) +{ + uint8_t props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +void Lzma2Dec_Init(CLzma2Dec *p) +{ + p->state = LZMA2_STATE_CONTROL; + p->needInitDic = true; + p->needInitState = true; + p->needInitProp = true; + LzmaDec_Init(&p->decoder); +} + +static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, uint8_t b) +{ + switch(p->state) + { + case LZMA2_STATE_CONTROL: + p->control = b; + PRF(printf("\n %4X ", p->decoder.dicPos)); + PRF(printf(" %2X", b)); + if (p->control == 0) + return LZMA2_STATE_FINISHED; + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if ((p->control & 0x7F) > 2) + return LZMA2_STATE_ERROR; + p->unpackSize = 0; + } + else + p->unpackSize = (uint32_t)(p->control & 0x1F) << 16; + return LZMA2_STATE_UNPACK0; + + case LZMA2_STATE_UNPACK0: + p->unpackSize |= (uint32_t)b << 8; + return LZMA2_STATE_UNPACK1; + + case LZMA2_STATE_UNPACK1: + p->unpackSize |= (uint32_t)b; + p->unpackSize++; + PRF(printf(" %8d", p->unpackSize)); + return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; + + case LZMA2_STATE_PACK0: + p->packSize = (uint32_t)b << 8; + return LZMA2_STATE_PACK1; + + case LZMA2_STATE_PACK1: + p->packSize |= (uint32_t)b; + p->packSize++; + PRF(printf(" %8d", p->packSize)); + return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: + (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); + + case LZMA2_STATE_PROP: + { + int lc, lp; + if (b >= (9 * 5 * 5)) + return LZMA2_STATE_ERROR; + lc = b % 9; + b /= 9; + p->decoder.prop.pb = b / 5; + lp = b % 5; + if (lc + lp > LZMA2_LCLP_MAX) + return LZMA2_STATE_ERROR; + p->decoder.prop.lc = lc; + p->decoder.prop.lp = lp; + p->needInitProp = false; + return LZMA2_STATE_DATA; + } + } + return LZMA2_STATE_ERROR; +} + +static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const uint8_t *src, size_t size) +{ + memcpy(p->dic + p->dicPos, src, size); + p->dicPos += size; + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) + p->checkDicSize = p->prop.dicSize; + p->processedPos += (uint32_t)size; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t inSize = *srcLen; + *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + + while (p->state != LZMA2_STATE_FINISHED) + { + size_t dicPos = p->decoder.dicPos; + if (p->state == LZMA2_STATE_ERROR) + return SZ_ERROR_DATA; + if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) + { + if (*srcLen == inSize) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + (*srcLen)++; + p->state = Lzma2Dec_UpdateState(p, *src++); + continue; + } + { + size_t destSizeCur = dicLimit - dicPos; + size_t srcSizeCur = inSize - *srcLen; + ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; + + if (p->unpackSize <= destSizeCur) + { + destSizeCur = (size_t)p->unpackSize; + curFinishMode = LZMA_FINISH_END; + } + + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if (*srcLen == inSize) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + if (p->state == LZMA2_STATE_DATA) + { + bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); + if (initDic) + p->needInitProp = p->needInitState = true; + else if (p->needInitDic) + return SZ_ERROR_DATA; + p->needInitDic = false; + LzmaDec_InitDicAndState(&p->decoder, initDic, false); + } + + if (srcSizeCur > destSizeCur) + srcSizeCur = destSizeCur; + + if (srcSizeCur == 0) + return SZ_ERROR_DATA; + + LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->unpackSize -= (uint32_t)srcSizeCur; + p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; + } + else + { + size_t outSizeProcessed; + SRes res; + + if (p->state == LZMA2_STATE_DATA) + { + int mode = LZMA2_GET_LZMA_MODE(p); + bool initDic = (mode == 3); + bool initState = (mode > 0); + if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) + return SZ_ERROR_DATA; + + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); + p->needInitDic = false; + p->needInitState = false; + p->state = LZMA2_STATE_DATA_CONT; + } + if (srcSizeCur > p->packSize) + srcSizeCur = (size_t)p->packSize; + + res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->packSize -= (uint32_t)srcSizeCur; + + outSizeProcessed = p->decoder.dicPos - dicPos; + p->unpackSize -= (uint32_t)outSizeProcessed; + + RINOK(res); + if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) + return res; + + if (srcSizeCur == 0 && outSizeProcessed == 0) + { + if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || + p->unpackSize != 0 || p->packSize != 0) + return SZ_ERROR_DATA; + p->state = LZMA2_STATE_CONTROL; + } + if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) + *status = LZMA_STATUS_NOT_FINISHED; + } + } + } + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return SZ_OK; +} + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t outSize = *destLen, inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) + { + size_t srcSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->decoder.dicPos == p->decoder.dicBufSize) + p->decoder.dicPos = 0; + dicPos = p->decoder.dicPos; + if (outSize > p->decoder.dicBufSize - dicPos) + { + outSizeCur = p->decoder.dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } + else + { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); + src += srcSizeCur; + inSize -= srcSizeCur; + *srcLen += srcSizeCur; + outSizeCur = p->decoder.dicPos - dicPos; + memcpy(dest, p->decoder.dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } +} + +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) +{ + CLzma2Dec decoder; + SRes res; + size_t outSize = *destLen, inSize = *srcLen; + uint8_t props[LZMA_PROPS_SIZE]; + + Lzma2Dec_Construct(&decoder); + + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + decoder.decoder.dic = dest; + decoder.decoder.dicBufSize = outSize; + + RINOK(Lzma2Dec_GetOldProps(prop, props)); + RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); + + *srcLen = inSize; + res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); + *destLen = decoder.decoder.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + LzmaDec_FreeProbs(&decoder.decoder, alloc); + return res; +} diff --git a/deps/7zip/Lzma2Dec.h b/deps/7zip/Lzma2Dec.h index 53797ae049..5ab3706b49 100644 --- a/deps/7zip/Lzma2Dec.h +++ b/deps/7zip/Lzma2Dec.h @@ -1,85 +1,85 @@ -/* Lzma2Dec.h -- LZMA2 Decoder -2009-05-03 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_DEC_H -#define __LZMA2_DEC_H - -#include -#include "LzmaDec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- State Interface ---------- */ - -typedef struct -{ - CLzmaDec decoder; - uint32_t packSize; - uint32_t unpackSize; - int state; - uint8_t control; - bool needInitDic; - bool needInitState; - bool needInitProp; -} CLzma2Dec; - -#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) -#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); -#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); -SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); -void Lzma2Dec_Init(CLzma2Dec *p); - - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen or dicLimit). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - SZ_ERROR_DATA - Data error -*/ - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* Lzma2Dec.h -- LZMA2 Decoder +2009-05-03 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_DEC_H +#define __LZMA2_DEC_H + +#include +#include "LzmaDec.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- State Interface ---------- */ + +typedef struct +{ + CLzmaDec decoder; + uint32_t packSize; + uint32_t unpackSize; + int state; + uint8_t control; + bool needInitDic; + bool needInitState; + bool needInitProp; +} CLzma2Dec; + +#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) +#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); +#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); +void Lzma2Dec_Init(CLzma2Dec *p); + + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen or dicLimit). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_NEEDS_MORE_INPUT + SZ_ERROR_DATA - Data error +*/ + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- One Call Interface ---------- */ + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +*/ + +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index 4a0a5a5faf..5325053939 100644 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -1,1040 +1,1040 @@ -/* LzmaDec.c -- LZMA Decoder - 2009-09-20 : Igor Pavlov : Public domain */ -#include -#include -#include - -#include "LzmaDec.h" - -#define kNumTopBits 24 -#define kTopValue ((uint32_t)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_INIT_SIZE 5 - -#define LZMADEC_NORMALIZE if (range < kTopValue) { range <<= 8; codes = (codes << 8) | (*buf++); } - -#define LZMADEC_IF_BIT_0(prob) ttt = *(prob); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) -#define UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define LZMADEC_UPDATE_1(p) range -= bound; codes -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); -#define GET_BIT2(p, i, A0, A1) LZMADEC_IF_BIT_0(p) \ -{ UPDATE_0(p); i = (i + i); A0; } else \ -{ LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; } -#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) - -#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } -#define TREE_DECODE(probs, limit, i) \ -{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } - -/* #define _LZMA_SIZE_OPT */ - -#ifdef _LZMA_SIZE_OPT -#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) -#else -#define TREE_6_DECODE(probs, i) \ -{ i = 1; \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - i -= 0x40; } -#endif - -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; codes = (codes << 8) | (*buf++); } - -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) -#define UPDATE_0_CHECK range = bound; -#define UPDATE_1_CHECK range -= bound; codes -= bound; -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ -{ UPDATE_0_CHECK; i = (i + i); A0; } else \ -{ UPDATE_1_CHECK; i = (i + i) + 1; A1; } -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) -#define TREE_DECODE_CHECK(probs, limit, i) \ -{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -#define LZMA_DIC_MIN (1 << 12) - -/* First LZMA-symbol is always decoded. - And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization - Out: - Result: - SZ_OK - OK - SZ_ERROR_DATA - Error - p->remainLen: - < kMatchSpecLenStart : normal remain - = kMatchSpecLenStart : finished - = kMatchSpecLenStart + 1 : Flush marker - = kMatchSpecLenStart + 2 : State Init Marker - */ - -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) -{ - uint16_t *probs = p->probs; - - unsigned state = p->state; - uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; - unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; - unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; - unsigned lc = p->prop.lc; - - uint8_t *dic = p->dic; - size_t dicBufSize = p->dicBufSize; - size_t dicPos = p->dicPos; - - uint32_t processedPos = p->processedPos; - uint32_t checkDicSize = p->checkDicSize; - unsigned len = 0; - - const uint8_t *buf = p->buf; - uint32_t range = p->range; - uint32_t codes = p->code; - - do - { - uint16_t *prob; - uint32_t bound; - unsigned ttt; - unsigned posState = processedPos & pbMask; - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - unsigned symbol; - UPDATE_0(prob); - prob = probs + Literal; - if (checkDicSize != 0 || processedPos != 0) - prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + - (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); - - if (state < kNumLitStates) - { - state -= (state < 4) ? state : 3; - symbol = 1; - do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; - symbol = 1; - do - { - unsigned bit; - uint16_t *probLit; - matchuint8_t <<= 1; - bit = (matchuint8_t & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - dic[dicPos++] = (uint8_t)symbol; - processedPos++; - continue; - } - else - { - LZMADEC_UPDATE_1(prob); - prob = probs + IsRep + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - state += kNumStates; - prob = probs + LenCoder; - } - else - { - LZMADEC_UPDATE_1(prob); - if (checkDicSize == 0 && processedPos == 0) - return SZ_ERROR_DATA; - prob = probs + IsRepG0 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - processedPos++; - state = state < kNumLitStates ? 9 : 11; - continue; - } - LZMADEC_UPDATE_1(prob); - } - else - { - uint32_t distance; - LZMADEC_UPDATE_1(prob); - prob = probs + IsRepG1 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - distance = rep1; - } - else - { - LZMADEC_UPDATE_1(prob); - prob = probs + IsRepG2 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - distance = rep2; - } - else - { - LZMADEC_UPDATE_1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = probs + RepLenCoder; - } - { - unsigned _limit, offset; - uint16_t *probLen = prob + LenChoice; - - ttt = *(probLen); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - if (codes < bound) - { - UPDATE_0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - _limit = (1 << kLenNumLowBits); - } - else - { - LZMADEC_UPDATE_1(probLen); - probLen = prob + LenChoice2; - - ttt = *(probLen); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - if (codes < bound) - { - UPDATE_0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - _limit = (1 << kLenNumMidBits); - } - else - { - LZMADEC_UPDATE_1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - _limit = (1 << kLenNumHighBits); - } - } - TREE_DECODE(probLen, _limit, len); - len += offset; - } - - if (state >= kNumStates) - { - uint32_t distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance); - if (distance >= kStartPosModelIndex) - { - unsigned posSlot = (unsigned)distance; - int numDirectBits = (int)(((distance >> 1) - 1)); - distance = (2 | (distance & 1)); - if (posSlot < kEndPosModelIndex) - { - distance <<= numDirectBits; - prob = probs + SpecPos + distance - posSlot - 1; - { - uint32_t mask = 1; - unsigned i = 1; - do - { - GET_BIT2(prob + i, i, ; , distance |= mask); - mask <<= 1; - } - while (--numDirectBits != 0); - } - } - else - { - numDirectBits -= kNumAlignBits; - do - { - LZMADEC_NORMALIZE - range >>= 1; - - { - uint32_t t; - codes -= range; - t = (0 - ((uint32_t)codes >> 31)); /* (uint32_t)((Int32)codes >> 31) */ - distance = (distance << 1) + (t + 1); - codes += range & t; - } - /* - distance <<= 1; - if (codes >= range) - { - codes -= range; - distance |= 1; - } - */ - } - while (--numDirectBits != 0); - prob = probs + Align; - distance <<= kNumAlignBits; - { - unsigned i = 1; - GET_BIT2(prob + i, i, ; , distance |= 1); - GET_BIT2(prob + i, i, ; , distance |= 2); - GET_BIT2(prob + i, i, ; , distance |= 4); - GET_BIT2(prob + i, i, ; , distance |= 8); - } - if (distance == (uint32_t)0xFFFFFFFF) - { - len += kMatchSpecLenStart; - state -= kNumStates; - break; - } - } - } - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance + 1; - if (checkDicSize == 0) - { - if (distance >= processedPos) - return SZ_ERROR_DATA; - } - else if (distance >= checkDicSize) - return SZ_ERROR_DATA; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - } - - len += kMatchMinLen; - - if (limit == dicPos) - return SZ_ERROR_DATA; - { - size_t rem = limit - dicPos; - unsigned curLen = ((rem < len) ? (unsigned)rem : len); - size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); - - processedPos += curLen; - - len -= curLen; - if (pos + curLen <= dicBufSize) - { - uint8_t *dest = dic + dicPos; - ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const uint8_t *lim = dest + curLen; - dicPos += curLen; - do - *(dest) = (uint8_t)*(dest + src); - while (++dest != lim); - } - else - { - do - { - dic[dicPos++] = dic[pos]; - if (++pos == dicBufSize) - pos = 0; - } - while (--curLen != 0); - } - } - } - }while (dicPos < limit && buf < bufLimit); - - LZMADEC_NORMALIZE; - - p->buf = buf; - p->range = range; - p->code = codes; - p->remainLen = len; - p->dicPos = dicPos; - p->processedPos = processedPos; - p->reps[0] = rep0; - p->reps[1] = rep1; - p->reps[2] = rep2; - p->reps[3] = rep3; - p->state = state; - - return SZ_OK; -} - -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit) -{ - if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) - { - uint8_t *dic = p->dic; - size_t dicPos = p->dicPos; - size_t dicBufSize = p->dicBufSize; - unsigned len = p->remainLen; - uint32_t rep0 = p->reps[0]; - if (limit - dicPos < len) - len = (unsigned)(limit - dicPos); - - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; - - p->processedPos += len; - p->remainLen -= len; - while (len-- != 0) - { - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - } - p->dicPos = dicPos; - } -} - -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) -{ - do - { - size_t limit2 = limit; - if (p->checkDicSize == 0) - { - uint32_t rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit2 = p->dicPos + rem; - } - RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); - if (p->processedPos >= p->prop.dicSize) - p->checkDicSize = p->prop.dicSize; - LzmaDec_WriteRem(p, limit); - } - while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); - - if (p->remainLen > kMatchSpecLenStart) - { - p->remainLen = kMatchSpecLenStart; - } - return 0; -} - -typedef enum -{ - DUMMY_ERROR, /* unexpected end of input stream */ - DUMMY_LIT, - DUMMY_MATCH, - DUMMY_REP -} ELzmaDummy; - -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize) -{ - uint32_t range = p->range; - uint32_t codes = p->code; - const uint8_t *bufLimit = buf + inSize; - uint16_t *probs = p->probs; - unsigned state = p->state; - ELzmaDummy res; - - { - uint16_t *prob; - uint32_t bound; - unsigned ttt; - unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK - - /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ - - prob = probs + Literal; - if (p->checkDicSize != 0 || p->processedPos != 0) - prob += (LZMA_LIT_SIZE * - ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + - (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); - - if (state < kNumLitStates) - { - unsigned symbol = 1; - do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] + - ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; - unsigned offs = 0x100; - unsigned symbol = 1; - do - { - unsigned bit; - uint16_t *probLit; - matchuint8_t <<= 1; - bit = (matchuint8_t & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - res = DUMMY_LIT; - } - else - { - unsigned len; - UPDATE_1_CHECK; - - prob = probs + IsRep + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - state = 0; - prob = probs + LenCoder; - res = DUMMY_MATCH; - } - else - { - UPDATE_1_CHECK; - res = DUMMY_REP; - prob = probs + IsRepG0 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - NORMALIZE_CHECK; - return DUMMY_REP; - } - else - { - UPDATE_1_CHECK; - } - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG1 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG2 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - } - } - } - state = kNumStates; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - uint16_t *probLen = prob + LenChoice; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenChoice2; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = 1 << kLenNumMidBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = 1 << kLenNumHighBits; - } - } - TREE_DECODE_CHECK(probLen, limit, len); - len += offset; - } - - if (state < 4) - { - unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); - - /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ - - if (posSlot < kEndPosModelIndex) - { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE_CHECK - range >>= 1; - codes -= range & (((codes - range) >> 31) - 1); - /* if (codes >= range) codes -= range; */ - } - while (--numDirectBits != 0); - prob = probs + Align; - numDirectBits = kNumAlignBits; - } - { - unsigned i = 1; - do - { - GET_BIT_CHECK(prob + i, i); - } - while (--numDirectBits != 0); - } - } - } - } - } - NORMALIZE_CHECK; - return res; -} - - -static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data) -{ - p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]); - p->range = 0xFFFFFFFF; - p->needFlush = 0; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState) -{ - p->needFlush = 1; - p->remainLen = 0; - p->tempBufSize = 0; - - if (initDic) - { - p->processedPos = 0; - p->checkDicSize = 0; - p->needInitState = 1; - } - if (initState) - p->needInitState = 1; -} - -void LzmaDec_Init(CLzmaDec *p) -{ - p->dicPos = 0; - LzmaDec_InitDicAndState(p, true, true); -} - -static void LzmaDec_InitStateReal(CLzmaDec *p) -{ - uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); - uint32_t i; - uint16_t *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - p->needInitState = 0; -} - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t inSize = *srcLen; - (*srcLen) = 0; - LzmaDec_WriteRem(p, dicLimit); - - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->remainLen != kMatchSpecLenStart) - { - int checkEndMarkNow; - - if (p->needFlush != 0) - { - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (p->tempBuf[0] != 0) - return SZ_ERROR_DATA; - - LzmaDec_InitRc(p, p->tempBuf); - p->tempBufSize = 0; - } - - checkEndMarkNow = 0; - if (p->dicPos >= dicLimit) - { - if (p->remainLen == 0 && p->code == 0) - { - *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; - return SZ_OK; - } - if (finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->remainLen != 0) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - checkEndMarkNow = 1; - } - - if (p->needInitState) - LzmaDec_InitStateReal(p); - - if (p->tempBufSize == 0) - { - size_t processed; - const uint8_t *bufLimit; - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, src, inSize); - if (dummyRes == DUMMY_ERROR) - { - memcpy(p->tempBuf, src, inSize); - p->tempBufSize = (unsigned)inSize; - (*srcLen) += inSize; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - bufLimit = src; - } - else - bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - p->buf = src; - if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) - return SZ_ERROR_DATA; - processed = (size_t)(p->buf - src); - (*srcLen) += processed; - src += processed; - inSize -= processed; - } - else - { - unsigned rem = p->tempBufSize, lookAhead = 0; - while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) - p->tempBuf[rem++] = src[lookAhead++]; - p->tempBufSize = rem; - if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); - if (dummyRes == DUMMY_ERROR) - { - (*srcLen) += lookAhead; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - } - p->buf = p->tempBuf; - if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) - return SZ_ERROR_DATA; - lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); - (*srcLen) += lookAhead; - src += lookAhead; - inSize -= lookAhead; - p->tempBufSize = 0; - } - } - if (p->code == 0) - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; -} - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t outSize = *destLen; - size_t inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - size_t inSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->dicPos == p->dicBufSize) - p->dicPos = 0; - dicPos = p->dicPos; - if (outSize > p->dicBufSize - dicPos) - { - outSizeCur = p->dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); - src += inSizeCur; - inSize -= inSizeCur; - *srcLen += inSizeCur; - outSizeCur = p->dicPos - dicPos; - memcpy(dest, p->dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->probs); - p->probs = 0; -} - -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->dic); - p->dic = 0; -} - -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) -{ - LzmaDec_FreeProbs(p, alloc); - LzmaDec_FreeDict(p, alloc); -} - -SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size) -{ - uint32_t dicSize; - uint8_t d; - - if (size < LZMA_PROPS_SIZE) - return SZ_ERROR_UNSUPPORTED; - else - dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); - - if (dicSize < LZMA_DIC_MIN) - dicSize = LZMA_DIC_MIN; - p->dicSize = dicSize; - - d = data[0]; - if (d >= (9 * 5 * 5)) - return SZ_ERROR_UNSUPPORTED; - - p->lc = d % 9; - d /= 9; - p->pb = d / 5; - p->lp = d % 5; - - return SZ_OK; -} - -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) -{ - uint32_t numProbs = LzmaProps_GetNumProbs(propNew); - if (p->probs == 0 || numProbs != p->numProbs) - { - LzmaDec_FreeProbs(p, alloc); - p->probs = (uint16_t *)alloc->Alloc(alloc, numProbs * sizeof(uint16_t)); - p->numProbs = numProbs; - if (p->probs == 0) - return SZ_ERROR_MEM; - } - return SZ_OK; -} - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - size_t dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - dicBufSize = propNew.dicSize; - if (p->dic == 0 || dicBufSize != p->dicBufSize) - { - LzmaDec_FreeDict(p, alloc); - p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize); - if (p->dic == 0) - { - LzmaDec_FreeProbs(p, alloc); - return SZ_ERROR_MEM; - } - } - p->dicBufSize = dicBufSize; - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzmaDec p; - SRes res; - size_t inSize = *srcLen; - size_t outSize = *destLen; - *srcLen = *destLen = 0; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; - - LzmaDec_Construct(&p); - res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); - if (res != 0) - return res; - p.dic = dest; - p.dicBufSize = outSize; - - LzmaDec_Init(&p); - - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - (*destLen) = p.dicPos; - LzmaDec_FreeProbs(&p, alloc); - return res; -} +/* LzmaDec.c -- LZMA Decoder + 2009-09-20 : Igor Pavlov : Public domain */ +#include +#include +#include + +#include "LzmaDec.h" + +#define kNumTopBits 24 +#define kTopValue ((uint32_t)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_INIT_SIZE 5 + +#define LZMADEC_NORMALIZE if (range < kTopValue) { range <<= 8; codes = (codes << 8) | (*buf++); } + +#define LZMADEC_IF_BIT_0(prob) ttt = *(prob); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) +#define UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define LZMADEC_UPDATE_1(p) range -= bound; codes -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); +#define GET_BIT2(p, i, A0, A1) LZMADEC_IF_BIT_0(p) \ +{ UPDATE_0(p); i = (i + i); A0; } else \ +{ LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; } +#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) + +#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } +#define TREE_DECODE(probs, limit, i) \ +{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } + +/* #define _LZMA_SIZE_OPT */ + +#ifdef _LZMA_SIZE_OPT +#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) +#else +#define TREE_6_DECODE(probs, i) \ +{ i = 1; \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + i -= 0x40; } +#endif + +#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; codes = (codes << 8) | (*buf++); } + +#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) +#define UPDATE_0_CHECK range = bound; +#define UPDATE_1_CHECK range -= bound; codes -= bound; +#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ +{ UPDATE_0_CHECK; i = (i + i); A0; } else \ +{ UPDATE_1_CHECK; i = (i + i) + 1; A1; } +#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) +#define TREE_DECODE_CHECK(probs, limit, i) \ +{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } + + +#define kNumPosBitsMax 4 +#define kNumPosStatesMax (1 << kNumPosBitsMax) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) + +#define LenChoice 0 +#define LenChoice2 (LenChoice + 1) +#define LenLow (LenChoice2 + 1) +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) +#define kNumLenProbs (LenHigh + kLenNumHighSymbols) + + +#define kNumStates 12 +#define kNumLitStates 7 + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +#define kNumPosSlotBits 6 +#define kNumLenToPosStates 4 + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) + +#define kMatchMinLen 2 +#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) + +#define IsMatch 0 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) +#define IsRepG0 (IsRep + kNumStates) +#define IsRepG1 (IsRepG0 + kNumStates) +#define IsRepG2 (IsRepG1 + kNumStates) +#define IsRep0Long (IsRepG2 + kNumStates) +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) +#define LenCoder (Align + kAlignTableSize) +#define RepLenCoder (LenCoder + kNumLenProbs) +#define Literal (RepLenCoder + kNumLenProbs) + +#define LZMA_BASE_SIZE 1846 +#define LZMA_LIT_SIZE 768 + +#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) + +#if Literal != LZMA_BASE_SIZE +StopCompilingDueBUG +#endif + +#define LZMA_DIC_MIN (1 << 12) + +/* First LZMA-symbol is always decoded. + And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization + Out: + Result: + SZ_OK - OK + SZ_ERROR_DATA - Error + p->remainLen: + < kMatchSpecLenStart : normal remain + = kMatchSpecLenStart : finished + = kMatchSpecLenStart + 1 : Flush marker + = kMatchSpecLenStart + 2 : State Init Marker + */ + +static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) +{ + uint16_t *probs = p->probs; + + unsigned state = p->state; + uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; + unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; + unsigned lc = p->prop.lc; + + uint8_t *dic = p->dic; + size_t dicBufSize = p->dicBufSize; + size_t dicPos = p->dicPos; + + uint32_t processedPos = p->processedPos; + uint32_t checkDicSize = p->checkDicSize; + unsigned len = 0; + + const uint8_t *buf = p->buf; + uint32_t range = p->range; + uint32_t codes = p->code; + + do + { + uint16_t *prob; + uint32_t bound; + unsigned ttt; + unsigned posState = processedPos & pbMask; + + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + unsigned symbol; + UPDATE_0(prob); + prob = probs + Literal; + if (checkDicSize != 0 || processedPos != 0) + prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + + (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); + + if (state < kNumLitStates) + { + state -= (state < 4) ? state : 3; + symbol = 1; + do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); + } + else + { + unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + unsigned offs = 0x100; + state -= (state < 10) ? 3 : 6; + symbol = 1; + do + { + unsigned bit; + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) + } + while (symbol < 0x100); + } + dic[dicPos++] = (uint8_t)symbol; + processedPos++; + continue; + } + else + { + LZMADEC_UPDATE_1(prob); + prob = probs + IsRep + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + state += kNumStates; + prob = probs + LenCoder; + } + else + { + LZMADEC_UPDATE_1(prob); + if (checkDicSize == 0 && processedPos == 0) + return SZ_ERROR_DATA; + prob = probs + IsRepG0 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + processedPos++; + state = state < kNumLitStates ? 9 : 11; + continue; + } + LZMADEC_UPDATE_1(prob); + } + else + { + uint32_t distance; + LZMADEC_UPDATE_1(prob); + prob = probs + IsRepG1 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + distance = rep1; + } + else + { + LZMADEC_UPDATE_1(prob); + prob = probs + IsRepG2 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + distance = rep2; + } + else + { + LZMADEC_UPDATE_1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = probs + RepLenCoder; + } + { + unsigned _limit, offset; + uint16_t *probLen = prob + LenChoice; + + ttt = *(probLen); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + if (codes < bound) + { + UPDATE_0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + _limit = (1 << kLenNumLowBits); + } + else + { + LZMADEC_UPDATE_1(probLen); + probLen = prob + LenChoice2; + + ttt = *(probLen); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + if (codes < bound) + { + UPDATE_0(probLen); + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + _limit = (1 << kLenNumMidBits); + } + else + { + LZMADEC_UPDATE_1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + _limit = (1 << kLenNumHighBits); + } + } + TREE_DECODE(probLen, _limit, len); + len += offset; + } + + if (state >= kNumStates) + { + uint32_t distance; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); + TREE_6_DECODE(prob, distance); + if (distance >= kStartPosModelIndex) + { + unsigned posSlot = (unsigned)distance; + int numDirectBits = (int)(((distance >> 1) - 1)); + distance = (2 | (distance & 1)); + if (posSlot < kEndPosModelIndex) + { + distance <<= numDirectBits; + prob = probs + SpecPos + distance - posSlot - 1; + { + uint32_t mask = 1; + unsigned i = 1; + do + { + GET_BIT2(prob + i, i, ; , distance |= mask); + mask <<= 1; + } + while (--numDirectBits != 0); + } + } + else + { + numDirectBits -= kNumAlignBits; + do + { + LZMADEC_NORMALIZE + range >>= 1; + + { + uint32_t t; + codes -= range; + t = (0 - ((uint32_t)codes >> 31)); /* (uint32_t)((Int32)codes >> 31) */ + distance = (distance << 1) + (t + 1); + codes += range & t; + } + /* + distance <<= 1; + if (codes >= range) + { + codes -= range; + distance |= 1; + } + */ + } + while (--numDirectBits != 0); + prob = probs + Align; + distance <<= kNumAlignBits; + { + unsigned i = 1; + GET_BIT2(prob + i, i, ; , distance |= 1); + GET_BIT2(prob + i, i, ; , distance |= 2); + GET_BIT2(prob + i, i, ; , distance |= 4); + GET_BIT2(prob + i, i, ; , distance |= 8); + } + if (distance == (uint32_t)0xFFFFFFFF) + { + len += kMatchSpecLenStart; + state -= kNumStates; + break; + } + } + } + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance + 1; + if (checkDicSize == 0) + { + if (distance >= processedPos) + return SZ_ERROR_DATA; + } + else if (distance >= checkDicSize) + return SZ_ERROR_DATA; + state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; + } + + len += kMatchMinLen; + + if (limit == dicPos) + return SZ_ERROR_DATA; + { + size_t rem = limit - dicPos; + unsigned curLen = ((rem < len) ? (unsigned)rem : len); + size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); + + processedPos += curLen; + + len -= curLen; + if (pos + curLen <= dicBufSize) + { + uint8_t *dest = dic + dicPos; + ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; + const uint8_t *lim = dest + curLen; + dicPos += curLen; + do + *(dest) = (uint8_t)*(dest + src); + while (++dest != lim); + } + else + { + do + { + dic[dicPos++] = dic[pos]; + if (++pos == dicBufSize) + pos = 0; + } + while (--curLen != 0); + } + } + } + }while (dicPos < limit && buf < bufLimit); + + LZMADEC_NORMALIZE; + + p->buf = buf; + p->range = range; + p->code = codes; + p->remainLen = len; + p->dicPos = dicPos; + p->processedPos = processedPos; + p->reps[0] = rep0; + p->reps[1] = rep1; + p->reps[2] = rep2; + p->reps[3] = rep3; + p->state = state; + + return SZ_OK; +} + +static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit) +{ + if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) + { + uint8_t *dic = p->dic; + size_t dicPos = p->dicPos; + size_t dicBufSize = p->dicBufSize; + unsigned len = p->remainLen; + uint32_t rep0 = p->reps[0]; + if (limit - dicPos < len) + len = (unsigned)(limit - dicPos); + + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) + p->checkDicSize = p->prop.dicSize; + + p->processedPos += len; + p->remainLen -= len; + while (len-- != 0) + { + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + } + p->dicPos = dicPos; + } +} + +static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) +{ + do + { + size_t limit2 = limit; + if (p->checkDicSize == 0) + { + uint32_t rem = p->prop.dicSize - p->processedPos; + if (limit - p->dicPos > rem) + limit2 = p->dicPos + rem; + } + RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); + if (p->processedPos >= p->prop.dicSize) + p->checkDicSize = p->prop.dicSize; + LzmaDec_WriteRem(p, limit); + } + while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); + + if (p->remainLen > kMatchSpecLenStart) + { + p->remainLen = kMatchSpecLenStart; + } + return 0; +} + +typedef enum +{ + DUMMY_ERROR, /* unexpected end of input stream */ + DUMMY_LIT, + DUMMY_MATCH, + DUMMY_REP +} ELzmaDummy; + +static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize) +{ + uint32_t range = p->range; + uint32_t codes = p->code; + const uint8_t *bufLimit = buf + inSize; + uint16_t *probs = p->probs; + unsigned state = p->state; + ELzmaDummy res; + + { + uint16_t *prob; + uint32_t bound; + unsigned ttt; + unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); + + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK + + /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ + + prob = probs + Literal; + if (p->checkDicSize != 0 || p->processedPos != 0) + prob += (LZMA_LIT_SIZE * + ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + + (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); + + if (state < kNumLitStates) + { + unsigned symbol = 1; + do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); + } + else + { + unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] + + ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; + unsigned offs = 0x100; + unsigned symbol = 1; + do + { + unsigned bit; + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) + } + while (symbol < 0x100); + } + res = DUMMY_LIT; + } + else + { + unsigned len; + UPDATE_1_CHECK; + + prob = probs + IsRep + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + state = 0; + prob = probs + LenCoder; + res = DUMMY_MATCH; + } + else + { + UPDATE_1_CHECK; + res = DUMMY_REP; + prob = probs + IsRepG0 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + NORMALIZE_CHECK; + return DUMMY_REP; + } + else + { + UPDATE_1_CHECK; + } + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG1 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG2 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + } + } + } + state = kNumStates; + prob = probs + RepLenCoder; + } + { + unsigned limit, offset; + uint16_t *probLen = prob + LenChoice; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + limit = 1 << kLenNumLowBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenChoice2; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + limit = 1 << kLenNumMidBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + limit = 1 << kLenNumHighBits; + } + } + TREE_DECODE_CHECK(probLen, limit, len); + len += offset; + } + + if (state < 4) + { + unsigned posSlot; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << + kNumPosSlotBits); + TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) + { + int numDirectBits = ((posSlot >> 1) - 1); + + /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ + + if (posSlot < kEndPosModelIndex) + { + prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; + } + else + { + numDirectBits -= kNumAlignBits; + do + { + NORMALIZE_CHECK + range >>= 1; + codes -= range & (((codes - range) >> 31) - 1); + /* if (codes >= range) codes -= range; */ + } + while (--numDirectBits != 0); + prob = probs + Align; + numDirectBits = kNumAlignBits; + } + { + unsigned i = 1; + do + { + GET_BIT_CHECK(prob + i, i); + } + while (--numDirectBits != 0); + } + } + } + } + } + NORMALIZE_CHECK; + return res; +} + + +static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data) +{ + p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]); + p->range = 0xFFFFFFFF; + p->needFlush = 0; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState) +{ + p->needFlush = 1; + p->remainLen = 0; + p->tempBufSize = 0; + + if (initDic) + { + p->processedPos = 0; + p->checkDicSize = 0; + p->needInitState = 1; + } + if (initState) + p->needInitState = 1; +} + +void LzmaDec_Init(CLzmaDec *p) +{ + p->dicPos = 0; + LzmaDec_InitDicAndState(p, true, true); +} + +static void LzmaDec_InitStateReal(CLzmaDec *p) +{ + uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); + uint32_t i; + uint16_t *probs = p->probs; + for (i = 0; i < numProbs; i++) + probs[i] = kBitModelTotal >> 1; + p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; + p->state = 0; + p->needInitState = 0; +} + +SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t inSize = *srcLen; + (*srcLen) = 0; + LzmaDec_WriteRem(p, dicLimit); + + *status = LZMA_STATUS_NOT_SPECIFIED; + + while (p->remainLen != kMatchSpecLenStart) + { + int checkEndMarkNow; + + if (p->needFlush != 0) + { + for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) + p->tempBuf[p->tempBufSize++] = *src++; + if (p->tempBufSize < RC_INIT_SIZE) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (p->tempBuf[0] != 0) + return SZ_ERROR_DATA; + + LzmaDec_InitRc(p, p->tempBuf); + p->tempBufSize = 0; + } + + checkEndMarkNow = 0; + if (p->dicPos >= dicLimit) + { + if (p->remainLen == 0 && p->code == 0) + { + *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; + return SZ_OK; + } + if (finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->remainLen != 0) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + checkEndMarkNow = 1; + } + + if (p->needInitState) + LzmaDec_InitStateReal(p); + + if (p->tempBufSize == 0) + { + size_t processed; + const uint8_t *bufLimit; + if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + int dummyRes = LzmaDec_TryDummy(p, src, inSize); + if (dummyRes == DUMMY_ERROR) + { + memcpy(p->tempBuf, src, inSize); + p->tempBufSize = (unsigned)inSize; + (*srcLen) += inSize; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + bufLimit = src; + } + else + bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; + p->buf = src; + if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) + return SZ_ERROR_DATA; + processed = (size_t)(p->buf - src); + (*srcLen) += processed; + src += processed; + inSize -= processed; + } + else + { + unsigned rem = p->tempBufSize, lookAhead = 0; + while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) + p->tempBuf[rem++] = src[lookAhead++]; + p->tempBufSize = rem; + if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); + if (dummyRes == DUMMY_ERROR) + { + (*srcLen) += lookAhead; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + } + p->buf = p->tempBuf; + if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) + return SZ_ERROR_DATA; + lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); + (*srcLen) += lookAhead; + src += lookAhead; + inSize -= lookAhead; + p->tempBufSize = 0; + } + } + if (p->code == 0) + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; +} + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t outSize = *destLen; + size_t inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) + { + size_t inSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->dicPos == p->dicBufSize) + p->dicPos = 0; + dicPos = p->dicPos; + if (outSize > p->dicBufSize - dicPos) + { + outSizeCur = p->dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } + else + { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); + src += inSizeCur; + inSize -= inSizeCur; + *srcLen += inSizeCur; + outSizeCur = p->dicPos - dicPos; + memcpy(dest, p->dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } +} + +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->probs); + p->probs = 0; +} + +static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->dic); + p->dic = 0; +} + +void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) +{ + LzmaDec_FreeProbs(p, alloc); + LzmaDec_FreeDict(p, alloc); +} + +SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size) +{ + uint32_t dicSize; + uint8_t d; + + if (size < LZMA_PROPS_SIZE) + return SZ_ERROR_UNSUPPORTED; + else + dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); + + if (dicSize < LZMA_DIC_MIN) + dicSize = LZMA_DIC_MIN; + p->dicSize = dicSize; + + d = data[0]; + if (d >= (9 * 5 * 5)) + return SZ_ERROR_UNSUPPORTED; + + p->lc = d % 9; + d /= 9; + p->pb = d / 5; + p->lp = d % 5; + + return SZ_OK; +} + +static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) +{ + uint32_t numProbs = LzmaProps_GetNumProbs(propNew); + if (p->probs == 0 || numProbs != p->numProbs) + { + LzmaDec_FreeProbs(p, alloc); + p->probs = (uint16_t *)alloc->Alloc(alloc, numProbs * sizeof(uint16_t)); + p->numProbs = numProbs; + if (p->probs == 0) + return SZ_ERROR_MEM; + } + return SZ_OK; +} + +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) +{ + CLzmaProps propNew; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) +{ + CLzmaProps propNew; + size_t dicBufSize; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + dicBufSize = propNew.dicSize; + if (p->dic == 0 || dicBufSize != p->dicBufSize) + { + LzmaDec_FreeDict(p, alloc); + p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize); + if (p->dic == 0) + { + LzmaDec_FreeProbs(p, alloc); + return SZ_ERROR_MEM; + } + } + p->dicBufSize = dicBufSize; + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc) +{ + CLzmaDec p; + SRes res; + size_t inSize = *srcLen; + size_t outSize = *destLen; + *srcLen = *destLen = 0; + if (inSize < RC_INIT_SIZE) + return SZ_ERROR_INPUT_EOF; + + LzmaDec_Construct(&p); + res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); + if (res != 0) + return res; + p.dic = dest; + p.dicBufSize = outSize; + + LzmaDec_Init(&p); + + *srcLen = inSize; + res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); + + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + (*destLen) = p.dicPos; + LzmaDec_FreeProbs(&p, alloc); + return res; +} diff --git a/deps/7zip/LzmaDec.h b/deps/7zip/LzmaDec.h index b10837ce99..a7cf98d971 100644 --- a/deps/7zip/LzmaDec.h +++ b/deps/7zip/LzmaDec.h @@ -1,220 +1,220 @@ -/* LzmaDec.h -- LZMA Decoder - 2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_DEC_H -#define __LZMA_DEC_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- LZMA Properties ---------- */ - -#define LZMA_PROPS_SIZE 5 - - typedef struct _CLzmaProps - { - unsigned lc, lp, pb; - uint32_t dicSize; - } CLzmaProps; - - /* LzmaProps_Decode - decodes properties -Returns: -SZ_OK -SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - - SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size); - - - /* ---------- LZMA Decoder state ---------- */ - - /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. - Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ - -#define LZMA_REQUIRED_INPUT_MAX 20 - - typedef struct - { - CLzmaProps prop; - uint16_t *probs; - uint8_t *dic; - const uint8_t *buf; - uint32_t range, code; - size_t dicPos; - size_t dicBufSize; - uint32_t processedPos; - uint32_t checkDicSize; - unsigned state; - uint32_t reps[4]; - unsigned remainLen; - int needFlush; - int needInitState; - uint32_t numProbs; - unsigned tempBufSize; - uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX]; - } CLzmaDec; - -#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } - - void LzmaDec_Init(CLzmaDec *p); - - /* There are two types of LZMA streams: - 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. - 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ - - typedef enum - { - LZMA_FINISH_ANY, /* finish at any point */ - LZMA_FINISH_END /* block must be finished at the end */ - } ELzmaFinishMode; - - /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! - - You must use LZMA_FINISH_END, when you know that current output buffer - covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. - - If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, - and output value of destLen will be less than output buffer size limit. - You can check status result also. - - You can use multiple checks to test data integrity after full decompression: - 1) Check Result and "status" variable. - 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. - 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. - You must use correct finish mode in that case. */ - - typedef enum - { - LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ - LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ - LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ - } ELzmaStatus; - - /* ELzmaStatus is used only as output value for function call */ - - - /* ---------- Interfaces ---------- */ - - /* There are 3 levels of interfaces: - 1) Dictionary Interface - 2) Buffer Interface - 3) One Call Interface - You can select any of these interfaces, but don't mix functions from different - groups for same object. */ - - - /* There are two variants to allocate state for Dictionary Interface: - 1) LzmaDec_Allocate / LzmaDec_Free - 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs - You can use variant 2, if you set dictionary buffer manually. - For Buffer Interface you must always use variant 1. - - LzmaDec_Allocate* can return: - SZ_OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - */ - - SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc); - void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); - - SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc); - void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); - - /* ---------- Dictionary Interface ---------- */ - - /* You can use it, if you want to eliminate the overhead for data copying from - dictionary to some other external buffer. - You must work with CLzmaDec variables directly in this interface. - -STEPS: -LzmaDec_Constr() -LzmaDec_Allocate() -for (each new stream) -{ -LzmaDec_Init() -while (it needs more decompression) -{ -LzmaDec_DecodeToDic() -use data from CLzmaDec::dic and update CLzmaDec::dicPos -} -} -LzmaDec_Free() -*/ - - /* LzmaDec_DecodeToDic - - The decoding to internal dictionary buffer (CLzmaDec::dic). - You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! - -finishMode: -It has meaning only if the decoding reaches output limit (dicLimit). -LZMA_FINISH_ANY - Decode just dicLimit bytes. -LZMA_FINISH_END - Stream must be finished after dicLimit. - -Returns: -SZ_OK -status: -LZMA_STATUS_FINISHED_WITH_MARK -LZMA_STATUS_NOT_FINISHED -LZMA_STATUS_NEEDS_MORE_INPUT -LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK -SZ_ERROR_DATA - Data error -*/ - - SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- Buffer Interface ---------- */ - -/* It's zlib-like interface. - See LzmaDec_DecodeToDic description for information about STEPS and return results, - but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need - to work with CLzmaDec variables manually. - -finishMode: -It has meaning only if the decoding reaches output limit (*destLen). -LZMA_FINISH_ANY - Decode just destLen bytes. -LZMA_FINISH_END - Stream must be finished after (*destLen). -*/ - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* LzmaDecode - -finishMode: -It has meaning only if the decoding reaches output limit (*destLen). -LZMA_FINISH_ANY - Decode just destLen bytes. -LZMA_FINISH_END - Stream must be finished after (*destLen). - -Returns: -SZ_OK -status: -LZMA_STATUS_FINISHED_WITH_MARK -LZMA_STATUS_NOT_FINISHED -LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK -SZ_ERROR_DATA - Data error -SZ_ERROR_MEM - Memory allocation error -SZ_ERROR_UNSUPPORTED - Unsupported properties -SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* LzmaDec.h -- LZMA Decoder + 2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __LZMA_DEC_H +#define __LZMA_DEC_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- LZMA Properties ---------- */ + +#define LZMA_PROPS_SIZE 5 + + typedef struct _CLzmaProps + { + unsigned lc, lp, pb; + uint32_t dicSize; + } CLzmaProps; + + /* LzmaProps_Decode - decodes properties +Returns: +SZ_OK +SZ_ERROR_UNSUPPORTED - Unsupported properties +*/ + + SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size); + + + /* ---------- LZMA Decoder state ---------- */ + + /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. + Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ + +#define LZMA_REQUIRED_INPUT_MAX 20 + + typedef struct + { + CLzmaProps prop; + uint16_t *probs; + uint8_t *dic; + const uint8_t *buf; + uint32_t range, code; + size_t dicPos; + size_t dicBufSize; + uint32_t processedPos; + uint32_t checkDicSize; + unsigned state; + uint32_t reps[4]; + unsigned remainLen; + int needFlush; + int needInitState; + uint32_t numProbs; + unsigned tempBufSize; + uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX]; + } CLzmaDec; + +#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } + + void LzmaDec_Init(CLzmaDec *p); + + /* There are two types of LZMA streams: + 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. + 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ + + typedef enum + { + LZMA_FINISH_ANY, /* finish at any point */ + LZMA_FINISH_END /* block must be finished at the end */ + } ELzmaFinishMode; + + /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! + + You must use LZMA_FINISH_END, when you know that current output buffer + covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. + + If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, + and output value of destLen will be less than output buffer size limit. + You can check status result also. + + You can use multiple checks to test data integrity after full decompression: + 1) Check Result and "status" variable. + 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. + 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. + You must use correct finish mode in that case. */ + + typedef enum + { + LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ + LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ + LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ + LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ + } ELzmaStatus; + + /* ELzmaStatus is used only as output value for function call */ + + + /* ---------- Interfaces ---------- */ + + /* There are 3 levels of interfaces: + 1) Dictionary Interface + 2) Buffer Interface + 3) One Call Interface + You can select any of these interfaces, but don't mix functions from different + groups for same object. */ + + + /* There are two variants to allocate state for Dictionary Interface: + 1) LzmaDec_Allocate / LzmaDec_Free + 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs + You can use variant 2, if you set dictionary buffer manually. + For Buffer Interface you must always use variant 1. + + LzmaDec_Allocate* can return: + SZ_OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + */ + + SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc); + void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); + + SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc); + void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); + + /* ---------- Dictionary Interface ---------- */ + + /* You can use it, if you want to eliminate the overhead for data copying from + dictionary to some other external buffer. + You must work with CLzmaDec variables directly in this interface. + +STEPS: +LzmaDec_Constr() +LzmaDec_Allocate() +for (each new stream) +{ +LzmaDec_Init() +while (it needs more decompression) +{ +LzmaDec_DecodeToDic() +use data from CLzmaDec::dic and update CLzmaDec::dicPos +} +} +LzmaDec_Free() +*/ + + /* LzmaDec_DecodeToDic + + The decoding to internal dictionary buffer (CLzmaDec::dic). + You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! + +finishMode: +It has meaning only if the decoding reaches output limit (dicLimit). +LZMA_FINISH_ANY - Decode just dicLimit bytes. +LZMA_FINISH_END - Stream must be finished after dicLimit. + +Returns: +SZ_OK +status: +LZMA_STATUS_FINISHED_WITH_MARK +LZMA_STATUS_NOT_FINISHED +LZMA_STATUS_NEEDS_MORE_INPUT +LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK +SZ_ERROR_DATA - Data error +*/ + + SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- Buffer Interface ---------- */ + +/* It's zlib-like interface. + See LzmaDec_DecodeToDic description for information about STEPS and return results, + but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need + to work with CLzmaDec variables manually. + +finishMode: +It has meaning only if the decoding reaches output limit (*destLen). +LZMA_FINISH_ANY - Decode just destLen bytes. +LZMA_FINISH_END - Stream must be finished after (*destLen). +*/ + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- One Call Interface ---------- */ + +/* LzmaDecode + +finishMode: +It has meaning only if the decoding reaches output limit (*destLen). +LZMA_FINISH_ANY - Decode just destLen bytes. +LZMA_FINISH_END - Stream must be finished after (*destLen). + +Returns: +SZ_OK +status: +LZMA_STATUS_FINISHED_WITH_MARK +LZMA_STATUS_NOT_FINISHED +LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK +SZ_ERROR_DATA - Data error +SZ_ERROR_MEM - Memory allocation error +SZ_ERROR_UNSUPPORTED - Unsupported properties +SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +*/ + +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzmaEnc.c b/deps/7zip/LzmaEnc.c index 6ea4395a3b..d66c0acb08 100644 --- a/deps/7zip/LzmaEnc.c +++ b/deps/7zip/LzmaEnc.c @@ -50,7 +50,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) int level = p->level; if (level < 0) level = 5; p->level = level; - + if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); if (p->dictSize > p->reduceSize) { @@ -71,7 +71,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); if (p->numHashBytes < 0) p->numHashBytes = 4; if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); - + if (p->numThreads < 0) p->numThreads = #ifndef _7ZIP_ST @@ -99,7 +99,7 @@ static void LzmaEnc_FastPosInit(unsigned char *g_FastPos) g_FastPos[0] = 0; g_FastPos[1] = 1; g_FastPos += 2; - + for (slot = 2; slot < kNumLogBits * 2; slot++) { size_t k = ((size_t)1 << ((slot >> 1) - 1)); @@ -236,7 +236,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; } CSaveState; @@ -272,7 +272,7 @@ typedef struct bool needInit; uint64_t nowPos64; - + uint32_t matchPriceCount; uint32_t alignPriceCount; @@ -293,9 +293,9 @@ typedef struct #ifndef _7ZIP_ST unsigned char pad[128]; #endif - + COptimal opt[kNumOpts]; - + unsigned char g_FastPos[1 << kNumLogBits]; uint32_t ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; @@ -315,7 +315,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; @@ -808,7 +808,7 @@ static uint32_t ReadMatchDistances(CLzmaEnc *p, uint32_t *numDistancePairsRes) uint32_t lenRes = 0, numPairs; p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - + if (numPairs > 0) { lenRes = p->matches[numPairs - 2]; @@ -893,10 +893,10 @@ static uint32_t Backward(CLzmaEnc *p, uint32_t *backRes, uint32_t cur) { uint32_t posPrev = posMem; uint32_t backCur = backMem; - + backMem = p->opt[posPrev].backPrev; posMem = p->opt[posPrev].posPrev; - + p->opt[posPrev].backPrev = backCur; p->opt[posPrev].posPrev = cur; cur = posPrev; @@ -932,7 +932,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) return lenRes; } p->optimumCurrentIndex = p->optimumEndIndex = 0; - + if (p->additionalOffset == 0) mainLen = ReadMatchDistances(p, &numPairs); else @@ -1223,7 +1223,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - + if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) { uint32_t shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); @@ -1285,7 +1285,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) } } } - + startLen = 2; /* speed optimization */ { uint32_t repIndex; @@ -1316,10 +1316,10 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) } while (--lenTest >= 2); lenTest = lenTestTemp; - + if (repIndex == 0) startLen = lenTest + 1; - + /* if (_maxMode) */ { uint32_t lenTest2 = lenTest + 1; @@ -1343,7 +1343,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { uint32_t curAndLenPrice; @@ -1399,7 +1399,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; else curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; - + opt = &p->opt[cur + lenTest]; if (curAndLenPrice < opt->price) { @@ -1434,7 +1434,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { uint32_t offset = cur + lenTest + 1 + lenTest2; @@ -1546,7 +1546,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes) MovePos(p, repLen - 1); return repLen; } - + if (mainLen < 2 || numAvail <= 2) return 1; @@ -1560,7 +1560,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes) (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) return 1; } - + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; for (i = 0; i < LZMA_NUM_REPS; i++) { @@ -1660,7 +1660,7 @@ void LzmaEnc_Construct(CLzmaEnc *p) { RangeEnc_Construct(&p->rc); MatchFinder_Construct(&p->matchFinderBase); - + #ifndef _7ZIP_ST MatchFinderMt_Construct(&p->matchFinderMt); p->matchFinderMt.MatchFinder = &p->matchFinderBase; @@ -1701,7 +1701,7 @@ void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) #ifndef _7ZIP_ST MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); #endif - + MatchFinder_Free(&p->matchFinderBase, allocBig); LzmaEnc_FreeLits(p, alloc); RangeEnc_Free(&p->rc, alloc); @@ -1816,7 +1816,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSi pos -= LZMA_NUM_REPS; GetPosSlot(pos, posSlot); RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); - + if (posSlot >= kStartPosModelIndex) { uint32_t footerBits = ((posSlot >> 1) - 1); @@ -1919,7 +1919,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, p->matchFinderObj = &p->matchFinderBase; MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); } - + return SZ_OK; } @@ -2123,7 +2123,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, bool reInit, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_CodeOneBlock(p, true, desiredPackSize, *unpackSize); - + *unpackSize = (uint32_t)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; if (outStream.overflow) @@ -2158,7 +2158,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) } } } - + LzmaEnc_Finish(p); return res; @@ -2218,7 +2218,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, unsigned char *dest, size_t *destLen, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); - + if (res == SZ_OK) { res = LzmaEnc_Encode2(p, progress); diff --git a/deps/SPIRV-Cross/GLSL.std.450.h b/deps/SPIRV-Cross/GLSL.std.450.h index 54cc00e9a8..943fd8650f 100644 --- a/deps/SPIRV-Cross/GLSL.std.450.h +++ b/deps/SPIRV-Cross/GLSL.std.450.h @@ -13,7 +13,7 @@ ** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/deps/glslang/glslang/SPIRV/GLSL.std.450.h b/deps/glslang/glslang/SPIRV/GLSL.std.450.h index df31092bec..86d3da8065 100755 --- a/deps/glslang/glslang/SPIRV/GLSL.std.450.h +++ b/deps/glslang/glslang/SPIRV/GLSL.std.450.h @@ -13,7 +13,7 @@ ** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/deps/glslang/glslang/SPIRV/SPVRemapper.h b/deps/glslang/glslang/SPIRV/SPVRemapper.h index b3c686aae5..ee5f63c653 100755 --- a/deps/glslang/glslang/SPIRV/SPVRemapper.h +++ b/deps/glslang/glslang/SPIRV/SPVRemapper.h @@ -112,7 +112,7 @@ class spirvbin_t : public spirvbin_base_t { public: spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose) { } - + // remap on an existing binary in memory void remap(std::vector& spv, std::uint32_t opts = DO_EVERYTHING); @@ -175,7 +175,7 @@ private: range_t constRange(spv::Op opCode) const; unsigned typeSizeInWords(spv::Id id) const; unsigned idTypeSizeInWords(spv::Id id) const; - + spv::Id& asId(unsigned word) { return spv[word]; } const spv::Id& asId(unsigned word) const { return spv[word]; } spv::Op asOpCode(unsigned word) const { return opOpCode(spv[word]); } @@ -241,7 +241,7 @@ private: void mapRemainder(); // map any IDs we haven't touched yet void stripDebug(); // strip debug info void strip(); // remove debug symbols - + std::vector spv; // SPIR words namemap_t nameMap; // ID names from OpName @@ -268,11 +268,11 @@ private: // Which functions are called, anywhere in the module, with a call count std::unordered_map fnCalls; - + posmap_t typeConstPos; // word positions that define types & consts (ordered) posmap_rev_t idPosR; // reverse map from IDs to positions typesize_map_t idTypeSizeMap; // maps each ID to its type size, if known. - + std::vector idMapL; // ID {M}ap from {L}ocal to {G}lobal IDs spv::Id entryPoint; // module entry point diff --git a/deps/glslang/glslang/SPIRV/SpvBuilder.h b/deps/glslang/glslang/SPIRV/SpvBuilder.h index e8524b2b1b..ad5da5ffde 100755 --- a/deps/glslang/glslang/SPIRV/SpvBuilder.h +++ b/deps/glslang/glslang/SPIRV/SpvBuilder.h @@ -301,7 +301,7 @@ public: // Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'. // The type of the created vector is a vector of components of the same type as the scalar. // - // Note: One of the arguments will change, with the result coming back that way rather than + // Note: One of the arguments will change, with the result coming back that way rather than // through the return value. void promoteScalar(Decoration precision, Id& left, Id& right); diff --git a/deps/glslang/glslang/SPIRV/doc.h b/deps/glslang/glslang/SPIRV/doc.h index 743896ff4a..dfc5662667 100644 --- a/deps/glslang/glslang/SPIRV/doc.h +++ b/deps/glslang/glslang/SPIRV/doc.h @@ -195,7 +195,7 @@ public: // Parameterize a set of enumerants that form an enum class EnumDefinition : public EnumParameters { public: - EnumDefinition() : + EnumDefinition() : ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { } void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false) { diff --git a/deps/glslang/glslang/SPIRV/spvIR.h b/deps/glslang/glslang/SPIRV/spvIR.h index c584c9dcb4..88630f899c 100755 --- a/deps/glslang/glslang/SPIRV/spvIR.h +++ b/deps/glslang/glslang/SPIRV/spvIR.h @@ -36,9 +36,9 @@ // // Simple in-memory representation (IR) of SPIRV. Just for holding // Each function's CFG of blocks. Has this hierarchy: -// - Module, which is a list of -// - Function, which is a list of -// - Block, which is a list of +// - Module, which is a list of +// - Function, which is a list of +// - Block, which is a list of // - Instruction // @@ -65,7 +65,7 @@ const Id NoResult = 0; const Id NoType = 0; const Decoration NoPrecision = DecorationMax; -const MemorySemanticsMask MemorySemanticsAllMemory = +const MemorySemanticsMask MemorySemanticsAllMemory = (MemorySemanticsMask)(MemorySemanticsSequentiallyConsistentMask | MemorySemanticsUniformMemoryMask | MemorySemanticsSubgroupMemoryMask | @@ -229,7 +229,7 @@ protected: std::vector > localVariables; Function& parent; - // track whether this block is known to be uncreachable (not necessarily + // track whether this block is known to be uncreachable (not necessarily // true for all unreachable blocks, but should be set at least // for the extraneous ones introduced by the builder). bool unreachable; diff --git a/deps/glslang/glslang/StandAlone/Worklist.h b/deps/glslang/glslang/StandAlone/Worklist.h index 57dc0db7b2..cfa80a8321 100644 --- a/deps/glslang/glslang/StandAlone/Worklist.h +++ b/deps/glslang/glslang/StandAlone/Worklist.h @@ -59,21 +59,21 @@ namespace glslang { void add(TWorkItem* item) { GetGlobalLock(); - + worklist.push_back(item); - + ReleaseGlobalLock(); } - + bool remove(TWorkItem*& item) { GetGlobalLock(); - + if (worklist.empty()) return false; item = worklist.front(); worklist.pop_front(); - + ReleaseGlobalLock(); return true; diff --git a/deps/glslang/glslang/glslang/Include/BaseTypes.h b/deps/glslang/glslang/glslang/Include/BaseTypes.h index f707440672..38719306d0 100644 --- a/deps/glslang/glslang/glslang/Include/BaseTypes.h +++ b/deps/glslang/glslang/glslang/Include/BaseTypes.h @@ -84,7 +84,7 @@ enum TStorageQualifier { EvqUniform, // read only, shared with app EvqBuffer, // read/write, shared with app EvqShared, // compute shader's read/write 'shared' qualifier - + // parameters EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter @@ -212,7 +212,7 @@ enum TBuiltInVariable { }; // These will show up in error messages -__inline const char* GetStorageQualifierString(TStorageQualifier q) +__inline const char* GetStorageQualifierString(TStorageQualifier q) { switch (q) { case EvqTemporary: return "temp"; break; diff --git a/deps/glslang/glslang/glslang/Include/Common.h b/deps/glslang/glslang/glslang/Include/Common.h index a779c83e6a..e0af6b1ff1 100644 --- a/deps/glslang/glslang/glslang/Include/Common.h +++ b/deps/glslang/glslang/glslang/Include/Common.h @@ -56,7 +56,7 @@ std::string to_string(const T& val) { #if defined(_MSC_VER) && _MSC_VER < 1700 inline long long int strtoll (const char* str, char** endptr, int base) { - return _strtoi64(str, endptr, base); + return _strtoi64(str, endptr, base); } inline unsigned long long int strtoull (const char* str, char** endptr, int base) { @@ -168,7 +168,7 @@ public: template class TList : public std::list > { }; -template > +template > class TMap : public std::map > > { }; @@ -194,13 +194,13 @@ template T Max(const T a, const T b) { return a > b ? a : b; } inline const TString String(const int i, const int /*base*/ = 10) { char text[16]; // 32 bit ints are at most 10 digits in base 10 - + // we assume base 10 for all cases snprintf(text, sizeof(text), "%d", i); return text; } - + struct TSourceLoc { void init() { name = nullptr; string = 0; line = 0; column = 0; } // Returns the name if it exists. Otherwise, returns the string number. diff --git a/deps/glslang/glslang/glslang/Include/ConstantUnion.h b/deps/glslang/glslang/glslang/Include/ConstantUnion.h index ec6aff1171..18756f5ce0 100644 --- a/deps/glslang/glslang/glslang/Include/ConstantUnion.h +++ b/deps/glslang/glslang/glslang/Include/ConstantUnion.h @@ -46,14 +46,14 @@ public: TConstUnion() : iConst(0), type(EbtInt) { } void setIConst(int i) - { - iConst = i; + { + iConst = i; type = EbtInt; } void setUConst(unsigned int u) { - uConst = u; + uConst = u; type = EbtUint; } @@ -71,13 +71,13 @@ public: void setDConst(double d) { - dConst = d; + dConst = d; type = EbtDouble; } void setBConst(bool b) { - bConst = b; + bConst = b; type = EbtBool; } @@ -215,7 +215,7 @@ public: } bool operator>(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -250,7 +250,7 @@ public: } bool operator<(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -285,7 +285,7 @@ public: } TConstUnion operator+(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -301,7 +301,7 @@ public: } TConstUnion operator-(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -317,7 +317,7 @@ public: } TConstUnion operator*(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -325,7 +325,7 @@ public: case EbtInt64: returnValue.setI64Const(i64Const * constant.i64Const); break; case EbtUint: returnValue.setUConst(uConst * constant.uConst); break; case EbtUint64: returnValue.setU64Const(u64Const * constant.u64Const); break; - case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break; + case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break; default: assert(false && "Default missing"); } @@ -333,7 +333,7 @@ public: } TConstUnion operator%(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -348,7 +348,7 @@ public: } TConstUnion operator>>(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -394,7 +394,7 @@ public: } TConstUnion operator<<(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -440,7 +440,7 @@ public: } TConstUnion operator&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -455,7 +455,7 @@ public: } TConstUnion operator|(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -470,7 +470,7 @@ public: } TConstUnion operator^(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -485,7 +485,7 @@ public: } TConstUnion operator~() const - { + { TConstUnion returnValue; switch (type) { case EbtInt: returnValue.setIConst(~iConst); break; @@ -499,7 +499,7 @@ public: } TConstUnion operator&&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -511,7 +511,7 @@ public: } TConstUnion operator||(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -544,7 +544,7 @@ private: // One convenience is being able to use [] to go inside the array, instead // of C++ assuming it as an array of pointers to vectors. // -// General usage is that the size is known up front, and it is +// General usage is that the size is known up front, and it is // created once with the proper size. // class TConstUnionArray { diff --git a/deps/glslang/glslang/glslang/Include/InfoSink.h b/deps/glslang/glslang/glslang/Include/InfoSink.h index 0cbd99bdaa..54f1f3393c 100644 --- a/deps/glslang/glslang/glslang/Include/InfoSink.h +++ b/deps/glslang/glslang/glslang/Include/InfoSink.h @@ -74,9 +74,9 @@ public: TInfoSinkBase& operator<<(const char* s) { append(s); return *this; } TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; } TInfoSinkBase& operator<<(unsigned int n) { append(String(n)); return *this; } - TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size]; + TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size]; snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n); - append(buf); + append(buf); return *this; } TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; } TInfoSinkBase& operator+(const TString& t) { append(t); return *this; } @@ -113,20 +113,20 @@ public: append(s); append("\n"); } - + void setOutputStream(int output = 4) { outputStream = output; } protected: - void append(const char* s); + void append(const char* s); void append(int count, char c); void append(const TPersistString& t); void append(const TString& t); - void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2) + void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2) sink.reserve(sink.capacity() + sink.capacity() / 2); } void appendToStream(const char* s); TPersistString sink; diff --git a/deps/glslang/glslang/glslang/Include/PoolAlloc.h b/deps/glslang/glslang/glslang/Include/PoolAlloc.h index 635be79ef9..0aa2ab2c11 100644 --- a/deps/glslang/glslang/glslang/Include/PoolAlloc.h +++ b/deps/glslang/glslang/glslang/Include/PoolAlloc.h @@ -43,8 +43,8 @@ // // This header defines an allocator that can be used to efficiently -// allocate a large number of small requests for heap memory, with the -// intention that they are not individually deallocated, but rather +// allocate a large number of small requests for heap memory, with the +// intention that they are not individually deallocated, but rather // collectively deallocated at one time. // // This simultaneously @@ -70,7 +70,7 @@ namespace glslang { // If we are using guard blocks, we must track each individual // allocation. If we aren't using guard blocks, these // never get instantiated, so won't have any impact. -// +// class TAllocation { public: @@ -87,7 +87,7 @@ public: memset(postGuard(), guardBlockEndVal, guardBlockSize); # endif } - + void check() const { checkGuardBlock(preGuard(), guardBlockBeginVal, "before"); checkGuardBlock(postGuard(), guardBlockEndVal, "after"); @@ -100,7 +100,7 @@ public: inline static size_t allocationSize(size_t size) { return size + 2 * guardBlockSize + headerSize(); } - + // Offset from surrounding buffer to get to user data buffer. inline static unsigned char* offsetAllocation(unsigned char* m) { return m + guardBlockSize + headerSize(); @@ -123,16 +123,16 @@ private: const static unsigned char userDataFill; const static size_t guardBlockSize; -# ifdef GUARD_BLOCKS +# ifdef GUARD_BLOCKS inline static size_t headerSize() { return sizeof(TAllocation); } # else inline static size_t headerSize() { return 0; } # endif }; - + // // There are several stacks. One is to track the pushing and popping -// of the user, and not yet implemented. The others are simply a +// of the user, and not yet implemented. The others are simply a // repositories of free pages or used pages. // // Page stacks are linked together with a simple header at the beginning @@ -141,7 +141,7 @@ private: // re-use. // // The "page size" used is not, nor must it match, the underlying OS -// page size. But, having it be about that size or equal to a set of +// page size. But, having it be about that size or equal to a set of // pages is likely most optimal. // class TPoolAllocator { @@ -185,7 +185,7 @@ public: protected: friend struct tHeader; - + struct tHeader { tHeader(tHeader* nextPage, size_t pageCount) : #ifdef GUARD_BLOCKS @@ -227,7 +227,7 @@ protected: } size_t pageSize; // granularity of allocation from the OS - size_t alignment; // all returned allocations will be aligned at + size_t alignment; // all returned allocations will be aligned at // this granularity, which will be a power of 2 size_t alignmentMask; size_t headerSkip; // amount of memory to skip to make room for the @@ -278,7 +278,7 @@ public: typedef T& reference; typedef const T& const_reference; typedef T value_type; - template + template struct rebind { typedef pool_allocator other; }; @@ -292,9 +292,9 @@ public: template pool_allocator(const pool_allocator& p) : allocator(p.getAllocator()) { } - pointer allocate(size_type n) { + pointer allocate(size_type n) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } - pointer allocate(size_type n, const void*) { + pointer allocate(size_type n, const void*) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } void deallocate(void*, size_type) { } diff --git a/deps/glslang/glslang/glslang/Include/ResourceLimits.h b/deps/glslang/glslang/glslang/Include/ResourceLimits.h index e8c743d6b7..b9cadb9faf 100644 --- a/deps/glslang/glslang/glslang/Include/ResourceLimits.h +++ b/deps/glslang/glslang/glslang/Include/ResourceLimits.h @@ -81,7 +81,7 @@ struct TBuiltInResource { int maxComputeImageUniforms; int maxComputeAtomicCounters; int maxComputeAtomicCounterBuffers; - int maxVaryingComponents; + int maxVaryingComponents; int maxVertexOutputComponents; int maxGeometryInputComponents; int maxGeometryOutputComponents; diff --git a/deps/glslang/glslang/glslang/Include/ShHandle.h b/deps/glslang/glslang/glslang/Include/ShHandle.h index bfc97db8b2..1e24fdd933 100644 --- a/deps/glslang/glslang/glslang/Include/ShHandle.h +++ b/deps/glslang/glslang/glslang/Include/ShHandle.h @@ -43,7 +43,7 @@ // -#define SH_EXPORTING +#define SH_EXPORTING #include "../Public/ShaderLang.h" #include "../MachineIndependent/Versions.h" #include "InfoSink.h" @@ -73,7 +73,7 @@ public: TUniformMap() { } virtual ~TUniformMap() { } virtual TUniformMap* getAsUniformMap() { return this; } - virtual int getLocation(const char* name) = 0; + virtual int getLocation(const char* name) = 0; virtual TInfoSink& getInfoSink() { return infoSink; } TInfoSink infoSink; }; @@ -95,7 +95,7 @@ public: virtual TCompiler* getAsCompiler() { return this; } virtual bool linkable() { return haveValidObjectCode; } - + TInfoSink& infoSink; protected: TCompiler& operator=(TCompiler&); @@ -117,9 +117,9 @@ typedef glslang::TVector THandleList; class TLinker : public TShHandleBase { public: - TLinker(EShExecutable e, TInfoSink& iSink) : + TLinker(EShExecutable e, TInfoSink& iSink) : infoSink(iSink), - executable(e), + executable(e), haveReturnableObjectCode(false), appAttributeBindings(0), fixedAttributeBindings(0), @@ -147,7 +147,7 @@ protected: const ShBindingTable* fixedAttributeBindings; const int* excludedAttributes; int excludedCount; - ShBindingTable* uniformBindings; // created by the linker + ShBindingTable* uniformBindings; // created by the linker }; // @@ -155,7 +155,7 @@ protected: // and the machine dependent code. // // The machine dependent code should derive from the classes -// above. Then Construct*() and Delete*() will create and +// above. Then Construct*() and Delete*() will create and // destroy the machine dependent objects, which contain the // above machine independent information. // @@ -165,7 +165,7 @@ TShHandleBase* ConstructLinker(EShExecutable, int); TShHandleBase* ConstructBindings(); void DeleteLinker(TShHandleBase*); void DeleteBindingList(TShHandleBase* bindingList); - + TUniformMap* ConstructUniformMap(); void DeleteCompiler(TCompiler*); diff --git a/deps/glslang/glslang/glslang/Include/Types.h b/deps/glslang/glslang/glslang/Include/Types.h index 8745c7a942..7642df9be1 100644 --- a/deps/glslang/glslang/glslang/Include/Types.h +++ b/deps/glslang/glslang/glslang/Include/Types.h @@ -421,7 +421,7 @@ public: clearLayout(); } - // Drop just the storage qualification, which perhaps should + // Drop just the storage qualification, which perhaps should // never be done, as it is fundamentally inconsistent, but need to // explore what downstream consumers need. // E.g., in a deference, it is an inconsistency between: @@ -1067,7 +1067,7 @@ public: qualifier.storage = q; } // for explicit precision qualifier - TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0, + TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0, bool isVector = false) : basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr) diff --git a/deps/glslang/glslang/glslang/Include/intermediate.h b/deps/glslang/glslang/glslang/Include/intermediate.h index 8f7ffcc0da..ffdc82b003 100644 --- a/deps/glslang/glslang/glslang/Include/intermediate.h +++ b/deps/glslang/glslang/glslang/Include/intermediate.h @@ -38,7 +38,7 @@ // Definition of the in-memory high-level intermediate representation // of shaders. This is a tree that parser creates. // -// Nodes in the tree are defined as a hierarchy of classes derived from +// Nodes in the tree are defined as a hierarchy of classes derived from // TIntermNode. Each is a node in a tree. There is no preset branching factor; // each node can have it's own type of list of children. // @@ -66,14 +66,14 @@ enum TOperator { EOpNull, // if in a node, should only mean a node is still being built EOpSequence, // denotes a list of statements, or parameters, etc. EOpLinkerObjects, // for aggregate node of objects the linker may need, if not reference by the rest of the AST - EOpFunctionCall, + EOpFunctionCall, EOpFunction, // For function definition EOpParameters, // an aggregate listing the parameters to a function // // Unary operators // - + EOpNegative, EOpLogicalNot, EOpVectorLogicalNot, @@ -445,7 +445,7 @@ enum TOperator { // // moves // - + EOpAssign, EOpAddAssign, EOpSubAssign, @@ -708,7 +708,7 @@ public: virtual void setType(const TType& t) { type.shallowCopy(t); } virtual const TType& getType() const { return type; } virtual TType& getWritableType() { return type; } - + virtual TBasicType getBasicType() const { return type.getBasicType(); } virtual TQualifier& getQualifier() { return type.getQualifier(); } virtual const TQualifier& getQualifier() const { return type.getQualifier(); } @@ -733,7 +733,7 @@ protected: // class TIntermLoop : public TIntermNode { public: - TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : + TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : body(aBody), test(aTest), terminal(aTerminal), @@ -1147,7 +1147,7 @@ enum TVisit }; // -// For traversing the tree. User should derive from this, +// For traversing the tree. User should derive from this, // put their traversal specific data in it, and then pass // it to a Traverse method. // @@ -1159,10 +1159,10 @@ enum TVisit // the subtree). Similarly for inVisit for in-order visiting of nodes with // multiple children. // -// If you only want post-visits, explicitly turn off preVisit (and inVisit) +// If you only want post-visits, explicitly turn off preVisit (and inVisit) // and turn on postVisit. // -// In general, for the visit*() methods, return true from interior nodes +// In general, for the visit*() methods, return true from interior nodes // to have the traversal continue on to children. // // If you process children yourself, or don't want them processed, return false. diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h b/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h index 23f57acc17..a61c6b408a 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h @@ -67,7 +67,7 @@ public: virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; } virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0; - + virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0; protected: @@ -89,7 +89,7 @@ public: void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); - + void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); protected: diff --git a/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h b/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h index 6234db6095..30f2d9a822 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h @@ -449,7 +449,7 @@ protected: // * note, that appropriately gives an error if redeclaring a block that // was already used and hence already copied-up // - // - on seeing a layout declaration that sizes the array, fix everything in the + // - on seeing a layout declaration that sizes the array, fix everything in the // resize-list, giving errors for mismatch // // - on seeing an array size declaration, give errors on mismatch between it and previous diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h index 67c86d2efe..fe747ef431 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h @@ -254,7 +254,7 @@ protected: size_t currentChar; // This is for reporting what string/line an error occurred on, and can be overridden by #line. - // It remembers the last state of each source string as it is left for the next one, so unget() + // It remembers the last state of each source string as it is left for the next one, so unget() // can restore that state. TSourceLoc* loc; // an array diff --git a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h index aeec34fc02..9f5a2e69f5 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h @@ -120,7 +120,7 @@ protected: const TString *name; unsigned int uniqueId; // For cross-scope comparing during code generation - // For tracking what extensions must be present + // For tracking what extensions must be present // (don't use if correct version/profile is present). int numExtensions; const char** extensions; // an array of pointers to existing constant char strings @@ -145,7 +145,7 @@ protected: class TVariable : public TSymbol { public: TVariable(const TString *name, const TType& t, bool uT = false ) - : TSymbol(name), + : TSymbol(name), userType(uT), constSubtree(nullptr), anonId(-1) { type.shallowCopy(t); } @@ -191,7 +191,7 @@ protected: struct TParameter { TString *name; TType* type; - void copyParam(const TParameter& param) + void copyParam(const TParameter& param) { if (param.name) name = NewPoolTString(param.name->c_str()); @@ -272,7 +272,7 @@ public: virtual const TAnonMember* getAsAnonMember() const { return this; } virtual const TVariable& getAnonContainer() const { return anonContainer; } virtual unsigned int getMemberNumber() const { return memberNumber; } - + virtual const TType& getType() const { const TTypeList& types = *anonContainer.getType().getStruct(); @@ -285,7 +285,7 @@ public: const TTypeList& types = *anonContainer.getType().getStruct(); return *types[memberNumber].type; } - + virtual int getAnonId() const { return anonId; } virtual void dump(TInfoSink &infoSink) const; @@ -365,7 +365,7 @@ public: TSymbol* find(const TString& name) const { tLevel::const_iterator it = level.find(name); - if (it == level.end()) + if (it == level.end()) return 0; else return (*it).second; @@ -488,7 +488,7 @@ public: while (table.size() > adoptedLevels) pop(0); } - + void adoptLevels(TSymbolTable& symTable) { for (unsigned int level = 0; level < symTable.table.size(); ++level) { @@ -520,7 +520,7 @@ public: void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; } void setSeparateNameSpaces() { separateNameSpaces = true; } - + void push() { table.push_back(new TSymbolTableLevel); @@ -546,7 +546,7 @@ public: // make sure there isn't a function of this variable name if (! separateNameSpaces && ! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName())) return false; - + // check for not overloading or redefining a built-in function if (noBuiltInRedeclarations) { if (atGlobalLevel() && currentLevel() > 0) { @@ -570,7 +570,7 @@ public: // // To allocate an internal temporary, which will need to be uniquely - // identified by the consumer of the AST, but never need to + // identified by the consumer of the AST, but never need to // found by doing a symbol table search by name, hence allowed an // arbitrary name in the symbol with no worry of collision. // @@ -672,7 +672,7 @@ public: for (unsigned int level = 0; level < table.size(); ++level) table[level]->relateToOperator(name, op); } - + void setFunctionExtensions(const char* name, int num, const char* const extensions[]) { for (unsigned int level = 0; level < table.size(); ++level) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h b/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h index b6d27993c9..a3a458bb77 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h @@ -1,19 +1,19 @@ /* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ diff --git a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h index 6f6db92d5f..57a2a70353 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h @@ -83,7 +83,7 @@ struct TCall { // A generic 1-D range. struct TRange { TRange(int start, int last) : start(start), last(last) { } - bool overlap(const TRange& rhs) const + bool overlap(const TRange& rhs) const { return last >= rhs.start && start <= rhs.last; } @@ -188,7 +188,7 @@ public: bool getFlattenUniformArrays() const { return flattenUniformArrays; } void setNoStorageFormat(bool b) { useUnknownFormat = b; } bool getNoStorageFormat() const { return useUnknownFormat; } - + void setVersion(int v) { version = v; } int getVersion() const { return version; } void setProfile(EProfile p) { profile = p; } @@ -269,7 +269,7 @@ public: void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&); void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&); - bool setInvocations(int i) + bool setInvocations(int i) { if (invocations != TQualifier::layoutNotSet) return invocations == i; @@ -311,7 +311,7 @@ public: TVertexOrder getVertexOrder() const { return vertexOrder; } void setPointMode() { pointMode = true; } bool getPointMode() const { return pointMode; } - + bool setLocalSize(int dim, int size) { if (localSize[dim] > 1) @@ -406,7 +406,7 @@ protected: bool promoteBinary(TIntermBinary&); void addSymbolLinkageNode(TIntermAggregate*& linkage, TSymbolTable&, const TString&); bool promoteAggregate(TIntermAggregate&); - + const EShLanguage language; // stage, known at construction time EShSource source; // source language, known a bit later std::string entryPointName; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h index 013c90e567..f1c2f31108 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h @@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses express or implied, are granted by NVIDIA herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. +incorporated. No hardware is licensed hereunder. THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, @@ -94,7 +94,7 @@ class TPpToken { public: TPpToken() : token(0), space(false), ival(0), dval(0.0), atom(0) { - loc.init(); + loc.init(); name[0] = 0; } @@ -239,7 +239,7 @@ protected: static const int maxMacroArgs = 64; static const int maxIfNesting = 64; - int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor) + int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor) bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth int elsetracker; // #if-#else and #endif constructs...Counter. @@ -301,11 +301,11 @@ protected: int extraTokenCheck(int atom, TPpToken* ppToken, int token); int eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken * ppToken); int evalToToken(int token, bool shortCircuit, int& res, bool& err, TPpToken * ppToken); - int CPPif (TPpToken * ppToken); + int CPPif (TPpToken * ppToken); int CPPifdef(int defined, TPpToken * ppToken); int CPPinclude(TPpToken * ppToken); - int CPPline(TPpToken * ppToken); - int CPPerror(TPpToken * ppToken); + int CPPline(TPpToken * ppToken); + int CPPerror(TPpToken * ppToken); int CPPpragma(TPpToken * ppToken); int CPPversion(TPpToken * ppToken); int CPPextension(TPpToken * ppToken); @@ -331,7 +331,7 @@ protected: int ReadToken(TokenStream* pTok, TPpToken* ppToken); void pushTokenStreamInput(TokenStream *ts); void UngetToken(int token, TPpToken* ppToken); - + class tTokenInput : public tInput { public: tTokenInput(TPpContext* pp, TokenStream* t) : tInput(pp), tokens(t) { } @@ -387,7 +387,7 @@ protected: return '\\'; } while (ch == '\\'); } - + // handle any non-escaped newline if (ch == '\r' || ch == '\n') { if (ch == '\r' && input->peek() == '\n') @@ -432,7 +432,7 @@ protected: TInputScanner* input; }; - // Holds a reference to included file data, as well as a + // Holds a reference to included file data, as well as a // prologue and an epilogue string. This can be scanned using the tInput // interface and acts as a single source string. class TokenizableIncludeFile : public tInput { diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h index c84431d368..2d231e1d2d 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h @@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses express or implied, are granted by NVIDIA herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. +incorporated. No hardware is licensed hereunder. THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, @@ -128,7 +128,7 @@ enum EFixedAtoms { #endif PpAtomConstString, - // Identifiers + // Identifiers PpAtomIdentifier, // preprocessor "keywords" diff --git a/deps/glslang/glslang/glslang/MachineIndependent/reflection.h b/deps/glslang/glslang/glslang/MachineIndependent/reflection.h index 13f5177c0f..b6bf4a9b02 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/reflection.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/reflection.h @@ -55,7 +55,7 @@ class TReflectionTraverser; // Data needed for just a single object at the granularity exchanged by the reflection API class TObjectReflection { public: - TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) : + TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) : name(pName), type(pType.clone()), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex) { } @@ -107,7 +107,7 @@ public: // for mapping a block index to the block's description int getNumUniformBlocks() const { return (int)indexToUniformBlock.size(); } - const TObjectReflection& getUniformBlock(int i) const + const TObjectReflection& getUniformBlock(int i) const { if (i >= 0 && i < (int)indexToUniformBlock.size()) return indexToUniformBlock[i]; @@ -126,7 +126,7 @@ public: } // for mapping any name to its index (block names, uniform names and attribute names) - int getIndex(const char* name) const + int getIndex(const char* name) const { TNameToIndex::const_iterator it = nameToIndex.find(name); if (it == nameToIndex.end()) diff --git a/deps/glslang/glslang/glslang/Public/ShaderLang.h b/deps/glslang/glslang/glslang/Public/ShaderLang.h index afdc7d1eb2..4e4d695c69 100644 --- a/deps/glslang/glslang/glslang/Public/ShaderLang.h +++ b/deps/glslang/glslang/glslang/Public/ShaderLang.h @@ -165,9 +165,9 @@ typedef struct { // // ShHandle held by but opaque to the driver. It is allocated, -// managed, and de-allocated by the compiler/linker. It's contents +// managed, and de-allocated by the compiler/linker. It's contents // are defined by and used by the compiler and linker. For example, -// symbol table information and object code passed from the compiler +// symbol table information and object code passed from the compiler // to the linker can be stored where ShHandle points. // // If handle creation fails, 0 will be returned. @@ -187,7 +187,7 @@ SH_IMPORT_EXPORT void ShDestruct(ShHandle); // The return value of ShCompile is boolean, non-zero indicating // success. // -// The info-log should be written by ShCompile into +// The info-log should be written by ShCompile into // ShHandle, so it can answer future queries. // SH_IMPORT_EXPORT int ShCompile( @@ -251,8 +251,8 @@ SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* // ----------------------------------- // // Below is a new alternate C++ interface that might potentially replace the above -// opaque handle-based interface. -// +// opaque handle-based interface. +// // The below is further designed to handle multiple compilation units per stage, where // the intermediate results, including the parse tree, are preserved until link time, // rather than the above interface which is designed to have each compilation unit @@ -513,7 +513,7 @@ public: const char *getAttributeName(int index) const; // can be used for glGetActiveAttrib() int getAttributeType(int index) const; // can be used for glGetActiveAttrib() const TType* getUniformTType(int index) const; // returns a TType* - const TType* getUniformBlockTType(int index) const; // returns a TType* + const TType* getUniformBlockTType(int index) const; // returns a TType* const TType* getAttributeTType(int index) const; // returns a TType* void dumpReflection(); diff --git a/deps/glslang/glslang/gtests/TestFixture.h b/deps/glslang/glslang/gtests/TestFixture.h index e795e8dc90..8aee0cf88e 100644 --- a/deps/glslang/glslang/gtests/TestFixture.h +++ b/deps/glslang/glslang/gtests/TestFixture.h @@ -258,7 +258,7 @@ public: glslang::TProgram program; program.addShader(&shader); - + success &= program.link(controls); success &= program.mapIO(); @@ -330,7 +330,7 @@ public: std::vector spirv_binary(code); // scratch copy spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions); - + std::ostringstream disassembly_stream; spv::Parameterize(); spv::Disassemble(disassembly_stream, spirv_binary); diff --git a/deps/glslang/glslang/hlsl/hlslGrammar.h b/deps/glslang/glslang/hlsl/hlslGrammar.h index 8804b217ec..ad124cb755 100755 --- a/deps/glslang/glslang/hlsl/hlslGrammar.h +++ b/deps/glslang/glslang/hlsl/hlslGrammar.h @@ -44,7 +44,7 @@ namespace glslang { class TAttributeMap; // forward declare - + // Should just be the grammar aspect of HLSL. // Described in more detail in hlslGrammar.cpp. diff --git a/deps/glslang/glslang/hlsl/hlslParseHelper.h b/deps/glslang/glslang/hlsl/hlslParseHelper.h index 206df9b887..1de4f36d03 100755 --- a/deps/glslang/glslang/hlsl/hlslParseHelper.h +++ b/deps/glslang/glslang/hlsl/hlslParseHelper.h @@ -263,7 +263,7 @@ protected: // * note, that appropriately gives an error if redeclaring a block that // was already used and hence already copied-up // - // - on seeing a layout declaration that sizes the array, fix everything in the + // - on seeing a layout declaration that sizes the array, fix everything in the // resize-list, giving errors for mismatch // // - on seeing an array size declaration, give errors on mismatch between it and previous diff --git a/deps/glslang/glslang/hlsl/hlslParseables.h b/deps/glslang/glslang/hlsl/hlslParseables.h index c837590030..3c93b178e6 100755 --- a/deps/glslang/glslang/hlsl/hlslParseables.h +++ b/deps/glslang/glslang/hlsl/hlslParseables.h @@ -52,7 +52,7 @@ public: void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); - + void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); private: diff --git a/deps/glslang/glslang/hlsl/hlslTokens.h b/deps/glslang/glslang/hlsl/hlslTokens.h index 6902070cbe..cfa63b7cfe 100755 --- a/deps/glslang/glslang/hlsl/hlslTokens.h +++ b/deps/glslang/glslang/hlsl/hlslTokens.h @@ -247,7 +247,7 @@ enum EHlslTokenClass { EHTokRWTexture2darray, EHTokRWTexture3d, EHTokRWBuffer, - + // variable, user type, ... EHTokIdentifier, diff --git a/deps/ibxm/ibxm.c b/deps/ibxm/ibxm.c index 526cfd6875..2097cedc12 100644 --- a/deps/ibxm/ibxm.c +++ b/deps/ibxm/ibxm.c @@ -1,1922 +1,1922 @@ - -#include "stdlib.h" -#include "string.h" - -#include "ibxm.h" - -const char *IBXM_VERSION = "ibxm/ac mod/xm/s3m replay 20170901 (c)mumart@gmail.com"; - -static const int FP_SHIFT = 15, FP_ONE = 32768, FP_MASK = 32767; - -static const int exp2_table[] = { - 32768, 32946, 33125, 33305, 33486, 33667, 33850, 34034, - 34219, 34405, 34591, 34779, 34968, 35158, 35349, 35541, - 35734, 35928, 36123, 36319, 36516, 36715, 36914, 37114, - 37316, 37518, 37722, 37927, 38133, 38340, 38548, 38757, - 38968, 39180, 39392, 39606, 39821, 40037, 40255, 40473, - 40693, 40914, 41136, 41360, 41584, 41810, 42037, 42265, - 42495, 42726, 42958, 43191, 43425, 43661, 43898, 44137, - 44376, 44617, 44859, 45103, 45348, 45594, 45842, 46091, - 46341, 46593, 46846, 47100, 47356, 47613, 47871, 48131, - 48393, 48655, 48920, 49185, 49452, 49721, 49991, 50262, - 50535, 50810, 51085, 51363, 51642, 51922, 52204, 52488, - 52773, 53059, 53347, 53637, 53928, 54221, 54515, 54811, - 55109, 55408, 55709, 56012, 56316, 56622, 56929, 57238, - 57549, 57861, 58176, 58491, 58809, 59128, 59449, 59772, - 60097, 60423, 60751, 61081, 61413, 61746, 62081, 62419, - 62757, 63098, 63441, 63785, 64132, 64480, 64830, 65182, - 65536 -}; - -static const short sine_table[] = { - 0, 24, 49, 74, 97, 120, 141, 161, 180, 197, 212, 224, 235, 244, 250, 253, - 255, 253, 250, 244, 235, 224, 212, 197, 180, 161, 141, 120, 97, 74, 49, 24 -}; - -struct note { - unsigned char key, instrument, volume, effect, param; -}; - -struct channel { - struct replay *replay; - struct instrument *instrument; - struct sample *sample; - struct note note; - int id, key_on, random_seed, pl_row; - int sample_off, sample_idx, sample_fra, freq, ampl, pann; - int volume, panning, fadeout_vol, vol_env_tick, pan_env_tick; - int period, porta_period, retrig_count, fx_count, av_count; - int porta_up_param, porta_down_param, tone_porta_param, offset_param; - int fine_porta_up_param, fine_porta_down_param, xfine_porta_param; - int arpeggio_param, vol_slide_param, gvol_slide_param, pan_slide_param; - int fine_vslide_up_param, fine_vslide_down_param; - int retrig_volume, retrig_ticks, tremor_on_ticks, tremor_off_ticks; - int vibrato_type, vibrato_phase, vibrato_speed, vibrato_depth; - int tremolo_type, tremolo_phase, tremolo_speed, tremolo_depth; - int tremolo_add, vibrato_add, arpeggio_add; -}; - -struct replay { - int sample_rate, interpolation, global_vol; - int seq_pos, break_pos, row, next_row, tick; - int speed, tempo, pl_count, pl_chan; - int *ramp_buf; - char **play_count; - struct channel *channels; - struct module *module; -}; - -static int exp_2( int x ) { - int c, m, y; - int x0 = ( x & FP_MASK ) >> ( FP_SHIFT - 7 ); - c = exp2_table[ x0 ]; - m = exp2_table[ x0 + 1 ] - c; - y = ( m * ( x & ( FP_MASK >> 7 ) ) >> 8 ) + c; - return ( y << FP_SHIFT ) >> ( FP_SHIFT - ( x >> FP_SHIFT ) ); -} - -static int log_2( int x ) { - int step; - int y = 16 << FP_SHIFT; - for( step = y; step > 0; step >>= 1 ) { - if( exp_2( y - step ) >= x ) { - y -= step; - } - } - return y; -} - -static char* data_ascii( struct data *data, int offset, int length, char *dest ) { - int idx, chr; - memset( dest, 32, length ); - if( offset > data->length ) { - offset = data->length; - } - if( ( unsigned int ) offset + length > ( unsigned int ) data->length ) { - length = data->length - offset; - } - for( idx = 0; idx < length; idx++ ) { - chr = data->buffer[ offset + idx ] & 0xFF; - if( chr > 32 ) { - dest[ idx ] = chr; - } - } - return dest; -} - -static int data_s8( struct data *data, int offset ) { - int value = 0; - if( offset < data->length ) { - value = data->buffer[ offset ]; - value = ( value & 0x7F ) - ( value & 0x80 ); - } - return value; -} - -static int data_u8( struct data *data, int offset ) { - int value = 0; - if( offset < data->length ) { - value = data->buffer[ offset ] & 0xFF; - } - return value; -} - -static int data_u16be( struct data *data, int offset ) { - int value = 0; - if( offset + 1 < data->length ) { - value = ( ( data->buffer[ offset ] & 0xFF ) << 8 ) - | ( data->buffer[ offset + 1 ] & 0xFF ); - } - return value; -} - -static int data_u16le( struct data *data, int offset ) { - int value = 0; - if( offset + 1 < data->length ) { - value = ( data->buffer[ offset ] & 0xFF ) - | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ); - } - return value; -} - -static unsigned int data_u32le( struct data *data, int offset ) { - unsigned int value = 0; - if( offset + 3 < data->length ) { - value = ( data->buffer[ offset ] & 0xFF ) - | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ) - | ( ( data->buffer[ offset + 2 ] & 0xFF ) << 16 ) - | ( ( data->buffer[ offset + 3 ] & 0xFF ) << 24 ); - } - return value; -} - -static void data_sam_s8( struct data *data, int offset, int count, short *dest ) { - int idx, amp, length = data->length; - char *buffer = data->buffer; - if( offset > length ) { - offset = length; - } - if( offset + count > length ) { - count = length - offset; - } - for( idx = 0; idx < count; idx++ ) { - amp = ( buffer[ offset + idx ] & 0xFF ) << 8; - dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - } -} - -static void data_sam_s16le( struct data *data, int offset, int count, short *dest ) { - int idx, amp, length = data->length; - char *buffer = data->buffer; - if( offset > length ) { - offset = length; - } - if( offset + count * 2 > length ) { - count = ( length - offset ) / 2; - } - for( idx = 0; idx < count; idx++ ) { - amp = ( buffer[ offset + idx * 2 ] & 0xFF ) | ( buffer[ offset + idx * 2 + 1 ] << 8 ); - dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - } -} - -static int envelope_next_tick( struct envelope *envelope, int tick, int key_on ) { - tick++; - if( envelope->looped && tick >= envelope->loop_end_tick ) { - tick = envelope->loop_start_tick; - } - if( envelope->sustain && key_on && tick >= envelope->sustain_tick ) { - tick = envelope->sustain_tick; - } - return tick; -} - -static int envelope_calculate_ampl( struct envelope *envelope, int tick ) { - int idx, point, dt, da; - int ampl = envelope->points_ampl[ envelope->num_points - 1 ]; - if( tick < envelope->points_tick[ envelope->num_points - 1 ] ) { - point = 0; - for( idx = 1; idx < envelope->num_points; idx++ ) { - if( envelope->points_tick[ idx ] <= tick ) { - point = idx; - } - } - dt = envelope->points_tick[ point + 1 ] - envelope->points_tick[ point ]; - da = envelope->points_ampl[ point + 1 ] - envelope->points_ampl[ point ]; - ampl = envelope->points_ampl[ point ]; - ampl += ( ( da << 24 ) / dt ) * ( tick - envelope->points_tick[ point ] ) >> 24; - } - return ampl; -} - -static void sample_ping_pong( struct sample *sample ) { - int idx; - int loop_start = sample->loop_start; - int loop_length = sample->loop_length; - int loop_end = loop_start + loop_length; - short *sample_data = sample->data; - short *new_data = (short*)calloc( loop_end + loop_length + 1, sizeof( short ) ); - if( new_data ) { - memcpy( new_data, sample_data, loop_end * sizeof( short ) ); - for( idx = 0; idx < loop_length; idx++ ) { - new_data[ loop_end + idx ] = sample_data[ loop_end - idx - 1 ]; - } - free( sample->data ); - sample->data = new_data; - sample->loop_length *= 2; - sample->data[ loop_start + sample->loop_length ] = sample->data[ loop_start ]; - } -} - -/* Deallocate the specified module. */ -void dispose_module( struct module *module ) { - int idx, sam; - struct instrument *instrument; - free( module->default_panning ); - free( module->sequence ); - if( module->patterns ) { - for( idx = 0; idx < module->num_patterns; idx++ ) { - free( module->patterns[ idx ].data ); - } - free( module->patterns ); - } - if( module->instruments ) { - for( idx = 0; idx <= module->num_instruments; idx++ ) { - instrument = &module->instruments[ idx ]; - if( instrument->samples ) { - for( sam = 0; sam < instrument->num_samples; sam++ ) { - free( instrument->samples[ sam ].data ); - } - free( instrument->samples ); - } - } - free( module->instruments ); - } - free( module ); -} - -static struct module* module_load_xm( struct data *data, char *message ) { - int delta_env, offset, next_offset, idx, entry; - int num_rows, num_notes, pat_data_len, pat_data_offset; - int sam, sam_head_offset, sam_data_bytes, sam_data_samples; - int num_samples, sam_loop_start, sam_loop_length, amp; - int note, flags, key, ins, vol, fxc, fxp; - int point, point_tick, point_offset; - int looped, ping_pong, sixteen_bit; - char ascii[ 16 ], *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - if( data_u16le( data, 58 ) != 0x0104 ) { - strcpy( message, "XM format version must be 0x0104!" ); - dispose_module( module ); - return NULL; - } - data_ascii( data, 17, 20, module->name ); - delta_env = !memcmp( data_ascii( data, 38, 15, ascii ), "DigiBooster Pro", 15 ); - offset = 60 + data_u32le( data, 60 ); - module->sequence_len = data_u16le( data, 64 ); - module->restart_pos = data_u16le( data, 66 ); - module->num_channels = data_u16le( data, 68 ); - module->num_patterns = data_u16le( data, 70 ); - module->num_instruments = data_u16le( data, 72 ); - module->linear_periods = data_u16le( data, 74 ) & 0x1; - module->default_gvol = 64; - module->default_speed = data_u16le( data, 76 ); - module->default_tempo = data_u16le( data, 78 ); - module->c2_rate = 8363; - module->gain = 64; - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( !module->default_panning ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - module->default_panning[ idx ] = 128; - } - module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); - if( !module->sequence ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->sequence_len; idx++ ) { - entry = data_u8( data, 80 + idx ); - module->sequence[ idx ] = entry < module->num_patterns ? entry : 0; - } - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_patterns; idx++ ) { - if( data_u8( data, offset + 4 ) ) { - strcpy( message, "Unknown pattern packing type!" ); - dispose_module( module ); - return NULL; - } - num_rows = data_u16le( data, offset + 5 ); - if( num_rows < 1 ) { - num_rows = 1; - } - pat_data_len = data_u16le( data, offset + 7 ); - offset += data_u32le( data, offset ); - next_offset = offset + pat_data_len; - num_notes = num_rows * module->num_channels; - pattern_data = (char*)calloc( num_notes, 5 ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ idx ].num_channels = module->num_channels; - module->patterns[ idx ].num_rows = num_rows; - module->patterns[ idx ].data = pattern_data; - if( pat_data_len > 0 ) { - pat_data_offset = 0; - for( note = 0; note < num_notes; note++ ) { - flags = data_u8( data, offset ); - if( ( flags & 0x80 ) == 0 ) { - flags = 0x1F; - } else { - offset++; - } - key = ( flags & 0x01 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = key; - ins = ( flags & 0x02 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = ins; - vol = ( flags & 0x04 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = vol; - fxc = ( flags & 0x08 ) > 0 ? data_u8( data, offset++ ) : 0; - fxp = ( flags & 0x10 ) > 0 ? data_u8( data, offset++ ) : 0; - if( fxc >= 0x40 ) { - fxc = fxp = 0; - } - pattern_data[ pat_data_offset++ ] = fxc; - pattern_data[ pat_data_offset++ ] = fxp; - } - } - offset = next_offset; - } - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - data_ascii( data, offset + 4, 22, instrument->name ); - num_samples = data_u16le( data, offset + 27 ); - instrument->num_samples = ( num_samples > 0 ) ? num_samples : 1; - instrument->samples = (struct sample*)calloc( instrument->num_samples, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - if( num_samples > 0 ) { - for( key = 0; key < 96; key++ ) { - instrument->key_to_sample[ key + 1 ] = data_u8( data, offset + 33 + key ); - } - point_tick = 0; - for( point = 0; point < 12; point++ ) { - point_offset = offset + 129 + ( point * 4 ); - point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); - instrument->vol_env.points_tick[ point ] = point_tick; - instrument->vol_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); - } - point_tick = 0; - for( point = 0; point < 12; point++ ) { - point_offset = offset + 177 + ( point * 4 ); - point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); - instrument->pan_env.points_tick[ point ] = point_tick; - instrument->pan_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); - } - instrument->vol_env.num_points = data_u8( data, offset + 225 ); - if( instrument->vol_env.num_points > 12 ) { - instrument->vol_env.num_points = 0; - } - instrument->pan_env.num_points = data_u8( data, offset + 226 ); - if( instrument->pan_env.num_points > 12 ) { - instrument->pan_env.num_points = 0; - } - instrument->vol_env.sustain_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 227 ) & 0xF ]; - instrument->vol_env.loop_start_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 228 ) & 0xF ]; - instrument->vol_env.loop_end_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 229 ) & 0xF ]; - instrument->pan_env.sustain_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 230 ) & 0xF ]; - instrument->pan_env.loop_start_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 231 ) & 0xF ]; - instrument->pan_env.loop_end_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 232 ) & 0xF ]; - instrument->vol_env.enabled = instrument->vol_env.num_points > 0 && ( data_u8( data, offset + 233 ) & 0x1 ); - instrument->vol_env.sustain = ( data_u8( data, offset + 233 ) & 0x2 ) > 0; - instrument->vol_env.looped = ( data_u8( data, offset + 233 ) & 0x4 ) > 0; - instrument->pan_env.enabled = instrument->pan_env.num_points > 0 && ( data_u8( data, offset + 234 ) & 0x1 ); - instrument->pan_env.sustain = ( data_u8( data, offset + 234 ) & 0x2 ) > 0; - instrument->pan_env.looped = ( data_u8( data, offset + 234 ) & 0x4 ) > 0; - instrument->vib_type = data_u8( data, offset + 235 ); - instrument->vib_sweep = data_u8( data, offset + 236 ); - instrument->vib_depth = data_u8( data, offset + 237 ); - instrument->vib_rate = data_u8( data, offset + 238 ); - instrument->vol_fadeout = data_u16le( data, offset + 239 ); - } - offset += data_u32le( data, offset ); - sam_head_offset = offset; - offset += num_samples * 40; - for( sam = 0; sam < num_samples; sam++ ) { - sample = &instrument->samples[ sam ]; - sam_data_bytes = data_u32le( data, sam_head_offset ); - sam_loop_start = data_u32le( data, sam_head_offset + 4 ); - sam_loop_length = data_u32le( data, sam_head_offset + 8 ); - sample->volume = data_u8( data, sam_head_offset + 12 ); - sample->fine_tune = data_s8( data, sam_head_offset + 13 ); - looped = ( data_u8( data, sam_head_offset + 14 ) & 0x3 ) > 0; - ping_pong = ( data_u8( data, sam_head_offset + 14 ) & 0x2 ) > 0; - sixteen_bit = ( data_u8( data, sam_head_offset + 14 ) & 0x10 ) > 0; - sample->panning = data_u8( data, sam_head_offset + 15 ) + 1; - sample->rel_note = data_s8( data, sam_head_offset + 16 ); - data_ascii( data, sam_head_offset + 18, 22, sample->name ); - sam_head_offset += 40; - sam_data_samples = sam_data_bytes; - if( sixteen_bit ) { - sam_data_samples = sam_data_samples >> 1; - sam_loop_start = sam_loop_start >> 1; - sam_loop_length = sam_loop_length >> 1; - } - if( !looped || ( sam_loop_start + sam_loop_length ) > sam_data_samples ) { - sam_loop_start = sam_data_samples; - sam_loop_length = 0; - } - sample->loop_start = sam_loop_start; - sample->loop_length = sam_loop_length; - sample->data = (short*)calloc( sam_data_samples + 1, sizeof( short ) ); - if( sample->data ) { - if( sixteen_bit ) { - data_sam_s16le( data, offset, sam_data_samples, sample->data ); - } else { - data_sam_s8( data, offset, sam_data_samples, sample->data ); - } - amp = 0; - for( idx = 0; idx < sam_data_samples; idx++ ) { - amp = amp + sample->data[ idx ]; - amp = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - sample->data[ idx ] = amp; - } - sample->data[ sam_loop_start + sam_loop_length ] = sample->data[ sam_loop_start ]; - if( ping_pong ) { - sample_ping_pong( sample ); - } - } else { - dispose_module( module ); - return NULL; - } - offset += sam_data_bytes; - } - } - } - return module; -} - -static struct module* module_load_s3m( struct data *data, char *message ) { - int idx, module_data_idx, inst_offset, flags; - int version, sixteen_bit, tune, signed_samples; - int stereo_mode, default_pan, channel_map[ 32 ]; - int sample_offset, sample_length, loop_start, loop_length; - int pat_offset, note_offset, row, chan, token; - int key, ins, volume, effect, param, panning; - char *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - data_ascii( data, 0, 28, module->name ); - module->sequence_len = data_u16le( data, 32 ); - module->num_instruments = data_u16le( data, 34 ); - module->num_patterns = data_u16le( data, 36 ); - flags = data_u16le( data, 38 ); - version = data_u16le( data, 40 ); - module->fast_vol_slides = ( ( flags & 0x40 ) == 0x40 ) || version == 0x1300; - signed_samples = data_u16le( data, 42 ) == 1; - if( data_u32le( data, 44 ) != 0x4d524353 ) { - strcpy( message, "Not an S3M file!" ); - dispose_module( module ); - return NULL; - } - module->default_gvol = data_u8( data, 48 ); - module->default_speed = data_u8( data, 49 ); - module->default_tempo = data_u8( data, 50 ); - module->c2_rate = 8363; - module->gain = data_u8( data, 51 ) & 0x7F; - stereo_mode = ( data_u8( data, 51 ) & 0x80 ) == 0x80; - default_pan = data_u8( data, 53 ) == 0xFC; - for( idx = 0; idx < 32; idx++ ) { - channel_map[ idx ] = -1; - if( data_u8( data, 64 + idx ) < 16 ) { - channel_map[ idx ] = module->num_channels++; - } - } - module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); - if( !module->sequence ){ - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->sequence_len; idx++ ) { - module->sequence[ idx ] = data_u8( data, 96 + idx ); - } - module_data_idx = 96 + module->sequence_len; - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - sample = &instrument->samples[ 0 ]; - inst_offset = data_u16le( data, module_data_idx ) << 4; - module_data_idx += 2; - data_ascii( data, inst_offset + 48, 28, instrument->name ); - if( data_u8( data, inst_offset ) == 1 && data_u16le( data, inst_offset + 76 ) == 0x4353 ) { - sample_offset = ( data_u8( data, inst_offset + 13 ) << 20 ) - + ( data_u16le( data, inst_offset + 14 ) << 4 ); - sample_length = data_u32le( data, inst_offset + 16 ); - loop_start = data_u32le( data, inst_offset + 20 ); - loop_length = data_u32le( data, inst_offset + 24 ) - loop_start; - sample->volume = data_u8( data, inst_offset + 28 ); - if( data_u8( data, inst_offset + 30 ) != 0 ) { - strcpy( message, "Packed samples not supported!" ); - dispose_module( module ); - return NULL; - } - if( loop_start + loop_length > sample_length ) { - loop_length = sample_length - loop_start; - } - if( loop_length < 1 || !( data_u8( data, inst_offset + 31 ) & 0x1 ) ) { - loop_start = sample_length; - loop_length = 0; - } - sample->loop_start = loop_start; - sample->loop_length = loop_length; - /* stereo = data_u8( data, inst_offset + 31 ) & 0x2; */ - sixteen_bit = data_u8( data, inst_offset + 31 ) & 0x4; - tune = ( log_2( data_u32le( data, inst_offset + 32 ) ) - log_2( module->c2_rate ) ) * 12; - sample->rel_note = tune >> FP_SHIFT; - sample->fine_tune = ( tune & FP_MASK ) >> ( FP_SHIFT - 7 ); - sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); - if( sample->data ) { - if( sixteen_bit ) { - data_sam_s16le( data, sample_offset, sample_length, sample->data ); - } else { - data_sam_s8( data, sample_offset, sample_length, sample->data ); - } - if( !signed_samples ) { - for( idx = 0; idx < sample_length; idx++ ) { - sample->data[ idx ] = ( sample->data[ idx ] & 0xFFFF ) - 32768; - } - } - sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; - } else { - dispose_module( module ); - return NULL; - } - } - } - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_patterns; idx++ ) { - module->patterns[ idx ].num_channels = module->num_channels; - module->patterns[ idx ].num_rows = 64; - pattern_data = (char*)calloc( module->num_channels * 64, 5 ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ idx ].data = pattern_data; - pat_offset = ( data_u16le( data, module_data_idx ) << 4 ) + 2; - row = 0; - while( row < 64 ) { - token = data_u8( data, pat_offset++ ); - if( token ) { - key = ins = 0; - if( ( token & 0x20 ) == 0x20 ) { - /* Key + Instrument.*/ - key = data_u8( data, pat_offset++ ); - ins = data_u8( data, pat_offset++ ); - if( key < 0xFE ) { - key = ( key >> 4 ) * 12 + ( key & 0xF ) + 1; - } else if( key == 0xFF ) { - key = 0; - } - } - volume = 0; - if( ( token & 0x40 ) == 0x40 ) { - /* Volume Column.*/ - volume = ( data_u8( data, pat_offset++ ) & 0x7F ) + 0x10; - if( volume > 0x50 ) { - volume = 0; - } - } - effect = param = 0; - if( ( token & 0x80 ) == 0x80 ) { - /* Effect + Param.*/ - effect = data_u8( data, pat_offset++ ); - param = data_u8( data, pat_offset++ ); - if( effect < 1 || effect >= 0x40 ) { - effect = param = 0; - } else if( effect > 0 ) { - effect += 0x80; - } - } - chan = channel_map[ token & 0x1F ]; - if( chan >= 0 ) { - note_offset = ( row * module->num_channels + chan ) * 5; - pattern_data[ note_offset ] = key; - pattern_data[ note_offset + 1 ] = ins; - pattern_data[ note_offset + 2 ] = volume; - pattern_data[ note_offset + 3 ] = effect; - pattern_data[ note_offset + 4 ] = param; - } - } else { - row++; - } - } - module_data_idx += 2; - } - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( module->default_panning ) { - for( chan = 0; chan < 32; chan++ ) { - if( channel_map[ chan ] >= 0 ) { - panning = 7; - if( stereo_mode ) { - panning = 12; - if( data_u8( data, 64 + chan ) < 8 ) { - panning = 3; - } - } - if( default_pan ) { - flags = data_u8( data, module_data_idx + chan ); - if( ( flags & 0x20 ) == 0x20 ) { - panning = flags & 0xF; - } - } - module->default_panning[ channel_map[ chan ] ] = panning * 17; - } - } - } else { - dispose_module( module ); - return NULL; - } - } - return module; -} - -static struct module* module_load_mod( struct data *data, char *message ) { - int idx, pat, module_data_idx, pat_data_len, pat_data_idx; - int period, key, ins, effect, param, fine_tune; - int sample_length, loop_start, loop_length; - char *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - data_ascii( data, 0, 20, module->name ); - module->sequence_len = data_u8( data, 950 ) & 0x7F; - module->restart_pos = data_u8( data, 951 ) & 0x7F; - if( module->restart_pos >= module->sequence_len ) { - module->restart_pos = 0; - } - module->sequence = (unsigned char*)calloc( 128, sizeof( unsigned char ) ); - if( !module->sequence ){ - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < 128; idx++ ) { - pat = data_u8( data, 952 + idx ) & 0x7F; - module->sequence[ idx ] = pat; - if( pat >= module->num_patterns ) { - module->num_patterns = pat + 1; - } - } - switch( data_u16be( data, 1082 ) ) { - case 0x4b2e: /* M.K. */ - case 0x4b21: /* M!K! */ - case 0x5434: /* FLT4 */ - module->num_channels = 4; - module->c2_rate = 8287; - module->gain = 64; - break; - case 0x484e: /* xCHN */ - module->num_channels = data_u8( data, 1080 ) - 48; - module->c2_rate = 8363; - module->gain = 32; - break; - case 0x4348: /* xxCH */ - module->num_channels = ( data_u8( data, 1080 ) - 48 ) * 10; - module->num_channels += data_u8( data, 1081 ) - 48; - module->c2_rate = 8363; - module->gain = 32; - break; - default: - strcpy( message, "MOD Format not recognised!" ); - dispose_module( module ); - return NULL; - } - module->default_gvol = 64; - module->default_speed = 6; - module->default_tempo = 125; - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( !module->default_panning ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - module->default_panning[ idx ] = 51; - if( ( idx & 3 ) == 1 || ( idx & 3 ) == 2 ) { - module->default_panning[ idx ] = 204; - } - } - module_data_idx = 1084; - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - pat_data_len = module->num_channels * 64 * 5; - for( pat = 0; pat < module->num_patterns; pat++ ) { - module->patterns[ pat ].num_channels = module->num_channels; - module->patterns[ pat ].num_rows = 64; - pattern_data = (char*)calloc( 1, pat_data_len ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ pat ].data = pattern_data; - for( pat_data_idx = 0; pat_data_idx < pat_data_len; pat_data_idx += 5 ) { - period = ( data_u8( data, module_data_idx ) & 0xF ) << 8; - period = ( period | data_u8( data, module_data_idx + 1 ) ) * 4; - if( period >= 112 && period <= 6848 ) { - key = -12 * log_2( ( period << FP_SHIFT ) / 29021 ); - key = ( key + ( key & ( FP_ONE >> 1 ) ) ) >> FP_SHIFT; - pattern_data[ pat_data_idx ] = key; - } - ins = ( data_u8( data, module_data_idx + 2 ) & 0xF0 ) >> 4; - ins = ins | ( data_u8( data, module_data_idx ) & 0x10 ); - pattern_data[ pat_data_idx + 1 ] = ins; - effect = data_u8( data, module_data_idx + 2 ) & 0x0F; - param = data_u8( data, module_data_idx + 3 ); - if( param == 0 && ( effect < 3 || effect == 0xA ) ) { - effect = 0; - } - if( param == 0 && ( effect == 5 || effect == 6 ) ) { - effect -= 2; - } - if( effect == 8 && module->num_channels == 4 ) { - effect = param = 0; - } - pattern_data[ pat_data_idx + 3 ] = effect; - pattern_data[ pat_data_idx + 4 ] = param; - module_data_idx += 4; - } - } - module->num_instruments = 31; - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - sample = &instrument->samples[ 0 ]; - data_ascii( data, ins * 30 - 10, 22, instrument->name ); - sample_length = data_u16be( data, ins * 30 + 12 ) * 2; - fine_tune = ( data_u8( data, ins * 30 + 14 ) & 0xF ) << 4; - sample->fine_tune = ( fine_tune & 0x7F ) - ( fine_tune & 0x80 ); - sample->volume = data_u8( data, ins * 30 + 15 ) & 0x7F; - if( sample->volume > 64 ) { - sample->volume = 64; - } - loop_start = data_u16be( data, ins * 30 + 16 ) * 2; - loop_length = data_u16be( data, ins * 30 + 18 ) * 2; - if( loop_start + loop_length > sample_length ) { - loop_length = sample_length - loop_start; - } - if( loop_length < 4 ) { - loop_start = sample_length; - loop_length = 0; - } - sample->loop_start = loop_start; - sample->loop_length = loop_length; - sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); - if( sample->data ) { - data_sam_s8( data, module_data_idx, sample_length, sample->data ); - sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; - } else { - dispose_module( module ); - return NULL; - } - module_data_idx += sample_length; - } - } - return module; -} - -/* Allocate and initialize a module from the specified data, returns NULL on error. - Message should point to a 64-character buffer to receive error messages. */ -struct module* module_load( struct data *data, char *message ) { - char ascii[ 16 ]; - struct module* module; - if( !memcmp( data_ascii( data, 0, 16, ascii ), "Extended Module:", 16 ) ) { - module = module_load_xm( data, message ); - } else if( !memcmp( data_ascii( data, 44, 4, ascii ), "SCRM", 4 ) ) { - module = module_load_s3m( data, message ); - } else { - module = module_load_mod( data, message ); - } - return module; -} - -static void pattern_get_note( struct pattern *pattern, int row, int chan, struct note *dest ) { - int offset = ( row * pattern->num_channels + chan ) * 5; - if( offset >= 0 && row < pattern->num_rows && chan < pattern->num_channels ) { - dest->key = pattern->data[ offset ]; - dest->instrument = pattern->data[ offset + 1 ]; - dest->volume = pattern->data[ offset + 2 ]; - dest->effect = pattern->data[ offset + 3 ]; - dest->param = pattern->data[ offset + 4 ]; - } else { - memset( dest, 0, sizeof( struct note ) ); - } -} - -static void channel_init( struct channel *channel, struct replay *replay, int idx ) { - memset( channel, 0, sizeof( struct channel ) ); - channel->replay = replay; - channel->id = idx; - channel->panning = replay->module->default_panning[ idx ]; - channel->instrument = &replay->module->instruments[ 0 ]; - channel->sample = &channel->instrument->samples[ 0 ]; - channel->random_seed = ( idx + 1 ) * 0xABCDEF; -} - -static void channel_volume_slide( struct channel *channel ) { - int up = channel->vol_slide_param >> 4; - int down = channel->vol_slide_param & 0xF; - if( down == 0xF && up > 0 ) { - /* Fine slide up.*/ - if( channel->fx_count == 0 ) { - channel->volume += up; - } - } else if( up == 0xF && down > 0 ) { - /* Fine slide down.*/ - if( channel->fx_count == 0 ) { - channel->volume -= down; - } - } else if( channel->fx_count > 0 || channel->replay->module->fast_vol_slides ) { - /* Normal.*/ - channel->volume += up - down; - } - if( channel->volume > 64 ) { - channel->volume = 64; - } - if( channel->volume < 0 ) { - channel->volume = 0; - } -} - -static void channel_porta_up( struct channel *channel, int param ) { - switch( param & 0xF0 ) { - case 0xE0: /* Extra-fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period -= param & 0xF; - } - break; - case 0xF0: /* Fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period -= ( param & 0xF ) << 2; - } - break; - default:/* Normal porta.*/ - if( channel->fx_count > 0 ) { - channel->period -= param << 2; - } - break; - } - if( channel->period < 0 ) { - channel->period = 0; - } -} - -static void channel_porta_down( struct channel *channel, int param ) { - if( channel->period > 0 ) { - switch( param & 0xF0 ) { - case 0xE0: /* Extra-fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period += param & 0xF; - } - break; - case 0xF0: /* Fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period += ( param & 0xF ) << 2; - } - break; - default:/* Normal porta.*/ - if( channel->fx_count > 0 ) { - channel->period += param << 2; - } - break; - } - if( channel->period > 65535 ) { - channel->period = 65535; - } - } -} - -static void channel_tone_porta( struct channel *channel ) { - if( channel->period > 0 ) { - if( channel->period < channel->porta_period ) { - channel->period += channel->tone_porta_param << 2; - if( channel->period > channel->porta_period ) { - channel->period = channel->porta_period; - } - } else { - channel->period -= channel->tone_porta_param << 2; - if( channel->period < channel->porta_period ) { - channel->period = channel->porta_period; - } - } - } -} - -static int channel_waveform( struct channel *channel, int phase, int type ) { - int amplitude = 0; - switch( type ) { - default: /* Sine. */ - amplitude = sine_table[ phase & 0x1F ]; - if( ( phase & 0x20 ) > 0 ) { - amplitude = -amplitude; - } - break; - case 6: /* Saw Up.*/ - amplitude = ( ( ( phase + 0x20 ) & 0x3F ) << 3 ) - 255; - break; - case 1: case 7: /* Saw Down. */ - amplitude = 255 - ( ( ( phase + 0x20 ) & 0x3F ) << 3 ); - break; - case 2: case 5: /* Square. */ - amplitude = ( phase & 0x20 ) > 0 ? 255 : -255; - break; - case 3: case 8: /* Random. */ - amplitude = ( channel->random_seed >> 20 ) - 255; - channel->random_seed = ( channel->random_seed * 65 + 17 ) & 0x1FFFFFFF; - break; - } - return amplitude; -} - -static void channel_vibrato( struct channel *channel, int fine ) { - int wave = channel_waveform( channel, channel->vibrato_phase, channel->vibrato_type & 0x3 ); - channel->vibrato_add = wave * channel->vibrato_depth >> ( fine ? 7 : 5 ); -} - -static void channel_tremolo( struct channel *channel ) { - int wave = channel_waveform( channel, channel->tremolo_phase, channel->tremolo_type & 0x3 ); - channel->tremolo_add = wave * channel->tremolo_depth >> 6; -} - -static void channel_tremor( struct channel *channel ) { - if( channel->retrig_count >= channel->tremor_on_ticks ) { - channel->tremolo_add = -64; - } - if( channel->retrig_count >= ( channel->tremor_on_ticks + channel->tremor_off_ticks ) ) { - channel->tremolo_add = channel->retrig_count = 0; - } -} - -static void channel_retrig_vol_slide( struct channel *channel ) { - if( channel->retrig_count >= channel->retrig_ticks ) { - channel->retrig_count = channel->sample_idx = channel->sample_fra = 0; - switch( channel->retrig_volume ) { - case 0x1: channel->volume = channel->volume - 1; break; - case 0x2: channel->volume = channel->volume - 2; break; - case 0x3: channel->volume = channel->volume - 4; break; - case 0x4: channel->volume = channel->volume - 8; break; - case 0x5: channel->volume = channel->volume - 16; break; - case 0x6: channel->volume = channel->volume * 2 / 3; break; - case 0x7: channel->volume = channel->volume >> 1; break; - case 0x8: /* ? */ break; - case 0x9: channel->volume = channel->volume + 1; break; - case 0xA: channel->volume = channel->volume + 2; break; - case 0xB: channel->volume = channel->volume + 4; break; - case 0xC: channel->volume = channel->volume + 8; break; - case 0xD: channel->volume = channel->volume + 16; break; - case 0xE: channel->volume = channel->volume * 3 / 2; break; - case 0xF: channel->volume = channel->volume << 1; break; - } - if( channel->volume < 0 ) { - channel->volume = 0; - } - if( channel->volume > 64 ) { - channel->volume = 64; - } - } -} - -static void channel_trigger( struct channel *channel ) { - int key, sam, porta, period, fine_tune, ins = channel->note.instrument; - struct sample *sample; - if( ins > 0 && ins <= channel->replay->module->num_instruments ) { - channel->instrument = &channel->replay->module->instruments[ ins ]; - key = channel->note.key < 97 ? channel->note.key : 0; - sam = channel->instrument->key_to_sample[ key ]; - sample = &channel->instrument->samples[ sam ]; - channel->volume = sample->volume >= 64 ? 64 : sample->volume & 0x3F; - if( sample->panning > 0 ) { - channel->panning = ( sample->panning - 1 ) & 0xFF; - } - if( channel->period > 0 && sample->loop_length > 1 ) { - /* Amiga trigger.*/ - channel->sample = sample; - } - channel->sample_off = 0; - channel->vol_env_tick = channel->pan_env_tick = 0; - channel->fadeout_vol = 32768; - channel->key_on = 1; - } - if( channel->note.effect == 0x09 || channel->note.effect == 0x8F ) { - /* Set Sample Offset. */ - if( channel->note.param > 0 ) { - channel->offset_param = channel->note.param; - } - channel->sample_off = channel->offset_param << 8; - } - if( channel->note.volume >= 0x10 && channel->note.volume < 0x60 ) { - channel->volume = channel->note.volume < 0x50 ? channel->note.volume - 0x10 : 64; - } - switch( channel->note.volume & 0xF0 ) { - case 0x80: /* Fine Vol Down.*/ - channel->volume -= channel->note.volume & 0xF; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x90: /* Fine Vol Up.*/ - channel->volume += channel->note.volume & 0xF; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0xA0: /* Set Vibrato Speed.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->vibrato_speed = channel->note.volume & 0xF; - } - break; - case 0xB0: /* Vibrato.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.volume & 0xF; - } - channel_vibrato( channel, 0 ); - break; - case 0xC0: /* Set Panning.*/ - channel->panning = ( channel->note.volume & 0xF ) * 17; - break; - case 0xF0: /* Tone Porta.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->tone_porta_param = channel->note.volume & 0xF; - } - break; - } - if( channel->note.key > 0 ) { - if( channel->note.key > 96 ) { - channel->key_on = 0; - } else { - porta = ( channel->note.volume & 0xF0 ) == 0xF0 || - channel->note.effect == 0x03 || channel->note.effect == 0x05 || - channel->note.effect == 0x87 || channel->note.effect == 0x8C; - if( !porta ) { - ins = channel->instrument->key_to_sample[ channel->note.key ]; - channel->sample = &channel->instrument->samples[ ins ]; - } - fine_tune = channel->sample->fine_tune; - if( channel->note.effect == 0x75 || channel->note.effect == 0xF2 ) { - /* Set Fine Tune. */ - fine_tune = ( ( channel->note.param & 0xF ) << 4 ) - 128; - } - key = channel->note.key + channel->sample->rel_note; - if( key < 1 ) { - key = 1; - } - if( key > 120 ) { - key = 120; - } - period = ( key << 6 ) + ( fine_tune >> 1 ); - if( channel->replay->module->linear_periods ) { - channel->porta_period = 7744 - period; - } else { - channel->porta_period = 29021 * exp_2( ( period << FP_SHIFT ) / -768 ) >> FP_SHIFT; - } - if( !porta ) { - channel->period = channel->porta_period; - channel->sample_idx = channel->sample_off; - channel->sample_fra = 0; - if( channel->vibrato_type < 4 ) { - channel->vibrato_phase = 0; - } - if( channel->tremolo_type < 4 ) { - channel->tremolo_phase = 0; - } - channel->retrig_count = channel->av_count = 0; - } - } - } -} - -static void channel_update_envelopes( struct channel *channel ) { - if( channel->instrument->vol_env.enabled ) { - if( !channel->key_on ) { - channel->fadeout_vol -= channel->instrument->vol_fadeout; - if( channel->fadeout_vol < 0 ) { - channel->fadeout_vol = 0; - } - } - channel->vol_env_tick = envelope_next_tick( &channel->instrument->vol_env, - channel->vol_env_tick, channel->key_on ); - } - if( channel->instrument->pan_env.enabled ) { - channel->pan_env_tick = envelope_next_tick( &channel->instrument->pan_env, - channel->pan_env_tick, channel->key_on ); - } -} - -static void channel_auto_vibrato( struct channel *channel ) { - int sweep, rate, type, wave; - int depth = channel->instrument->vib_depth & 0x7F; - if( depth > 0 ) { - sweep = channel->instrument->vib_sweep & 0x7F; - rate = channel->instrument->vib_rate & 0x7F; - type = channel->instrument->vib_type; - if( channel->av_count < sweep ) { - depth = depth * channel->av_count / sweep; - } - wave = channel_waveform( channel, channel->av_count * rate >> 2, type + 4 ); - channel->vibrato_add += wave * depth >> 8; - channel->av_count++; - } -} - -static void channel_calculate_freq( struct channel *channel ) { - int per = channel->period + channel->vibrato_add; - if( channel->replay->module->linear_periods ) { - per = per - ( channel->arpeggio_add << 6 ); - if( per < 28 || per > 7680 ) { - per = 7680; - } - channel->freq = ( ( channel->replay->module->c2_rate >> 4 ) - * exp_2( ( ( 4608 - per ) << FP_SHIFT ) / 768 ) ) >> ( FP_SHIFT - 4 ); - } else { - if( per > 29021 ) { - per = 29021; - } - per = ( per << FP_SHIFT ) / exp_2( ( channel->arpeggio_add << FP_SHIFT ) / 12 ); - if( per < 28 ) { - per = 29021; - } - channel->freq = channel->replay->module->c2_rate * 1712 / per; - } -} - -static void channel_calculate_ampl( struct channel *channel ) { - int vol, range, env_pan = 32, env_vol = channel->key_on ? 64 : 0; - if( channel->instrument->vol_env.enabled ) { - env_vol = envelope_calculate_ampl( &channel->instrument->vol_env, channel->vol_env_tick ); - } - vol = channel->volume + channel->tremolo_add; - if( vol > 64 ) { - vol = 64; - } - if( vol < 0 ) { - vol = 0; - } - vol = ( vol * channel->replay->module->gain * FP_ONE ) >> 13; - vol = ( vol * channel->fadeout_vol ) >> 15; - channel->ampl = ( vol * channel->replay->global_vol * env_vol ) >> 12; - if( channel->instrument->pan_env.enabled ) { - env_pan = envelope_calculate_ampl( &channel->instrument->pan_env, channel->pan_env_tick ); - } - range = ( channel->panning < 128 ) ? channel->panning : ( 255 - channel->panning ); - channel->pann = channel->panning + ( range * ( env_pan - 32 ) >> 5 ); -} - -static void channel_tick( struct channel *channel ) { - channel->vibrato_add = 0; - channel->fx_count++; - channel->retrig_count++; - if( !( channel->note.effect == 0x7D && channel->fx_count <= channel->note.param ) ) { - switch( channel->note.volume & 0xF0 ) { - case 0x60: /* Vol Slide Down.*/ - channel->volume -= channel->note.volume & 0xF; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x70: /* Vol Slide Up.*/ - channel->volume += channel->note.volume & 0xF; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0xB0: /* Vibrato.*/ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - break; - case 0xD0: /* Pan Slide Left.*/ - channel->panning -= channel->note.volume & 0xF; - if( channel->panning < 0 ) { - channel->panning = 0; - } - break; - case 0xE0: /* Pan Slide Right.*/ - channel->panning += channel->note.volume & 0xF; - if( channel->panning > 255 ) { - channel->panning = 255; - } - break; - case 0xF0: /* Tone Porta.*/ - channel_tone_porta( channel ); - break; - } - } - switch( channel->note.effect ) { - case 0x01: case 0x86: /* Porta Up. */ - channel_porta_up( channel, channel->porta_up_param ); - break; - case 0x02: case 0x85: /* Porta Down. */ - channel_porta_down( channel, channel->porta_down_param ); - break; - case 0x03: case 0x87: /* Tone Porta. */ - channel_tone_porta( channel ); - break; - case 0x04: case 0x88: /* Vibrato. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - break; - case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ - channel_tone_porta( channel ); - channel_volume_slide( channel ); - break; - case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - channel_volume_slide( channel ); - break; - case 0x07: case 0x92: /* Tremolo. */ - channel->tremolo_phase += channel->tremolo_speed; - channel_tremolo( channel ); - break; - case 0x0A: case 0x84: /* Vol Slide. */ - channel_volume_slide( channel ); - break; - case 0x11: /* Global Volume Slide. */ - channel->replay->global_vol = channel->replay->global_vol - + ( channel->gvol_slide_param >> 4 ) - - ( channel->gvol_slide_param & 0xF ); - if( channel->replay->global_vol < 0 ) { - channel->replay->global_vol = 0; - } - if( channel->replay->global_vol > 64 ) { - channel->replay->global_vol = 64; - } - break; - case 0x19: /* Panning Slide. */ - channel->panning = channel->panning - + ( channel->pan_slide_param >> 4 ) - - ( channel->pan_slide_param & 0xF ); - if( channel->panning < 0 ) { - channel->panning = 0; - } - if( channel->panning > 255 ) { - channel->panning = 255; - } - break; - case 0x1B: case 0x91: /* Retrig + Vol Slide. */ - channel_retrig_vol_slide( channel ); - break; - case 0x1D: case 0x89: /* Tremor. */ - channel_tremor( channel ); - break; - case 0x79: /* Retrig. */ - if( channel->fx_count >= channel->note.param ) { - channel->fx_count = 0; - channel->sample_idx = channel->sample_fra = 0; - } - break; - case 0x7C: case 0xFC: /* Note Cut. */ - if( channel->note.param == channel->fx_count ) { - channel->volume = 0; - } - break; - case 0x7D: case 0xFD: /* Note Delay. */ - if( channel->note.param == channel->fx_count ) { - channel_trigger( channel ); - } - break; - case 0x8A: /* Arpeggio. */ - if( channel->fx_count == 1 ) { - channel->arpeggio_add = channel->arpeggio_param >> 4; - } else if( channel->fx_count == 2 ) { - channel->arpeggio_add = channel->arpeggio_param & 0xF; - } else { - channel->arpeggio_add = channel->fx_count = 0; - } - break; - case 0x95: /* Fine Vibrato. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 1 ); - break; - } - channel_auto_vibrato( channel ); - channel_calculate_freq( channel ); - channel_calculate_ampl( channel ); - channel_update_envelopes( channel ); -} - -static void channel_row( struct channel *channel, struct note *note ) { - channel->note = *note; - channel->retrig_count++; - channel->vibrato_add = channel->tremolo_add = channel->arpeggio_add = channel->fx_count = 0; - if( !( ( note->effect == 0x7D || note->effect == 0xFD ) && note->param > 0 ) ) { - /* Not note delay.*/ - channel_trigger( channel ); - } - switch( channel->note.effect ) { - case 0x01: case 0x86: /* Porta Up. */ - if( channel->note.param > 0 ) { - channel->porta_up_param = channel->note.param; - } - channel_porta_up( channel, channel->porta_up_param ); - break; - case 0x02: case 0x85: /* Porta Down. */ - if( channel->note.param > 0 ) { - channel->porta_down_param = channel->note.param; - } - channel_porta_down( channel, channel->porta_down_param ); - break; - case 0x03: case 0x87: /* Tone Porta. */ - if( channel->note.param > 0 ) { - channel->tone_porta_param = channel->note.param; - } - break; - case 0x04: case 0x88: /* Vibrato. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->vibrato_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.param & 0xF; - } - channel_vibrato( channel, 0 ); - break; - case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_volume_slide( channel ); - break; - case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_vibrato( channel, 0 ); - channel_volume_slide( channel ); - break; - case 0x07: case 0x92: /* Tremolo. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->tremolo_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->tremolo_depth = channel->note.param & 0xF; - } - channel_tremolo( channel ); - break; - case 0x08: /* Set Panning.*/ - channel->panning = ( channel->note.param < 128 ) ? ( channel->note.param << 1 ) : 255; - break; - case 0x0A: case 0x84: /* Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_volume_slide( channel ); - break; - case 0x0C: /* Set Volume. */ - channel->volume = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; - break; - case 0x10: case 0x96: /* Set Global Volume. */ - channel->replay->global_vol = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; - break; - case 0x11: /* Global Volume Slide. */ - if( channel->note.param > 0 ) { - channel->gvol_slide_param = channel->note.param; - } - break; - case 0x14: /* Key Off. */ - channel->key_on = 0; - break; - case 0x15: /* Set Envelope Tick. */ - channel->vol_env_tick = channel->pan_env_tick = channel->note.param & 0xFF; - break; - case 0x19: /* Panning Slide. */ - if( channel->note.param > 0 ) { - channel->pan_slide_param = channel->note.param; - } - break; - case 0x1B: case 0x91: /* Retrig + Vol Slide. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->retrig_volume = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->retrig_ticks = channel->note.param & 0xF; - } - channel_retrig_vol_slide( channel ); - break; - case 0x1D: case 0x89: /* Tremor. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->tremor_on_ticks = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->tremor_off_ticks = channel->note.param & 0xF; - } - channel_tremor( channel ); - break; - case 0x21: /* Extra Fine Porta. */ - if( channel->note.param > 0 ) { - channel->xfine_porta_param = channel->note.param; - } - switch( channel->xfine_porta_param & 0xF0 ) { - case 0x10: - channel_porta_up( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); - break; - case 0x20: - channel_porta_down( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); - break; - } - break; - case 0x71: /* Fine Porta Up. */ - if( channel->note.param > 0 ) { - channel->fine_porta_up_param = channel->note.param; - } - channel_porta_up( channel, 0xF0 | ( channel->fine_porta_up_param & 0xF ) ); - break; - case 0x72: /* Fine Porta Down. */ - if( channel->note.param > 0 ) { - channel->fine_porta_down_param = channel->note.param; - } - channel_porta_down( channel, 0xF0 | ( channel->fine_porta_down_param & 0xF ) ); - break; - case 0x74: case 0xF3: /* Set Vibrato Waveform. */ - if( channel->note.param < 8 ) { - channel->vibrato_type = channel->note.param; - } - break; - case 0x77: case 0xF4: /* Set Tremolo Waveform. */ - if( channel->note.param < 8 ) { - channel->tremolo_type = channel->note.param; - } - break; - case 0x7A: /* Fine Vol Slide Up. */ - if( channel->note.param > 0 ) { - channel->fine_vslide_up_param = channel->note.param; - } - channel->volume += channel->fine_vslide_up_param; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0x7B: /* Fine Vol Slide Down. */ - if( channel->note.param > 0 ) { - channel->fine_vslide_down_param = channel->note.param; - } - channel->volume -= channel->fine_vslide_down_param; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x7C: case 0xFC: /* Note Cut. */ - if( channel->note.param <= 0 ) { - channel->volume = 0; - } - break; - case 0x8A: /* Arpeggio. */ - if( channel->note.param > 0 ) { - channel->arpeggio_param = channel->note.param; - } - break; - case 0x95: /* Fine Vibrato.*/ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->vibrato_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.param & 0xF; - } - channel_vibrato( channel, 1 ); - break; - case 0xF8: /* Set Panning. */ - channel->panning = channel->note.param * 17; - break; - } - channel_auto_vibrato( channel ); - channel_calculate_freq( channel ); - channel_calculate_ampl( channel ); - channel_update_envelopes( channel ); -} - -static void channel_resample( struct channel *channel, int *mix_buf, - int offset, int count, int sample_rate, int interpolate ) { - struct sample *sample = channel->sample; - int l_gain, r_gain, sam_idx, sam_fra, step; - int loop_len, loop_end, out_idx, out_end, y, m, c; - short *sample_data = channel->sample->data; - if( channel->ampl > 0 ) { - l_gain = channel->ampl * ( 255 - channel->pann ) >> 8; - r_gain = channel->ampl * channel->pann >> 8; - sam_idx = channel->sample_idx; - sam_fra = channel->sample_fra; - step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); - loop_len = sample->loop_length; - loop_end = sample->loop_start + loop_len; - out_idx = offset * 2; - out_end = ( offset + count ) * 2; - if( interpolate ) { - while( out_idx < out_end ) { - if( sam_idx >= loop_end ) { - if( loop_len > 1 ) { - while( sam_idx >= loop_end ) { - sam_idx -= loop_len; - } - } else { - break; - } - } - c = sample_data[ sam_idx ]; - m = sample_data[ sam_idx + 1 ] - c; - y = ( ( m * sam_fra ) >> FP_SHIFT ) + c; - mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; - mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; - sam_fra += step; - sam_idx += sam_fra >> FP_SHIFT; - sam_fra &= FP_MASK; - } - } else { - while( out_idx < out_end ) { - if( sam_idx >= loop_end ) { - if( loop_len > 1 ) { - while( sam_idx >= loop_end ) { - sam_idx -= loop_len; - } - } else { - break; - } - } - y = sample_data[ sam_idx ]; - mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; - mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; - sam_fra += step; - sam_idx += sam_fra >> FP_SHIFT; - sam_fra &= FP_MASK; - } - } - } -} - -static void channel_update_sample_idx( struct channel *channel, int count, int sample_rate ) { - struct sample *sample = channel->sample; - int step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); - channel->sample_fra += step * count; - channel->sample_idx += channel->sample_fra >> FP_SHIFT; - if( channel->sample_idx > sample->loop_start ) { - if( sample->loop_length > 1 ) { - channel->sample_idx = sample->loop_start - + ( channel->sample_idx - sample->loop_start ) % sample->loop_length; - } else { - channel->sample_idx = sample->loop_start; - } - } - channel->sample_fra &= FP_MASK; -} - -static void replay_row( struct replay *replay ) { - int idx, count; - struct note note; - struct pattern *pattern; - struct channel *channel; - struct module *module = replay->module; - if( replay->next_row < 0 ) { - replay->break_pos = replay->seq_pos + 1; - replay->next_row = 0; - } - if( replay->break_pos >= 0 ) { - if( replay->break_pos >= module->sequence_len ) { - replay->break_pos = replay->next_row = 0; - } - while( module->sequence[ replay->break_pos ] >= module->num_patterns ) { - replay->break_pos++; - if( replay->break_pos >= module->sequence_len ) { - replay->break_pos = replay->next_row = 0; - } - } - replay->seq_pos = replay->break_pos; - for( idx = 0; idx < module->num_channels; idx++ ) { - replay->channels[ idx ].pl_row = 0; - } - replay->break_pos = -1; - } - pattern = &module->patterns[ module->sequence[ replay->seq_pos ] ]; - replay->row = replay->next_row; - if( replay->row >= pattern->num_rows ) { - replay->row = 0; - } - if( replay->play_count && replay->play_count[ 0 ] ) { - count = replay->play_count[ replay->seq_pos ][ replay->row ]; - if( replay->pl_count < 0 && count < 127 ) { - replay->play_count[ replay->seq_pos ][ replay->row ] = count + 1; - } - } - replay->next_row = replay->row + 1; - if( replay->next_row >= pattern->num_rows ) { - replay->next_row = -1; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - channel = &replay->channels[ idx ]; - pattern_get_note( pattern, replay->row, idx, ¬e ); - if( note.effect == 0xE ) { - note.effect = 0x70 | ( note.param >> 4 ); - note.param &= 0xF; - } - if( note.effect == 0x93 ) { - note.effect = 0xF0 | ( note.param >> 4 ); - note.param &= 0xF; - } - if( note.effect == 0 && note.param > 0 ) { - note.effect = 0x8A; - } - channel_row( channel, ¬e ); - switch( note.effect ) { - case 0x81: /* Set Speed. */ - if( note.param > 0 ) { - replay->tick = replay->speed = note.param; - } - break; - case 0xB: case 0x82: /* Pattern Jump.*/ - if( replay->pl_count < 0 ) { - replay->break_pos = note.param; - replay->next_row = 0; - } - break; - case 0xD: case 0x83: /* Pattern Break.*/ - if( replay->pl_count < 0 ) { - if( replay->break_pos < 0 ) { - replay->break_pos = replay->seq_pos + 1; - } - replay->next_row = ( note.param >> 4 ) * 10 + ( note.param & 0xF ); - } - break; - case 0xF: /* Set Speed/Tempo.*/ - if( note.param > 0 ) { - if( note.param < 32 ) { - replay->tick = replay->speed = note.param; - } else { - replay->tempo = note.param; - } - } - break; - case 0x94: /* Set Tempo.*/ - if( note.param > 32 ) { - replay->tempo = note.param; - } - break; - case 0x76: case 0xFB : /* Pattern Loop.*/ - if( note.param == 0 ) { - /* Set loop marker on this channel. */ - channel->pl_row = replay->row; - } - if( channel->pl_row < replay->row && replay->break_pos < 0 ) { - /* Marker valid. */ - if( replay->pl_count < 0 ) { - /* Not already looping, begin. */ - replay->pl_count = note.param; - replay->pl_chan = idx; - } - if( replay->pl_chan == idx ) { - /* Next Loop.*/ - if( replay->pl_count == 0 ) { - /* Loop finished. Invalidate current marker. */ - channel->pl_row = replay->row + 1; - } else { - /* Loop. */ - replay->next_row = channel->pl_row; - } - replay->pl_count--; - } - } - break; - case 0x7E: case 0xFE: /* Pattern Delay.*/ - replay->tick = replay->speed + replay->speed * note.param; - break; - } - } -} - -static int replay_tick( struct replay *replay ) { - int idx, num_channels, count = 1; - if( --replay->tick <= 0 ) { - replay->tick = replay->speed; - replay_row( replay ); - } else { - num_channels = replay->module->num_channels; - for( idx = 0; idx < num_channels; idx++ ) { - channel_tick( &replay->channels[ idx ] ); - } - } - if( replay->play_count && replay->play_count[ 0 ] ) { - count = replay->play_count[ replay->seq_pos ][ replay->row ] - 1; - } - return count; -} - -static int module_init_play_count( struct module *module, char **play_count ) { - int idx, pat, rows, len = 0; - for( idx = 0; idx < module->sequence_len; idx++ ) { - pat = module->sequence[ idx ]; - rows = ( pat < module->num_patterns ) ? module->patterns[ pat ].num_rows : 0; - if( play_count ) { - play_count[ idx ] = play_count[ 0 ] ? &play_count[ 0 ][ len ] : NULL; - } - len += rows; - } - return len; -} - -/* Set the pattern in the sequence to play. The tempo is reset to the default. */ -void replay_set_sequence_pos( struct replay *replay, int pos ) { - int idx; - struct module *module = replay->module; - if( pos >= module->sequence_len ) { - pos = 0; - } - replay->break_pos = pos; - replay->next_row = 0; - replay->tick = 1; - replay->global_vol = module->default_gvol; - replay->speed = module->default_speed > 0 ? module->default_speed : 6; - replay->tempo = module->default_tempo > 0 ? module->default_tempo : 125; - replay->pl_count = replay->pl_chan = -1; - if( replay->play_count ) { - free( replay->play_count[ 0 ] ); - free( replay->play_count ); - } - replay->play_count = (char**)calloc( module->sequence_len, sizeof( char * ) ); - if( replay->play_count ) { - replay->play_count[ 0 ] = (char*)calloc( module_init_play_count( module, NULL ), sizeof( char ) ); - module_init_play_count( module, replay->play_count ); - } - for( idx = 0; idx < module->num_channels; idx++ ) { - channel_init( &replay->channels[ idx ], replay, idx ); - } - memset( replay->ramp_buf, 0, 128 * sizeof( int ) ); - replay_tick( replay ); -} - -/* Deallocate the specified replay. */ -void dispose_replay( struct replay *replay ) { - if( replay->play_count ) { - free( replay->play_count[ 0 ] ); - free( replay->play_count ); - } - free( replay->ramp_buf ); - free( replay->channels ); - free( replay ); -} - -/* Allocate and initialize a replay with the specified sampling rate and interpolation. */ -struct replay* new_replay( struct module *module, int sample_rate, int interpolation ) { - struct replay *replay = (struct replay*)calloc( 1, sizeof( struct replay ) ); - if( replay ) { - replay->module = module; - replay->sample_rate = sample_rate; - replay->interpolation = interpolation; - replay->ramp_buf = (int*)calloc( 128, sizeof( int ) ); - replay->channels = (struct channel*)calloc( module->num_channels, sizeof( struct channel ) ); - if( replay->ramp_buf && replay->channels ) { - replay_set_sequence_pos( replay, 0 ); - } else { - dispose_replay( replay ); - replay = NULL; - } - } - return replay; -} - -static int calculate_tick_len( int tempo, int sample_rate ) { - return ( sample_rate * 5 ) / ( tempo * 2 ); -} - -/* Returns the length of the output buffer required by replay_get_audio(). */ -int calculate_mix_buf_len( int sample_rate ) { - return ( calculate_tick_len( 32, sample_rate ) + 65 ) * 4; -} - -/* Returns the song duration in samples at the current sampling rate. */ -int replay_calculate_duration( struct replay *replay ) { - int count = 0, duration = 0; - replay_set_sequence_pos( replay, 0 ); - while( count < 1 ) { - duration += calculate_tick_len( replay->tempo, replay->sample_rate ); - count = replay_tick( replay ); - } - replay_set_sequence_pos( replay, 0 ); - return duration; -} - -/* Seek to approximately the specified sample position. - The actual sample position reached is returned. */ -int replay_seek( struct replay *replay, int sample_pos ) { - int idx, tick_len, current_pos = 0; - replay_set_sequence_pos( replay, 0 ); - tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - while( ( sample_pos - current_pos ) >= tick_len ) { - for( idx = 0; idx < replay->module->num_channels; idx++ ) { - channel_update_sample_idx( &replay->channels[ idx ], - tick_len * 2, replay->sample_rate * 2 ); - } - current_pos += tick_len; - replay_tick( replay ); - tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - } - return current_pos; -} - -static void replay_volume_ramp( struct replay *replay, int *mix_buf, int tick_len ) { - int idx, a1, a2, ramp_rate = 256 * 2048 / replay->sample_rate; - for( idx = 0, a1 = 0; a1 < 256; idx += 2, a1 += ramp_rate ) { - a2 = 256 - a1; - mix_buf[ idx ] = ( mix_buf[ idx ] * a1 + replay->ramp_buf[ idx ] * a2 ) >> 8; - mix_buf[ idx + 1 ] = ( mix_buf[ idx + 1 ] * a1 + replay->ramp_buf[ idx + 1 ] * a2 ) >> 8; - } - memcpy( replay->ramp_buf, &mix_buf[ tick_len * 2 ], 128 * sizeof( int ) ); -} - -/* 2:1 downsampling with simple but effective anti-aliasing. Buf must contain count * 2 + 1 stereo samples. */ -static void downsample( int *buf, int count ) { - int idx, out_idx, out_len = count * 2; - for( idx = 0, out_idx = 0; out_idx < out_len; idx += 4, out_idx += 2 ) { - buf[ out_idx ] = ( buf[ idx ] >> 2 ) + ( buf[ idx + 2 ] >> 1 ) + ( buf[ idx + 4 ] >> 2 ); - buf[ out_idx + 1 ] = ( buf[ idx + 1 ] >> 2 ) + ( buf[ idx + 3 ] >> 1 ) + ( buf[ idx + 5 ] >> 2 ); - } -} - -/* Generates audio and returns the number of stereo samples written into mix_buf. */ -int replay_get_audio( struct replay *replay, int *mix_buf ) { - struct channel *channel; - int idx, num_channels, tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - /* Clear output buffer. */ - memset( mix_buf, 0, ( tick_len + 65 ) * 4 * sizeof( int ) ); - /* Resample. */ - num_channels = replay->module->num_channels; - for( idx = 0; idx < num_channels; idx++ ) { - channel = &replay->channels[ idx ]; - channel_resample( channel, mix_buf, 0, ( tick_len + 65 ) * 2, - replay->sample_rate * 2, replay->interpolation ); - channel_update_sample_idx( channel, tick_len * 2, replay->sample_rate * 2 ); - } - downsample( mix_buf, tick_len + 64 ); - replay_volume_ramp( replay, mix_buf, tick_len ); - replay_tick( replay ); - return tick_len; -} + +#include "stdlib.h" +#include "string.h" + +#include "ibxm.h" + +const char *IBXM_VERSION = "ibxm/ac mod/xm/s3m replay 20170901 (c)mumart@gmail.com"; + +static const int FP_SHIFT = 15, FP_ONE = 32768, FP_MASK = 32767; + +static const int exp2_table[] = { + 32768, 32946, 33125, 33305, 33486, 33667, 33850, 34034, + 34219, 34405, 34591, 34779, 34968, 35158, 35349, 35541, + 35734, 35928, 36123, 36319, 36516, 36715, 36914, 37114, + 37316, 37518, 37722, 37927, 38133, 38340, 38548, 38757, + 38968, 39180, 39392, 39606, 39821, 40037, 40255, 40473, + 40693, 40914, 41136, 41360, 41584, 41810, 42037, 42265, + 42495, 42726, 42958, 43191, 43425, 43661, 43898, 44137, + 44376, 44617, 44859, 45103, 45348, 45594, 45842, 46091, + 46341, 46593, 46846, 47100, 47356, 47613, 47871, 48131, + 48393, 48655, 48920, 49185, 49452, 49721, 49991, 50262, + 50535, 50810, 51085, 51363, 51642, 51922, 52204, 52488, + 52773, 53059, 53347, 53637, 53928, 54221, 54515, 54811, + 55109, 55408, 55709, 56012, 56316, 56622, 56929, 57238, + 57549, 57861, 58176, 58491, 58809, 59128, 59449, 59772, + 60097, 60423, 60751, 61081, 61413, 61746, 62081, 62419, + 62757, 63098, 63441, 63785, 64132, 64480, 64830, 65182, + 65536 +}; + +static const short sine_table[] = { + 0, 24, 49, 74, 97, 120, 141, 161, 180, 197, 212, 224, 235, 244, 250, 253, + 255, 253, 250, 244, 235, 224, 212, 197, 180, 161, 141, 120, 97, 74, 49, 24 +}; + +struct note { + unsigned char key, instrument, volume, effect, param; +}; + +struct channel { + struct replay *replay; + struct instrument *instrument; + struct sample *sample; + struct note note; + int id, key_on, random_seed, pl_row; + int sample_off, sample_idx, sample_fra, freq, ampl, pann; + int volume, panning, fadeout_vol, vol_env_tick, pan_env_tick; + int period, porta_period, retrig_count, fx_count, av_count; + int porta_up_param, porta_down_param, tone_porta_param, offset_param; + int fine_porta_up_param, fine_porta_down_param, xfine_porta_param; + int arpeggio_param, vol_slide_param, gvol_slide_param, pan_slide_param; + int fine_vslide_up_param, fine_vslide_down_param; + int retrig_volume, retrig_ticks, tremor_on_ticks, tremor_off_ticks; + int vibrato_type, vibrato_phase, vibrato_speed, vibrato_depth; + int tremolo_type, tremolo_phase, tremolo_speed, tremolo_depth; + int tremolo_add, vibrato_add, arpeggio_add; +}; + +struct replay { + int sample_rate, interpolation, global_vol; + int seq_pos, break_pos, row, next_row, tick; + int speed, tempo, pl_count, pl_chan; + int *ramp_buf; + char **play_count; + struct channel *channels; + struct module *module; +}; + +static int exp_2( int x ) { + int c, m, y; + int x0 = ( x & FP_MASK ) >> ( FP_SHIFT - 7 ); + c = exp2_table[ x0 ]; + m = exp2_table[ x0 + 1 ] - c; + y = ( m * ( x & ( FP_MASK >> 7 ) ) >> 8 ) + c; + return ( y << FP_SHIFT ) >> ( FP_SHIFT - ( x >> FP_SHIFT ) ); +} + +static int log_2( int x ) { + int step; + int y = 16 << FP_SHIFT; + for( step = y; step > 0; step >>= 1 ) { + if( exp_2( y - step ) >= x ) { + y -= step; + } + } + return y; +} + +static char* data_ascii( struct data *data, int offset, int length, char *dest ) { + int idx, chr; + memset( dest, 32, length ); + if( offset > data->length ) { + offset = data->length; + } + if( ( unsigned int ) offset + length > ( unsigned int ) data->length ) { + length = data->length - offset; + } + for( idx = 0; idx < length; idx++ ) { + chr = data->buffer[ offset + idx ] & 0xFF; + if( chr > 32 ) { + dest[ idx ] = chr; + } + } + return dest; +} + +static int data_s8( struct data *data, int offset ) { + int value = 0; + if( offset < data->length ) { + value = data->buffer[ offset ]; + value = ( value & 0x7F ) - ( value & 0x80 ); + } + return value; +} + +static int data_u8( struct data *data, int offset ) { + int value = 0; + if( offset < data->length ) { + value = data->buffer[ offset ] & 0xFF; + } + return value; +} + +static int data_u16be( struct data *data, int offset ) { + int value = 0; + if( offset + 1 < data->length ) { + value = ( ( data->buffer[ offset ] & 0xFF ) << 8 ) + | ( data->buffer[ offset + 1 ] & 0xFF ); + } + return value; +} + +static int data_u16le( struct data *data, int offset ) { + int value = 0; + if( offset + 1 < data->length ) { + value = ( data->buffer[ offset ] & 0xFF ) + | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ); + } + return value; +} + +static unsigned int data_u32le( struct data *data, int offset ) { + unsigned int value = 0; + if( offset + 3 < data->length ) { + value = ( data->buffer[ offset ] & 0xFF ) + | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ) + | ( ( data->buffer[ offset + 2 ] & 0xFF ) << 16 ) + | ( ( data->buffer[ offset + 3 ] & 0xFF ) << 24 ); + } + return value; +} + +static void data_sam_s8( struct data *data, int offset, int count, short *dest ) { + int idx, amp, length = data->length; + char *buffer = data->buffer; + if( offset > length ) { + offset = length; + } + if( offset + count > length ) { + count = length - offset; + } + for( idx = 0; idx < count; idx++ ) { + amp = ( buffer[ offset + idx ] & 0xFF ) << 8; + dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + } +} + +static void data_sam_s16le( struct data *data, int offset, int count, short *dest ) { + int idx, amp, length = data->length; + char *buffer = data->buffer; + if( offset > length ) { + offset = length; + } + if( offset + count * 2 > length ) { + count = ( length - offset ) / 2; + } + for( idx = 0; idx < count; idx++ ) { + amp = ( buffer[ offset + idx * 2 ] & 0xFF ) | ( buffer[ offset + idx * 2 + 1 ] << 8 ); + dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + } +} + +static int envelope_next_tick( struct envelope *envelope, int tick, int key_on ) { + tick++; + if( envelope->looped && tick >= envelope->loop_end_tick ) { + tick = envelope->loop_start_tick; + } + if( envelope->sustain && key_on && tick >= envelope->sustain_tick ) { + tick = envelope->sustain_tick; + } + return tick; +} + +static int envelope_calculate_ampl( struct envelope *envelope, int tick ) { + int idx, point, dt, da; + int ampl = envelope->points_ampl[ envelope->num_points - 1 ]; + if( tick < envelope->points_tick[ envelope->num_points - 1 ] ) { + point = 0; + for( idx = 1; idx < envelope->num_points; idx++ ) { + if( envelope->points_tick[ idx ] <= tick ) { + point = idx; + } + } + dt = envelope->points_tick[ point + 1 ] - envelope->points_tick[ point ]; + da = envelope->points_ampl[ point + 1 ] - envelope->points_ampl[ point ]; + ampl = envelope->points_ampl[ point ]; + ampl += ( ( da << 24 ) / dt ) * ( tick - envelope->points_tick[ point ] ) >> 24; + } + return ampl; +} + +static void sample_ping_pong( struct sample *sample ) { + int idx; + int loop_start = sample->loop_start; + int loop_length = sample->loop_length; + int loop_end = loop_start + loop_length; + short *sample_data = sample->data; + short *new_data = (short*)calloc( loop_end + loop_length + 1, sizeof( short ) ); + if( new_data ) { + memcpy( new_data, sample_data, loop_end * sizeof( short ) ); + for( idx = 0; idx < loop_length; idx++ ) { + new_data[ loop_end + idx ] = sample_data[ loop_end - idx - 1 ]; + } + free( sample->data ); + sample->data = new_data; + sample->loop_length *= 2; + sample->data[ loop_start + sample->loop_length ] = sample->data[ loop_start ]; + } +} + +/* Deallocate the specified module. */ +void dispose_module( struct module *module ) { + int idx, sam; + struct instrument *instrument; + free( module->default_panning ); + free( module->sequence ); + if( module->patterns ) { + for( idx = 0; idx < module->num_patterns; idx++ ) { + free( module->patterns[ idx ].data ); + } + free( module->patterns ); + } + if( module->instruments ) { + for( idx = 0; idx <= module->num_instruments; idx++ ) { + instrument = &module->instruments[ idx ]; + if( instrument->samples ) { + for( sam = 0; sam < instrument->num_samples; sam++ ) { + free( instrument->samples[ sam ].data ); + } + free( instrument->samples ); + } + } + free( module->instruments ); + } + free( module ); +} + +static struct module* module_load_xm( struct data *data, char *message ) { + int delta_env, offset, next_offset, idx, entry; + int num_rows, num_notes, pat_data_len, pat_data_offset; + int sam, sam_head_offset, sam_data_bytes, sam_data_samples; + int num_samples, sam_loop_start, sam_loop_length, amp; + int note, flags, key, ins, vol, fxc, fxp; + int point, point_tick, point_offset; + int looped, ping_pong, sixteen_bit; + char ascii[ 16 ], *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + if( data_u16le( data, 58 ) != 0x0104 ) { + strcpy( message, "XM format version must be 0x0104!" ); + dispose_module( module ); + return NULL; + } + data_ascii( data, 17, 20, module->name ); + delta_env = !memcmp( data_ascii( data, 38, 15, ascii ), "DigiBooster Pro", 15 ); + offset = 60 + data_u32le( data, 60 ); + module->sequence_len = data_u16le( data, 64 ); + module->restart_pos = data_u16le( data, 66 ); + module->num_channels = data_u16le( data, 68 ); + module->num_patterns = data_u16le( data, 70 ); + module->num_instruments = data_u16le( data, 72 ); + module->linear_periods = data_u16le( data, 74 ) & 0x1; + module->default_gvol = 64; + module->default_speed = data_u16le( data, 76 ); + module->default_tempo = data_u16le( data, 78 ); + module->c2_rate = 8363; + module->gain = 64; + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( !module->default_panning ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + module->default_panning[ idx ] = 128; + } + module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); + if( !module->sequence ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->sequence_len; idx++ ) { + entry = data_u8( data, 80 + idx ); + module->sequence[ idx ] = entry < module->num_patterns ? entry : 0; + } + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_patterns; idx++ ) { + if( data_u8( data, offset + 4 ) ) { + strcpy( message, "Unknown pattern packing type!" ); + dispose_module( module ); + return NULL; + } + num_rows = data_u16le( data, offset + 5 ); + if( num_rows < 1 ) { + num_rows = 1; + } + pat_data_len = data_u16le( data, offset + 7 ); + offset += data_u32le( data, offset ); + next_offset = offset + pat_data_len; + num_notes = num_rows * module->num_channels; + pattern_data = (char*)calloc( num_notes, 5 ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ idx ].num_channels = module->num_channels; + module->patterns[ idx ].num_rows = num_rows; + module->patterns[ idx ].data = pattern_data; + if( pat_data_len > 0 ) { + pat_data_offset = 0; + for( note = 0; note < num_notes; note++ ) { + flags = data_u8( data, offset ); + if( ( flags & 0x80 ) == 0 ) { + flags = 0x1F; + } else { + offset++; + } + key = ( flags & 0x01 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = key; + ins = ( flags & 0x02 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = ins; + vol = ( flags & 0x04 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = vol; + fxc = ( flags & 0x08 ) > 0 ? data_u8( data, offset++ ) : 0; + fxp = ( flags & 0x10 ) > 0 ? data_u8( data, offset++ ) : 0; + if( fxc >= 0x40 ) { + fxc = fxp = 0; + } + pattern_data[ pat_data_offset++ ] = fxc; + pattern_data[ pat_data_offset++ ] = fxp; + } + } + offset = next_offset; + } + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + data_ascii( data, offset + 4, 22, instrument->name ); + num_samples = data_u16le( data, offset + 27 ); + instrument->num_samples = ( num_samples > 0 ) ? num_samples : 1; + instrument->samples = (struct sample*)calloc( instrument->num_samples, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + if( num_samples > 0 ) { + for( key = 0; key < 96; key++ ) { + instrument->key_to_sample[ key + 1 ] = data_u8( data, offset + 33 + key ); + } + point_tick = 0; + for( point = 0; point < 12; point++ ) { + point_offset = offset + 129 + ( point * 4 ); + point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); + instrument->vol_env.points_tick[ point ] = point_tick; + instrument->vol_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); + } + point_tick = 0; + for( point = 0; point < 12; point++ ) { + point_offset = offset + 177 + ( point * 4 ); + point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); + instrument->pan_env.points_tick[ point ] = point_tick; + instrument->pan_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); + } + instrument->vol_env.num_points = data_u8( data, offset + 225 ); + if( instrument->vol_env.num_points > 12 ) { + instrument->vol_env.num_points = 0; + } + instrument->pan_env.num_points = data_u8( data, offset + 226 ); + if( instrument->pan_env.num_points > 12 ) { + instrument->pan_env.num_points = 0; + } + instrument->vol_env.sustain_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 227 ) & 0xF ]; + instrument->vol_env.loop_start_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 228 ) & 0xF ]; + instrument->vol_env.loop_end_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 229 ) & 0xF ]; + instrument->pan_env.sustain_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 230 ) & 0xF ]; + instrument->pan_env.loop_start_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 231 ) & 0xF ]; + instrument->pan_env.loop_end_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 232 ) & 0xF ]; + instrument->vol_env.enabled = instrument->vol_env.num_points > 0 && ( data_u8( data, offset + 233 ) & 0x1 ); + instrument->vol_env.sustain = ( data_u8( data, offset + 233 ) & 0x2 ) > 0; + instrument->vol_env.looped = ( data_u8( data, offset + 233 ) & 0x4 ) > 0; + instrument->pan_env.enabled = instrument->pan_env.num_points > 0 && ( data_u8( data, offset + 234 ) & 0x1 ); + instrument->pan_env.sustain = ( data_u8( data, offset + 234 ) & 0x2 ) > 0; + instrument->pan_env.looped = ( data_u8( data, offset + 234 ) & 0x4 ) > 0; + instrument->vib_type = data_u8( data, offset + 235 ); + instrument->vib_sweep = data_u8( data, offset + 236 ); + instrument->vib_depth = data_u8( data, offset + 237 ); + instrument->vib_rate = data_u8( data, offset + 238 ); + instrument->vol_fadeout = data_u16le( data, offset + 239 ); + } + offset += data_u32le( data, offset ); + sam_head_offset = offset; + offset += num_samples * 40; + for( sam = 0; sam < num_samples; sam++ ) { + sample = &instrument->samples[ sam ]; + sam_data_bytes = data_u32le( data, sam_head_offset ); + sam_loop_start = data_u32le( data, sam_head_offset + 4 ); + sam_loop_length = data_u32le( data, sam_head_offset + 8 ); + sample->volume = data_u8( data, sam_head_offset + 12 ); + sample->fine_tune = data_s8( data, sam_head_offset + 13 ); + looped = ( data_u8( data, sam_head_offset + 14 ) & 0x3 ) > 0; + ping_pong = ( data_u8( data, sam_head_offset + 14 ) & 0x2 ) > 0; + sixteen_bit = ( data_u8( data, sam_head_offset + 14 ) & 0x10 ) > 0; + sample->panning = data_u8( data, sam_head_offset + 15 ) + 1; + sample->rel_note = data_s8( data, sam_head_offset + 16 ); + data_ascii( data, sam_head_offset + 18, 22, sample->name ); + sam_head_offset += 40; + sam_data_samples = sam_data_bytes; + if( sixteen_bit ) { + sam_data_samples = sam_data_samples >> 1; + sam_loop_start = sam_loop_start >> 1; + sam_loop_length = sam_loop_length >> 1; + } + if( !looped || ( sam_loop_start + sam_loop_length ) > sam_data_samples ) { + sam_loop_start = sam_data_samples; + sam_loop_length = 0; + } + sample->loop_start = sam_loop_start; + sample->loop_length = sam_loop_length; + sample->data = (short*)calloc( sam_data_samples + 1, sizeof( short ) ); + if( sample->data ) { + if( sixteen_bit ) { + data_sam_s16le( data, offset, sam_data_samples, sample->data ); + } else { + data_sam_s8( data, offset, sam_data_samples, sample->data ); + } + amp = 0; + for( idx = 0; idx < sam_data_samples; idx++ ) { + amp = amp + sample->data[ idx ]; + amp = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + sample->data[ idx ] = amp; + } + sample->data[ sam_loop_start + sam_loop_length ] = sample->data[ sam_loop_start ]; + if( ping_pong ) { + sample_ping_pong( sample ); + } + } else { + dispose_module( module ); + return NULL; + } + offset += sam_data_bytes; + } + } + } + return module; +} + +static struct module* module_load_s3m( struct data *data, char *message ) { + int idx, module_data_idx, inst_offset, flags; + int version, sixteen_bit, tune, signed_samples; + int stereo_mode, default_pan, channel_map[ 32 ]; + int sample_offset, sample_length, loop_start, loop_length; + int pat_offset, note_offset, row, chan, token; + int key, ins, volume, effect, param, panning; + char *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + data_ascii( data, 0, 28, module->name ); + module->sequence_len = data_u16le( data, 32 ); + module->num_instruments = data_u16le( data, 34 ); + module->num_patterns = data_u16le( data, 36 ); + flags = data_u16le( data, 38 ); + version = data_u16le( data, 40 ); + module->fast_vol_slides = ( ( flags & 0x40 ) == 0x40 ) || version == 0x1300; + signed_samples = data_u16le( data, 42 ) == 1; + if( data_u32le( data, 44 ) != 0x4d524353 ) { + strcpy( message, "Not an S3M file!" ); + dispose_module( module ); + return NULL; + } + module->default_gvol = data_u8( data, 48 ); + module->default_speed = data_u8( data, 49 ); + module->default_tempo = data_u8( data, 50 ); + module->c2_rate = 8363; + module->gain = data_u8( data, 51 ) & 0x7F; + stereo_mode = ( data_u8( data, 51 ) & 0x80 ) == 0x80; + default_pan = data_u8( data, 53 ) == 0xFC; + for( idx = 0; idx < 32; idx++ ) { + channel_map[ idx ] = -1; + if( data_u8( data, 64 + idx ) < 16 ) { + channel_map[ idx ] = module->num_channels++; + } + } + module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); + if( !module->sequence ){ + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->sequence_len; idx++ ) { + module->sequence[ idx ] = data_u8( data, 96 + idx ); + } + module_data_idx = 96 + module->sequence_len; + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + sample = &instrument->samples[ 0 ]; + inst_offset = data_u16le( data, module_data_idx ) << 4; + module_data_idx += 2; + data_ascii( data, inst_offset + 48, 28, instrument->name ); + if( data_u8( data, inst_offset ) == 1 && data_u16le( data, inst_offset + 76 ) == 0x4353 ) { + sample_offset = ( data_u8( data, inst_offset + 13 ) << 20 ) + + ( data_u16le( data, inst_offset + 14 ) << 4 ); + sample_length = data_u32le( data, inst_offset + 16 ); + loop_start = data_u32le( data, inst_offset + 20 ); + loop_length = data_u32le( data, inst_offset + 24 ) - loop_start; + sample->volume = data_u8( data, inst_offset + 28 ); + if( data_u8( data, inst_offset + 30 ) != 0 ) { + strcpy( message, "Packed samples not supported!" ); + dispose_module( module ); + return NULL; + } + if( loop_start + loop_length > sample_length ) { + loop_length = sample_length - loop_start; + } + if( loop_length < 1 || !( data_u8( data, inst_offset + 31 ) & 0x1 ) ) { + loop_start = sample_length; + loop_length = 0; + } + sample->loop_start = loop_start; + sample->loop_length = loop_length; + /* stereo = data_u8( data, inst_offset + 31 ) & 0x2; */ + sixteen_bit = data_u8( data, inst_offset + 31 ) & 0x4; + tune = ( log_2( data_u32le( data, inst_offset + 32 ) ) - log_2( module->c2_rate ) ) * 12; + sample->rel_note = tune >> FP_SHIFT; + sample->fine_tune = ( tune & FP_MASK ) >> ( FP_SHIFT - 7 ); + sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); + if( sample->data ) { + if( sixteen_bit ) { + data_sam_s16le( data, sample_offset, sample_length, sample->data ); + } else { + data_sam_s8( data, sample_offset, sample_length, sample->data ); + } + if( !signed_samples ) { + for( idx = 0; idx < sample_length; idx++ ) { + sample->data[ idx ] = ( sample->data[ idx ] & 0xFFFF ) - 32768; + } + } + sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; + } else { + dispose_module( module ); + return NULL; + } + } + } + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_patterns; idx++ ) { + module->patterns[ idx ].num_channels = module->num_channels; + module->patterns[ idx ].num_rows = 64; + pattern_data = (char*)calloc( module->num_channels * 64, 5 ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ idx ].data = pattern_data; + pat_offset = ( data_u16le( data, module_data_idx ) << 4 ) + 2; + row = 0; + while( row < 64 ) { + token = data_u8( data, pat_offset++ ); + if( token ) { + key = ins = 0; + if( ( token & 0x20 ) == 0x20 ) { + /* Key + Instrument.*/ + key = data_u8( data, pat_offset++ ); + ins = data_u8( data, pat_offset++ ); + if( key < 0xFE ) { + key = ( key >> 4 ) * 12 + ( key & 0xF ) + 1; + } else if( key == 0xFF ) { + key = 0; + } + } + volume = 0; + if( ( token & 0x40 ) == 0x40 ) { + /* Volume Column.*/ + volume = ( data_u8( data, pat_offset++ ) & 0x7F ) + 0x10; + if( volume > 0x50 ) { + volume = 0; + } + } + effect = param = 0; + if( ( token & 0x80 ) == 0x80 ) { + /* Effect + Param.*/ + effect = data_u8( data, pat_offset++ ); + param = data_u8( data, pat_offset++ ); + if( effect < 1 || effect >= 0x40 ) { + effect = param = 0; + } else if( effect > 0 ) { + effect += 0x80; + } + } + chan = channel_map[ token & 0x1F ]; + if( chan >= 0 ) { + note_offset = ( row * module->num_channels + chan ) * 5; + pattern_data[ note_offset ] = key; + pattern_data[ note_offset + 1 ] = ins; + pattern_data[ note_offset + 2 ] = volume; + pattern_data[ note_offset + 3 ] = effect; + pattern_data[ note_offset + 4 ] = param; + } + } else { + row++; + } + } + module_data_idx += 2; + } + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( module->default_panning ) { + for( chan = 0; chan < 32; chan++ ) { + if( channel_map[ chan ] >= 0 ) { + panning = 7; + if( stereo_mode ) { + panning = 12; + if( data_u8( data, 64 + chan ) < 8 ) { + panning = 3; + } + } + if( default_pan ) { + flags = data_u8( data, module_data_idx + chan ); + if( ( flags & 0x20 ) == 0x20 ) { + panning = flags & 0xF; + } + } + module->default_panning[ channel_map[ chan ] ] = panning * 17; + } + } + } else { + dispose_module( module ); + return NULL; + } + } + return module; +} + +static struct module* module_load_mod( struct data *data, char *message ) { + int idx, pat, module_data_idx, pat_data_len, pat_data_idx; + int period, key, ins, effect, param, fine_tune; + int sample_length, loop_start, loop_length; + char *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + data_ascii( data, 0, 20, module->name ); + module->sequence_len = data_u8( data, 950 ) & 0x7F; + module->restart_pos = data_u8( data, 951 ) & 0x7F; + if( module->restart_pos >= module->sequence_len ) { + module->restart_pos = 0; + } + module->sequence = (unsigned char*)calloc( 128, sizeof( unsigned char ) ); + if( !module->sequence ){ + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < 128; idx++ ) { + pat = data_u8( data, 952 + idx ) & 0x7F; + module->sequence[ idx ] = pat; + if( pat >= module->num_patterns ) { + module->num_patterns = pat + 1; + } + } + switch( data_u16be( data, 1082 ) ) { + case 0x4b2e: /* M.K. */ + case 0x4b21: /* M!K! */ + case 0x5434: /* FLT4 */ + module->num_channels = 4; + module->c2_rate = 8287; + module->gain = 64; + break; + case 0x484e: /* xCHN */ + module->num_channels = data_u8( data, 1080 ) - 48; + module->c2_rate = 8363; + module->gain = 32; + break; + case 0x4348: /* xxCH */ + module->num_channels = ( data_u8( data, 1080 ) - 48 ) * 10; + module->num_channels += data_u8( data, 1081 ) - 48; + module->c2_rate = 8363; + module->gain = 32; + break; + default: + strcpy( message, "MOD Format not recognised!" ); + dispose_module( module ); + return NULL; + } + module->default_gvol = 64; + module->default_speed = 6; + module->default_tempo = 125; + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( !module->default_panning ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + module->default_panning[ idx ] = 51; + if( ( idx & 3 ) == 1 || ( idx & 3 ) == 2 ) { + module->default_panning[ idx ] = 204; + } + } + module_data_idx = 1084; + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + pat_data_len = module->num_channels * 64 * 5; + for( pat = 0; pat < module->num_patterns; pat++ ) { + module->patterns[ pat ].num_channels = module->num_channels; + module->patterns[ pat ].num_rows = 64; + pattern_data = (char*)calloc( 1, pat_data_len ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ pat ].data = pattern_data; + for( pat_data_idx = 0; pat_data_idx < pat_data_len; pat_data_idx += 5 ) { + period = ( data_u8( data, module_data_idx ) & 0xF ) << 8; + period = ( period | data_u8( data, module_data_idx + 1 ) ) * 4; + if( period >= 112 && period <= 6848 ) { + key = -12 * log_2( ( period << FP_SHIFT ) / 29021 ); + key = ( key + ( key & ( FP_ONE >> 1 ) ) ) >> FP_SHIFT; + pattern_data[ pat_data_idx ] = key; + } + ins = ( data_u8( data, module_data_idx + 2 ) & 0xF0 ) >> 4; + ins = ins | ( data_u8( data, module_data_idx ) & 0x10 ); + pattern_data[ pat_data_idx + 1 ] = ins; + effect = data_u8( data, module_data_idx + 2 ) & 0x0F; + param = data_u8( data, module_data_idx + 3 ); + if( param == 0 && ( effect < 3 || effect == 0xA ) ) { + effect = 0; + } + if( param == 0 && ( effect == 5 || effect == 6 ) ) { + effect -= 2; + } + if( effect == 8 && module->num_channels == 4 ) { + effect = param = 0; + } + pattern_data[ pat_data_idx + 3 ] = effect; + pattern_data[ pat_data_idx + 4 ] = param; + module_data_idx += 4; + } + } + module->num_instruments = 31; + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + sample = &instrument->samples[ 0 ]; + data_ascii( data, ins * 30 - 10, 22, instrument->name ); + sample_length = data_u16be( data, ins * 30 + 12 ) * 2; + fine_tune = ( data_u8( data, ins * 30 + 14 ) & 0xF ) << 4; + sample->fine_tune = ( fine_tune & 0x7F ) - ( fine_tune & 0x80 ); + sample->volume = data_u8( data, ins * 30 + 15 ) & 0x7F; + if( sample->volume > 64 ) { + sample->volume = 64; + } + loop_start = data_u16be( data, ins * 30 + 16 ) * 2; + loop_length = data_u16be( data, ins * 30 + 18 ) * 2; + if( loop_start + loop_length > sample_length ) { + loop_length = sample_length - loop_start; + } + if( loop_length < 4 ) { + loop_start = sample_length; + loop_length = 0; + } + sample->loop_start = loop_start; + sample->loop_length = loop_length; + sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); + if( sample->data ) { + data_sam_s8( data, module_data_idx, sample_length, sample->data ); + sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; + } else { + dispose_module( module ); + return NULL; + } + module_data_idx += sample_length; + } + } + return module; +} + +/* Allocate and initialize a module from the specified data, returns NULL on error. + Message should point to a 64-character buffer to receive error messages. */ +struct module* module_load( struct data *data, char *message ) { + char ascii[ 16 ]; + struct module* module; + if( !memcmp( data_ascii( data, 0, 16, ascii ), "Extended Module:", 16 ) ) { + module = module_load_xm( data, message ); + } else if( !memcmp( data_ascii( data, 44, 4, ascii ), "SCRM", 4 ) ) { + module = module_load_s3m( data, message ); + } else { + module = module_load_mod( data, message ); + } + return module; +} + +static void pattern_get_note( struct pattern *pattern, int row, int chan, struct note *dest ) { + int offset = ( row * pattern->num_channels + chan ) * 5; + if( offset >= 0 && row < pattern->num_rows && chan < pattern->num_channels ) { + dest->key = pattern->data[ offset ]; + dest->instrument = pattern->data[ offset + 1 ]; + dest->volume = pattern->data[ offset + 2 ]; + dest->effect = pattern->data[ offset + 3 ]; + dest->param = pattern->data[ offset + 4 ]; + } else { + memset( dest, 0, sizeof( struct note ) ); + } +} + +static void channel_init( struct channel *channel, struct replay *replay, int idx ) { + memset( channel, 0, sizeof( struct channel ) ); + channel->replay = replay; + channel->id = idx; + channel->panning = replay->module->default_panning[ idx ]; + channel->instrument = &replay->module->instruments[ 0 ]; + channel->sample = &channel->instrument->samples[ 0 ]; + channel->random_seed = ( idx + 1 ) * 0xABCDEF; +} + +static void channel_volume_slide( struct channel *channel ) { + int up = channel->vol_slide_param >> 4; + int down = channel->vol_slide_param & 0xF; + if( down == 0xF && up > 0 ) { + /* Fine slide up.*/ + if( channel->fx_count == 0 ) { + channel->volume += up; + } + } else if( up == 0xF && down > 0 ) { + /* Fine slide down.*/ + if( channel->fx_count == 0 ) { + channel->volume -= down; + } + } else if( channel->fx_count > 0 || channel->replay->module->fast_vol_slides ) { + /* Normal.*/ + channel->volume += up - down; + } + if( channel->volume > 64 ) { + channel->volume = 64; + } + if( channel->volume < 0 ) { + channel->volume = 0; + } +} + +static void channel_porta_up( struct channel *channel, int param ) { + switch( param & 0xF0 ) { + case 0xE0: /* Extra-fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period -= param & 0xF; + } + break; + case 0xF0: /* Fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period -= ( param & 0xF ) << 2; + } + break; + default:/* Normal porta.*/ + if( channel->fx_count > 0 ) { + channel->period -= param << 2; + } + break; + } + if( channel->period < 0 ) { + channel->period = 0; + } +} + +static void channel_porta_down( struct channel *channel, int param ) { + if( channel->period > 0 ) { + switch( param & 0xF0 ) { + case 0xE0: /* Extra-fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period += param & 0xF; + } + break; + case 0xF0: /* Fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period += ( param & 0xF ) << 2; + } + break; + default:/* Normal porta.*/ + if( channel->fx_count > 0 ) { + channel->period += param << 2; + } + break; + } + if( channel->period > 65535 ) { + channel->period = 65535; + } + } +} + +static void channel_tone_porta( struct channel *channel ) { + if( channel->period > 0 ) { + if( channel->period < channel->porta_period ) { + channel->period += channel->tone_porta_param << 2; + if( channel->period > channel->porta_period ) { + channel->period = channel->porta_period; + } + } else { + channel->period -= channel->tone_porta_param << 2; + if( channel->period < channel->porta_period ) { + channel->period = channel->porta_period; + } + } + } +} + +static int channel_waveform( struct channel *channel, int phase, int type ) { + int amplitude = 0; + switch( type ) { + default: /* Sine. */ + amplitude = sine_table[ phase & 0x1F ]; + if( ( phase & 0x20 ) > 0 ) { + amplitude = -amplitude; + } + break; + case 6: /* Saw Up.*/ + amplitude = ( ( ( phase + 0x20 ) & 0x3F ) << 3 ) - 255; + break; + case 1: case 7: /* Saw Down. */ + amplitude = 255 - ( ( ( phase + 0x20 ) & 0x3F ) << 3 ); + break; + case 2: case 5: /* Square. */ + amplitude = ( phase & 0x20 ) > 0 ? 255 : -255; + break; + case 3: case 8: /* Random. */ + amplitude = ( channel->random_seed >> 20 ) - 255; + channel->random_seed = ( channel->random_seed * 65 + 17 ) & 0x1FFFFFFF; + break; + } + return amplitude; +} + +static void channel_vibrato( struct channel *channel, int fine ) { + int wave = channel_waveform( channel, channel->vibrato_phase, channel->vibrato_type & 0x3 ); + channel->vibrato_add = wave * channel->vibrato_depth >> ( fine ? 7 : 5 ); +} + +static void channel_tremolo( struct channel *channel ) { + int wave = channel_waveform( channel, channel->tremolo_phase, channel->tremolo_type & 0x3 ); + channel->tremolo_add = wave * channel->tremolo_depth >> 6; +} + +static void channel_tremor( struct channel *channel ) { + if( channel->retrig_count >= channel->tremor_on_ticks ) { + channel->tremolo_add = -64; + } + if( channel->retrig_count >= ( channel->tremor_on_ticks + channel->tremor_off_ticks ) ) { + channel->tremolo_add = channel->retrig_count = 0; + } +} + +static void channel_retrig_vol_slide( struct channel *channel ) { + if( channel->retrig_count >= channel->retrig_ticks ) { + channel->retrig_count = channel->sample_idx = channel->sample_fra = 0; + switch( channel->retrig_volume ) { + case 0x1: channel->volume = channel->volume - 1; break; + case 0x2: channel->volume = channel->volume - 2; break; + case 0x3: channel->volume = channel->volume - 4; break; + case 0x4: channel->volume = channel->volume - 8; break; + case 0x5: channel->volume = channel->volume - 16; break; + case 0x6: channel->volume = channel->volume * 2 / 3; break; + case 0x7: channel->volume = channel->volume >> 1; break; + case 0x8: /* ? */ break; + case 0x9: channel->volume = channel->volume + 1; break; + case 0xA: channel->volume = channel->volume + 2; break; + case 0xB: channel->volume = channel->volume + 4; break; + case 0xC: channel->volume = channel->volume + 8; break; + case 0xD: channel->volume = channel->volume + 16; break; + case 0xE: channel->volume = channel->volume * 3 / 2; break; + case 0xF: channel->volume = channel->volume << 1; break; + } + if( channel->volume < 0 ) { + channel->volume = 0; + } + if( channel->volume > 64 ) { + channel->volume = 64; + } + } +} + +static void channel_trigger( struct channel *channel ) { + int key, sam, porta, period, fine_tune, ins = channel->note.instrument; + struct sample *sample; + if( ins > 0 && ins <= channel->replay->module->num_instruments ) { + channel->instrument = &channel->replay->module->instruments[ ins ]; + key = channel->note.key < 97 ? channel->note.key : 0; + sam = channel->instrument->key_to_sample[ key ]; + sample = &channel->instrument->samples[ sam ]; + channel->volume = sample->volume >= 64 ? 64 : sample->volume & 0x3F; + if( sample->panning > 0 ) { + channel->panning = ( sample->panning - 1 ) & 0xFF; + } + if( channel->period > 0 && sample->loop_length > 1 ) { + /* Amiga trigger.*/ + channel->sample = sample; + } + channel->sample_off = 0; + channel->vol_env_tick = channel->pan_env_tick = 0; + channel->fadeout_vol = 32768; + channel->key_on = 1; + } + if( channel->note.effect == 0x09 || channel->note.effect == 0x8F ) { + /* Set Sample Offset. */ + if( channel->note.param > 0 ) { + channel->offset_param = channel->note.param; + } + channel->sample_off = channel->offset_param << 8; + } + if( channel->note.volume >= 0x10 && channel->note.volume < 0x60 ) { + channel->volume = channel->note.volume < 0x50 ? channel->note.volume - 0x10 : 64; + } + switch( channel->note.volume & 0xF0 ) { + case 0x80: /* Fine Vol Down.*/ + channel->volume -= channel->note.volume & 0xF; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x90: /* Fine Vol Up.*/ + channel->volume += channel->note.volume & 0xF; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0xA0: /* Set Vibrato Speed.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->vibrato_speed = channel->note.volume & 0xF; + } + break; + case 0xB0: /* Vibrato.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.volume & 0xF; + } + channel_vibrato( channel, 0 ); + break; + case 0xC0: /* Set Panning.*/ + channel->panning = ( channel->note.volume & 0xF ) * 17; + break; + case 0xF0: /* Tone Porta.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->tone_porta_param = channel->note.volume & 0xF; + } + break; + } + if( channel->note.key > 0 ) { + if( channel->note.key > 96 ) { + channel->key_on = 0; + } else { + porta = ( channel->note.volume & 0xF0 ) == 0xF0 || + channel->note.effect == 0x03 || channel->note.effect == 0x05 || + channel->note.effect == 0x87 || channel->note.effect == 0x8C; + if( !porta ) { + ins = channel->instrument->key_to_sample[ channel->note.key ]; + channel->sample = &channel->instrument->samples[ ins ]; + } + fine_tune = channel->sample->fine_tune; + if( channel->note.effect == 0x75 || channel->note.effect == 0xF2 ) { + /* Set Fine Tune. */ + fine_tune = ( ( channel->note.param & 0xF ) << 4 ) - 128; + } + key = channel->note.key + channel->sample->rel_note; + if( key < 1 ) { + key = 1; + } + if( key > 120 ) { + key = 120; + } + period = ( key << 6 ) + ( fine_tune >> 1 ); + if( channel->replay->module->linear_periods ) { + channel->porta_period = 7744 - period; + } else { + channel->porta_period = 29021 * exp_2( ( period << FP_SHIFT ) / -768 ) >> FP_SHIFT; + } + if( !porta ) { + channel->period = channel->porta_period; + channel->sample_idx = channel->sample_off; + channel->sample_fra = 0; + if( channel->vibrato_type < 4 ) { + channel->vibrato_phase = 0; + } + if( channel->tremolo_type < 4 ) { + channel->tremolo_phase = 0; + } + channel->retrig_count = channel->av_count = 0; + } + } + } +} + +static void channel_update_envelopes( struct channel *channel ) { + if( channel->instrument->vol_env.enabled ) { + if( !channel->key_on ) { + channel->fadeout_vol -= channel->instrument->vol_fadeout; + if( channel->fadeout_vol < 0 ) { + channel->fadeout_vol = 0; + } + } + channel->vol_env_tick = envelope_next_tick( &channel->instrument->vol_env, + channel->vol_env_tick, channel->key_on ); + } + if( channel->instrument->pan_env.enabled ) { + channel->pan_env_tick = envelope_next_tick( &channel->instrument->pan_env, + channel->pan_env_tick, channel->key_on ); + } +} + +static void channel_auto_vibrato( struct channel *channel ) { + int sweep, rate, type, wave; + int depth = channel->instrument->vib_depth & 0x7F; + if( depth > 0 ) { + sweep = channel->instrument->vib_sweep & 0x7F; + rate = channel->instrument->vib_rate & 0x7F; + type = channel->instrument->vib_type; + if( channel->av_count < sweep ) { + depth = depth * channel->av_count / sweep; + } + wave = channel_waveform( channel, channel->av_count * rate >> 2, type + 4 ); + channel->vibrato_add += wave * depth >> 8; + channel->av_count++; + } +} + +static void channel_calculate_freq( struct channel *channel ) { + int per = channel->period + channel->vibrato_add; + if( channel->replay->module->linear_periods ) { + per = per - ( channel->arpeggio_add << 6 ); + if( per < 28 || per > 7680 ) { + per = 7680; + } + channel->freq = ( ( channel->replay->module->c2_rate >> 4 ) + * exp_2( ( ( 4608 - per ) << FP_SHIFT ) / 768 ) ) >> ( FP_SHIFT - 4 ); + } else { + if( per > 29021 ) { + per = 29021; + } + per = ( per << FP_SHIFT ) / exp_2( ( channel->arpeggio_add << FP_SHIFT ) / 12 ); + if( per < 28 ) { + per = 29021; + } + channel->freq = channel->replay->module->c2_rate * 1712 / per; + } +} + +static void channel_calculate_ampl( struct channel *channel ) { + int vol, range, env_pan = 32, env_vol = channel->key_on ? 64 : 0; + if( channel->instrument->vol_env.enabled ) { + env_vol = envelope_calculate_ampl( &channel->instrument->vol_env, channel->vol_env_tick ); + } + vol = channel->volume + channel->tremolo_add; + if( vol > 64 ) { + vol = 64; + } + if( vol < 0 ) { + vol = 0; + } + vol = ( vol * channel->replay->module->gain * FP_ONE ) >> 13; + vol = ( vol * channel->fadeout_vol ) >> 15; + channel->ampl = ( vol * channel->replay->global_vol * env_vol ) >> 12; + if( channel->instrument->pan_env.enabled ) { + env_pan = envelope_calculate_ampl( &channel->instrument->pan_env, channel->pan_env_tick ); + } + range = ( channel->panning < 128 ) ? channel->panning : ( 255 - channel->panning ); + channel->pann = channel->panning + ( range * ( env_pan - 32 ) >> 5 ); +} + +static void channel_tick( struct channel *channel ) { + channel->vibrato_add = 0; + channel->fx_count++; + channel->retrig_count++; + if( !( channel->note.effect == 0x7D && channel->fx_count <= channel->note.param ) ) { + switch( channel->note.volume & 0xF0 ) { + case 0x60: /* Vol Slide Down.*/ + channel->volume -= channel->note.volume & 0xF; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x70: /* Vol Slide Up.*/ + channel->volume += channel->note.volume & 0xF; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0xB0: /* Vibrato.*/ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + break; + case 0xD0: /* Pan Slide Left.*/ + channel->panning -= channel->note.volume & 0xF; + if( channel->panning < 0 ) { + channel->panning = 0; + } + break; + case 0xE0: /* Pan Slide Right.*/ + channel->panning += channel->note.volume & 0xF; + if( channel->panning > 255 ) { + channel->panning = 255; + } + break; + case 0xF0: /* Tone Porta.*/ + channel_tone_porta( channel ); + break; + } + } + switch( channel->note.effect ) { + case 0x01: case 0x86: /* Porta Up. */ + channel_porta_up( channel, channel->porta_up_param ); + break; + case 0x02: case 0x85: /* Porta Down. */ + channel_porta_down( channel, channel->porta_down_param ); + break; + case 0x03: case 0x87: /* Tone Porta. */ + channel_tone_porta( channel ); + break; + case 0x04: case 0x88: /* Vibrato. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + break; + case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ + channel_tone_porta( channel ); + channel_volume_slide( channel ); + break; + case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + channel_volume_slide( channel ); + break; + case 0x07: case 0x92: /* Tremolo. */ + channel->tremolo_phase += channel->tremolo_speed; + channel_tremolo( channel ); + break; + case 0x0A: case 0x84: /* Vol Slide. */ + channel_volume_slide( channel ); + break; + case 0x11: /* Global Volume Slide. */ + channel->replay->global_vol = channel->replay->global_vol + + ( channel->gvol_slide_param >> 4 ) + - ( channel->gvol_slide_param & 0xF ); + if( channel->replay->global_vol < 0 ) { + channel->replay->global_vol = 0; + } + if( channel->replay->global_vol > 64 ) { + channel->replay->global_vol = 64; + } + break; + case 0x19: /* Panning Slide. */ + channel->panning = channel->panning + + ( channel->pan_slide_param >> 4 ) + - ( channel->pan_slide_param & 0xF ); + if( channel->panning < 0 ) { + channel->panning = 0; + } + if( channel->panning > 255 ) { + channel->panning = 255; + } + break; + case 0x1B: case 0x91: /* Retrig + Vol Slide. */ + channel_retrig_vol_slide( channel ); + break; + case 0x1D: case 0x89: /* Tremor. */ + channel_tremor( channel ); + break; + case 0x79: /* Retrig. */ + if( channel->fx_count >= channel->note.param ) { + channel->fx_count = 0; + channel->sample_idx = channel->sample_fra = 0; + } + break; + case 0x7C: case 0xFC: /* Note Cut. */ + if( channel->note.param == channel->fx_count ) { + channel->volume = 0; + } + break; + case 0x7D: case 0xFD: /* Note Delay. */ + if( channel->note.param == channel->fx_count ) { + channel_trigger( channel ); + } + break; + case 0x8A: /* Arpeggio. */ + if( channel->fx_count == 1 ) { + channel->arpeggio_add = channel->arpeggio_param >> 4; + } else if( channel->fx_count == 2 ) { + channel->arpeggio_add = channel->arpeggio_param & 0xF; + } else { + channel->arpeggio_add = channel->fx_count = 0; + } + break; + case 0x95: /* Fine Vibrato. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 1 ); + break; + } + channel_auto_vibrato( channel ); + channel_calculate_freq( channel ); + channel_calculate_ampl( channel ); + channel_update_envelopes( channel ); +} + +static void channel_row( struct channel *channel, struct note *note ) { + channel->note = *note; + channel->retrig_count++; + channel->vibrato_add = channel->tremolo_add = channel->arpeggio_add = channel->fx_count = 0; + if( !( ( note->effect == 0x7D || note->effect == 0xFD ) && note->param > 0 ) ) { + /* Not note delay.*/ + channel_trigger( channel ); + } + switch( channel->note.effect ) { + case 0x01: case 0x86: /* Porta Up. */ + if( channel->note.param > 0 ) { + channel->porta_up_param = channel->note.param; + } + channel_porta_up( channel, channel->porta_up_param ); + break; + case 0x02: case 0x85: /* Porta Down. */ + if( channel->note.param > 0 ) { + channel->porta_down_param = channel->note.param; + } + channel_porta_down( channel, channel->porta_down_param ); + break; + case 0x03: case 0x87: /* Tone Porta. */ + if( channel->note.param > 0 ) { + channel->tone_porta_param = channel->note.param; + } + break; + case 0x04: case 0x88: /* Vibrato. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->vibrato_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.param & 0xF; + } + channel_vibrato( channel, 0 ); + break; + case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_volume_slide( channel ); + break; + case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_vibrato( channel, 0 ); + channel_volume_slide( channel ); + break; + case 0x07: case 0x92: /* Tremolo. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->tremolo_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->tremolo_depth = channel->note.param & 0xF; + } + channel_tremolo( channel ); + break; + case 0x08: /* Set Panning.*/ + channel->panning = ( channel->note.param < 128 ) ? ( channel->note.param << 1 ) : 255; + break; + case 0x0A: case 0x84: /* Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_volume_slide( channel ); + break; + case 0x0C: /* Set Volume. */ + channel->volume = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; + break; + case 0x10: case 0x96: /* Set Global Volume. */ + channel->replay->global_vol = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; + break; + case 0x11: /* Global Volume Slide. */ + if( channel->note.param > 0 ) { + channel->gvol_slide_param = channel->note.param; + } + break; + case 0x14: /* Key Off. */ + channel->key_on = 0; + break; + case 0x15: /* Set Envelope Tick. */ + channel->vol_env_tick = channel->pan_env_tick = channel->note.param & 0xFF; + break; + case 0x19: /* Panning Slide. */ + if( channel->note.param > 0 ) { + channel->pan_slide_param = channel->note.param; + } + break; + case 0x1B: case 0x91: /* Retrig + Vol Slide. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->retrig_volume = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->retrig_ticks = channel->note.param & 0xF; + } + channel_retrig_vol_slide( channel ); + break; + case 0x1D: case 0x89: /* Tremor. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->tremor_on_ticks = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->tremor_off_ticks = channel->note.param & 0xF; + } + channel_tremor( channel ); + break; + case 0x21: /* Extra Fine Porta. */ + if( channel->note.param > 0 ) { + channel->xfine_porta_param = channel->note.param; + } + switch( channel->xfine_porta_param & 0xF0 ) { + case 0x10: + channel_porta_up( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); + break; + case 0x20: + channel_porta_down( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); + break; + } + break; + case 0x71: /* Fine Porta Up. */ + if( channel->note.param > 0 ) { + channel->fine_porta_up_param = channel->note.param; + } + channel_porta_up( channel, 0xF0 | ( channel->fine_porta_up_param & 0xF ) ); + break; + case 0x72: /* Fine Porta Down. */ + if( channel->note.param > 0 ) { + channel->fine_porta_down_param = channel->note.param; + } + channel_porta_down( channel, 0xF0 | ( channel->fine_porta_down_param & 0xF ) ); + break; + case 0x74: case 0xF3: /* Set Vibrato Waveform. */ + if( channel->note.param < 8 ) { + channel->vibrato_type = channel->note.param; + } + break; + case 0x77: case 0xF4: /* Set Tremolo Waveform. */ + if( channel->note.param < 8 ) { + channel->tremolo_type = channel->note.param; + } + break; + case 0x7A: /* Fine Vol Slide Up. */ + if( channel->note.param > 0 ) { + channel->fine_vslide_up_param = channel->note.param; + } + channel->volume += channel->fine_vslide_up_param; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0x7B: /* Fine Vol Slide Down. */ + if( channel->note.param > 0 ) { + channel->fine_vslide_down_param = channel->note.param; + } + channel->volume -= channel->fine_vslide_down_param; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x7C: case 0xFC: /* Note Cut. */ + if( channel->note.param <= 0 ) { + channel->volume = 0; + } + break; + case 0x8A: /* Arpeggio. */ + if( channel->note.param > 0 ) { + channel->arpeggio_param = channel->note.param; + } + break; + case 0x95: /* Fine Vibrato.*/ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->vibrato_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.param & 0xF; + } + channel_vibrato( channel, 1 ); + break; + case 0xF8: /* Set Panning. */ + channel->panning = channel->note.param * 17; + break; + } + channel_auto_vibrato( channel ); + channel_calculate_freq( channel ); + channel_calculate_ampl( channel ); + channel_update_envelopes( channel ); +} + +static void channel_resample( struct channel *channel, int *mix_buf, + int offset, int count, int sample_rate, int interpolate ) { + struct sample *sample = channel->sample; + int l_gain, r_gain, sam_idx, sam_fra, step; + int loop_len, loop_end, out_idx, out_end, y, m, c; + short *sample_data = channel->sample->data; + if( channel->ampl > 0 ) { + l_gain = channel->ampl * ( 255 - channel->pann ) >> 8; + r_gain = channel->ampl * channel->pann >> 8; + sam_idx = channel->sample_idx; + sam_fra = channel->sample_fra; + step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); + loop_len = sample->loop_length; + loop_end = sample->loop_start + loop_len; + out_idx = offset * 2; + out_end = ( offset + count ) * 2; + if( interpolate ) { + while( out_idx < out_end ) { + if( sam_idx >= loop_end ) { + if( loop_len > 1 ) { + while( sam_idx >= loop_end ) { + sam_idx -= loop_len; + } + } else { + break; + } + } + c = sample_data[ sam_idx ]; + m = sample_data[ sam_idx + 1 ] - c; + y = ( ( m * sam_fra ) >> FP_SHIFT ) + c; + mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; + mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; + sam_fra += step; + sam_idx += sam_fra >> FP_SHIFT; + sam_fra &= FP_MASK; + } + } else { + while( out_idx < out_end ) { + if( sam_idx >= loop_end ) { + if( loop_len > 1 ) { + while( sam_idx >= loop_end ) { + sam_idx -= loop_len; + } + } else { + break; + } + } + y = sample_data[ sam_idx ]; + mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; + mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; + sam_fra += step; + sam_idx += sam_fra >> FP_SHIFT; + sam_fra &= FP_MASK; + } + } + } +} + +static void channel_update_sample_idx( struct channel *channel, int count, int sample_rate ) { + struct sample *sample = channel->sample; + int step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); + channel->sample_fra += step * count; + channel->sample_idx += channel->sample_fra >> FP_SHIFT; + if( channel->sample_idx > sample->loop_start ) { + if( sample->loop_length > 1 ) { + channel->sample_idx = sample->loop_start + + ( channel->sample_idx - sample->loop_start ) % sample->loop_length; + } else { + channel->sample_idx = sample->loop_start; + } + } + channel->sample_fra &= FP_MASK; +} + +static void replay_row( struct replay *replay ) { + int idx, count; + struct note note; + struct pattern *pattern; + struct channel *channel; + struct module *module = replay->module; + if( replay->next_row < 0 ) { + replay->break_pos = replay->seq_pos + 1; + replay->next_row = 0; + } + if( replay->break_pos >= 0 ) { + if( replay->break_pos >= module->sequence_len ) { + replay->break_pos = replay->next_row = 0; + } + while( module->sequence[ replay->break_pos ] >= module->num_patterns ) { + replay->break_pos++; + if( replay->break_pos >= module->sequence_len ) { + replay->break_pos = replay->next_row = 0; + } + } + replay->seq_pos = replay->break_pos; + for( idx = 0; idx < module->num_channels; idx++ ) { + replay->channels[ idx ].pl_row = 0; + } + replay->break_pos = -1; + } + pattern = &module->patterns[ module->sequence[ replay->seq_pos ] ]; + replay->row = replay->next_row; + if( replay->row >= pattern->num_rows ) { + replay->row = 0; + } + if( replay->play_count && replay->play_count[ 0 ] ) { + count = replay->play_count[ replay->seq_pos ][ replay->row ]; + if( replay->pl_count < 0 && count < 127 ) { + replay->play_count[ replay->seq_pos ][ replay->row ] = count + 1; + } + } + replay->next_row = replay->row + 1; + if( replay->next_row >= pattern->num_rows ) { + replay->next_row = -1; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + channel = &replay->channels[ idx ]; + pattern_get_note( pattern, replay->row, idx, ¬e ); + if( note.effect == 0xE ) { + note.effect = 0x70 | ( note.param >> 4 ); + note.param &= 0xF; + } + if( note.effect == 0x93 ) { + note.effect = 0xF0 | ( note.param >> 4 ); + note.param &= 0xF; + } + if( note.effect == 0 && note.param > 0 ) { + note.effect = 0x8A; + } + channel_row( channel, ¬e ); + switch( note.effect ) { + case 0x81: /* Set Speed. */ + if( note.param > 0 ) { + replay->tick = replay->speed = note.param; + } + break; + case 0xB: case 0x82: /* Pattern Jump.*/ + if( replay->pl_count < 0 ) { + replay->break_pos = note.param; + replay->next_row = 0; + } + break; + case 0xD: case 0x83: /* Pattern Break.*/ + if( replay->pl_count < 0 ) { + if( replay->break_pos < 0 ) { + replay->break_pos = replay->seq_pos + 1; + } + replay->next_row = ( note.param >> 4 ) * 10 + ( note.param & 0xF ); + } + break; + case 0xF: /* Set Speed/Tempo.*/ + if( note.param > 0 ) { + if( note.param < 32 ) { + replay->tick = replay->speed = note.param; + } else { + replay->tempo = note.param; + } + } + break; + case 0x94: /* Set Tempo.*/ + if( note.param > 32 ) { + replay->tempo = note.param; + } + break; + case 0x76: case 0xFB : /* Pattern Loop.*/ + if( note.param == 0 ) { + /* Set loop marker on this channel. */ + channel->pl_row = replay->row; + } + if( channel->pl_row < replay->row && replay->break_pos < 0 ) { + /* Marker valid. */ + if( replay->pl_count < 0 ) { + /* Not already looping, begin. */ + replay->pl_count = note.param; + replay->pl_chan = idx; + } + if( replay->pl_chan == idx ) { + /* Next Loop.*/ + if( replay->pl_count == 0 ) { + /* Loop finished. Invalidate current marker. */ + channel->pl_row = replay->row + 1; + } else { + /* Loop. */ + replay->next_row = channel->pl_row; + } + replay->pl_count--; + } + } + break; + case 0x7E: case 0xFE: /* Pattern Delay.*/ + replay->tick = replay->speed + replay->speed * note.param; + break; + } + } +} + +static int replay_tick( struct replay *replay ) { + int idx, num_channels, count = 1; + if( --replay->tick <= 0 ) { + replay->tick = replay->speed; + replay_row( replay ); + } else { + num_channels = replay->module->num_channels; + for( idx = 0; idx < num_channels; idx++ ) { + channel_tick( &replay->channels[ idx ] ); + } + } + if( replay->play_count && replay->play_count[ 0 ] ) { + count = replay->play_count[ replay->seq_pos ][ replay->row ] - 1; + } + return count; +} + +static int module_init_play_count( struct module *module, char **play_count ) { + int idx, pat, rows, len = 0; + for( idx = 0; idx < module->sequence_len; idx++ ) { + pat = module->sequence[ idx ]; + rows = ( pat < module->num_patterns ) ? module->patterns[ pat ].num_rows : 0; + if( play_count ) { + play_count[ idx ] = play_count[ 0 ] ? &play_count[ 0 ][ len ] : NULL; + } + len += rows; + } + return len; +} + +/* Set the pattern in the sequence to play. The tempo is reset to the default. */ +void replay_set_sequence_pos( struct replay *replay, int pos ) { + int idx; + struct module *module = replay->module; + if( pos >= module->sequence_len ) { + pos = 0; + } + replay->break_pos = pos; + replay->next_row = 0; + replay->tick = 1; + replay->global_vol = module->default_gvol; + replay->speed = module->default_speed > 0 ? module->default_speed : 6; + replay->tempo = module->default_tempo > 0 ? module->default_tempo : 125; + replay->pl_count = replay->pl_chan = -1; + if( replay->play_count ) { + free( replay->play_count[ 0 ] ); + free( replay->play_count ); + } + replay->play_count = (char**)calloc( module->sequence_len, sizeof( char * ) ); + if( replay->play_count ) { + replay->play_count[ 0 ] = (char*)calloc( module_init_play_count( module, NULL ), sizeof( char ) ); + module_init_play_count( module, replay->play_count ); + } + for( idx = 0; idx < module->num_channels; idx++ ) { + channel_init( &replay->channels[ idx ], replay, idx ); + } + memset( replay->ramp_buf, 0, 128 * sizeof( int ) ); + replay_tick( replay ); +} + +/* Deallocate the specified replay. */ +void dispose_replay( struct replay *replay ) { + if( replay->play_count ) { + free( replay->play_count[ 0 ] ); + free( replay->play_count ); + } + free( replay->ramp_buf ); + free( replay->channels ); + free( replay ); +} + +/* Allocate and initialize a replay with the specified sampling rate and interpolation. */ +struct replay* new_replay( struct module *module, int sample_rate, int interpolation ) { + struct replay *replay = (struct replay*)calloc( 1, sizeof( struct replay ) ); + if( replay ) { + replay->module = module; + replay->sample_rate = sample_rate; + replay->interpolation = interpolation; + replay->ramp_buf = (int*)calloc( 128, sizeof( int ) ); + replay->channels = (struct channel*)calloc( module->num_channels, sizeof( struct channel ) ); + if( replay->ramp_buf && replay->channels ) { + replay_set_sequence_pos( replay, 0 ); + } else { + dispose_replay( replay ); + replay = NULL; + } + } + return replay; +} + +static int calculate_tick_len( int tempo, int sample_rate ) { + return ( sample_rate * 5 ) / ( tempo * 2 ); +} + +/* Returns the length of the output buffer required by replay_get_audio(). */ +int calculate_mix_buf_len( int sample_rate ) { + return ( calculate_tick_len( 32, sample_rate ) + 65 ) * 4; +} + +/* Returns the song duration in samples at the current sampling rate. */ +int replay_calculate_duration( struct replay *replay ) { + int count = 0, duration = 0; + replay_set_sequence_pos( replay, 0 ); + while( count < 1 ) { + duration += calculate_tick_len( replay->tempo, replay->sample_rate ); + count = replay_tick( replay ); + } + replay_set_sequence_pos( replay, 0 ); + return duration; +} + +/* Seek to approximately the specified sample position. + The actual sample position reached is returned. */ +int replay_seek( struct replay *replay, int sample_pos ) { + int idx, tick_len, current_pos = 0; + replay_set_sequence_pos( replay, 0 ); + tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + while( ( sample_pos - current_pos ) >= tick_len ) { + for( idx = 0; idx < replay->module->num_channels; idx++ ) { + channel_update_sample_idx( &replay->channels[ idx ], + tick_len * 2, replay->sample_rate * 2 ); + } + current_pos += tick_len; + replay_tick( replay ); + tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + } + return current_pos; +} + +static void replay_volume_ramp( struct replay *replay, int *mix_buf, int tick_len ) { + int idx, a1, a2, ramp_rate = 256 * 2048 / replay->sample_rate; + for( idx = 0, a1 = 0; a1 < 256; idx += 2, a1 += ramp_rate ) { + a2 = 256 - a1; + mix_buf[ idx ] = ( mix_buf[ idx ] * a1 + replay->ramp_buf[ idx ] * a2 ) >> 8; + mix_buf[ idx + 1 ] = ( mix_buf[ idx + 1 ] * a1 + replay->ramp_buf[ idx + 1 ] * a2 ) >> 8; + } + memcpy( replay->ramp_buf, &mix_buf[ tick_len * 2 ], 128 * sizeof( int ) ); +} + +/* 2:1 downsampling with simple but effective anti-aliasing. Buf must contain count * 2 + 1 stereo samples. */ +static void downsample( int *buf, int count ) { + int idx, out_idx, out_len = count * 2; + for( idx = 0, out_idx = 0; out_idx < out_len; idx += 4, out_idx += 2 ) { + buf[ out_idx ] = ( buf[ idx ] >> 2 ) + ( buf[ idx + 2 ] >> 1 ) + ( buf[ idx + 4 ] >> 2 ); + buf[ out_idx + 1 ] = ( buf[ idx + 1 ] >> 2 ) + ( buf[ idx + 3 ] >> 1 ) + ( buf[ idx + 5 ] >> 2 ); + } +} + +/* Generates audio and returns the number of stereo samples written into mix_buf. */ +int replay_get_audio( struct replay *replay, int *mix_buf ) { + struct channel *channel; + int idx, num_channels, tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + /* Clear output buffer. */ + memset( mix_buf, 0, ( tick_len + 65 ) * 4 * sizeof( int ) ); + /* Resample. */ + num_channels = replay->module->num_channels; + for( idx = 0; idx < num_channels; idx++ ) { + channel = &replay->channels[ idx ]; + channel_resample( channel, mix_buf, 0, ( tick_len + 65 ) * 2, + replay->sample_rate * 2, replay->interpolation ); + channel_update_sample_idx( channel, tick_len * 2, replay->sample_rate * 2 ); + } + downsample( mix_buf, tick_len + 64 ); + replay_volume_ramp( replay, mix_buf, tick_len ); + replay_tick( replay ); + return tick_len; +} diff --git a/deps/libvita2d/source/vita2d_texture.c b/deps/libvita2d/source/vita2d_texture.c index 9d43071fb2..452bd4e51e 100644 --- a/deps/libvita2d/source/vita2d_texture.c +++ b/deps/libvita2d/source/vita2d_texture.c @@ -673,7 +673,7 @@ void vita2d_texture_set_tint_color_uniform(unsigned int color){ void vita2d_draw_texture_part_generic(const vita2d_texture *texture, SceGxmPrimitiveType type, vita2d_texture_vertex *vertices, unsigned int num_vertices) { - + uint16_t *indices = (uint16_t *)vita2d_pool_memalign( num_vertices * sizeof(uint16_t), // 4 indices sizeof(uint16_t)); diff --git a/deps/mbedtls/ecjpake.c b/deps/mbedtls/ecjpake.c index 1fa1c2d801..9218c5d172 100644 --- a/deps/mbedtls/ecjpake.c +++ b/deps/mbedtls/ecjpake.c @@ -299,7 +299,7 @@ cleanup: */ static int ecjpake_zkp_write( const mbedtls_md_info_t *md_info, const mbedtls_ecp_group *grp, - const int pf, + const int pf, const mbedtls_ecp_point *G, const mbedtls_mpi *x, const mbedtls_ecp_point *X, diff --git a/deps/mbedtls/mbedtls/ecp_internal.h b/deps/mbedtls/mbedtls/ecp_internal.h index 2991e26dd9..1a0fcd688c 100644 --- a/deps/mbedtls/mbedtls/ecp_internal.h +++ b/deps/mbedtls/mbedtls/ecp_internal.h @@ -47,7 +47,7 @@ * [6] Digital Signature Standard (DSS), FIPS 186-4. * * - * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer + * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer * Security (TLS), RFC 4492. * * diff --git a/deps/mbedtls/mbedtls/rsa.h b/deps/mbedtls/mbedtls/rsa.h index 7d7469d509..a1a804be4c 100644 --- a/deps/mbedtls/mbedtls/rsa.h +++ b/deps/mbedtls/mbedtls/rsa.h @@ -333,7 +333,7 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \note The input buffer must be as large as the size @@ -365,7 +365,7 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \note The input buffer must be as large as the size @@ -399,10 +399,10 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * - * \note The input buffer must be as large as the size + * \note The input buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, diff --git a/deps/mbedtls/mbedtls/ssl_ciphersuites.h b/deps/mbedtls/mbedtls/ssl_ciphersuites.h index 9101d9cc7c..8ef79fdad3 100644 --- a/deps/mbedtls/mbedtls/ssl_ciphersuites.h +++ b/deps/mbedtls/mbedtls/ssl_ciphersuites.h @@ -266,7 +266,7 @@ typedef enum { defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ - defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #define MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED #endif diff --git a/deps/mbedtls/ssl_cli.c b/deps/mbedtls/ssl_cli.c index a2b9f8cfe1..b73e416458 100644 --- a/deps/mbedtls/ssl_cli.c +++ b/deps/mbedtls/ssl_cli.c @@ -344,7 +344,7 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, *olen = 6; } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) @@ -1247,7 +1247,7 @@ static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) diff --git a/deps/mbedtls/ssl_srv.c b/deps/mbedtls/ssl_srv.c index f137c3dce6..be961af710 100644 --- a/deps/mbedtls/ssl_srv.c +++ b/deps/mbedtls/ssl_srv.c @@ -785,7 +785,7 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, const mbedtls_ssl_ciphersuite_t *suite_info; #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ - defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) mbedtls_pk_type_t sig_type; #endif @@ -2955,7 +2955,7 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) return( ret ); } -#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) dig_signed = p; dig_signed_len = len; #endif @@ -3044,7 +3044,7 @@ curve_matching_done: /* * 3.1: Choose hash algorithm: - * A: For TLS 1.2, obey signature-hash-algorithm extension + * A: For TLS 1.2, obey signature-hash-algorithm extension * to choose appropriate hash. * B: For SSL3, TLS1.0, TLS1.1 and ECDHE_ECDSA, use SHA1 * (RFC 4492, Sec. 5.4) @@ -3065,7 +3065,7 @@ curve_matching_done: sig_alg ) ) == MBEDTLS_MD_NONE ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - /* (... because we choose a cipher suite + /* (... because we choose a cipher suite * only if there is a matching hash.) */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } diff --git a/deps/mbedtls/x509_crt.c b/deps/mbedtls/x509_crt.c index a6dce95ba2..a2305beb2e 100644 --- a/deps/mbedtls/x509_crt.c +++ b/deps/mbedtls/x509_crt.c @@ -713,7 +713,7 @@ static int x509_crt_parse_der_core( mbedtls_x509_crt *crt, const unsigned char * memcpy( p, buf, crt->raw.len ); - // Direct pointers to the new buffer + // Direct pointers to the new buffer p += crt->raw.len - len; end = crt_end = p + len; diff --git a/deps/miniupnpc/minissdpc.c b/deps/miniupnpc/minissdpc.c index c015298b97..6cf1570787 100644 --- a/deps/miniupnpc/minissdpc.c +++ b/deps/miniupnpc/minissdpc.c @@ -67,13 +67,13 @@ struct sockaddr_un { #define PRINT_SOCKET_ERROR(x) perror(x) #endif -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) +#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) && !defined(__HAIKU__) #define HAS_IP_MREQN #endif #if !defined(HAS_IP_MREQN) && !defined(_WIN32) #include -#if defined(__sun) +#if defined(__sun) || defined(__HAIKU__) #include #endif #endif diff --git a/deps/miniupnpc/portlistingparse.c b/deps/miniupnpc/portlistingparse.c index e864c0eb70..de596698aa 100644 --- a/deps/miniupnpc/portlistingparse.c +++ b/deps/miniupnpc/portlistingparse.c @@ -31,7 +31,7 @@ static const struct { /* Helper function */ static UNSIGNED_INTEGER -atoui(const char * p, int l) +my_atoui(const char * p, int l) { UNSIGNED_INTEGER r = 0; while(l > 0 && *p) @@ -106,7 +106,7 @@ static void portlisting_data(void * d, const char * data, int l) pm->remoteHost[l] = '\0'; break; case NewExternalPort: - pm->externalPort = (unsigned short)atoui(data, l); + pm->externalPort = (unsigned short)my_atoui(data, l); break; case NewProtocol: if(l > 3) @@ -115,21 +115,21 @@ static void portlisting_data(void * d, const char * data, int l) pm->protocol[l] = '\0'; break; case NewInternalPort: - pm->internalPort = (unsigned short)atoui(data, l); + pm->internalPort = (unsigned short)my_atoui(data, l); break; case NewInternalClient: memcpy(pm->internalClient, data, l); pm->internalClient[l] = '\0'; break; case NewEnabled: - pm->enabled = (unsigned char)atoui(data, l); + pm->enabled = (unsigned char)my_atoui(data, l); break; case NewDescription: memcpy(pm->description, data, l); pm->description[l] = '\0'; break; case NewLeaseTime: - pm->leaseTime = atoui(data, l); + pm->leaseTime = my_atoui(data, l); break; default: break; diff --git a/deps/miniupnpc/upnpcommands.c b/deps/miniupnpc/upnpcommands.c index 25483c0c45..017c5cdce6 100644 --- a/deps/miniupnpc/upnpcommands.c +++ b/deps/miniupnpc/upnpcommands.c @@ -14,7 +14,7 @@ #include "portlistingparse.h" static UNSIGNED_INTEGER -my_atoui(const char * s) +my_custom_atoui(const char * s) { return s ? ((UNSIGNED_INTEGER)STRTOUI(s, NULL, 0)) : 0; } @@ -38,7 +38,7 @@ UPNP_GetTotalBytesSent(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalBytesSent"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -62,7 +62,7 @@ UPNP_GetTotalBytesReceived(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalBytesReceived"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -86,7 +86,7 @@ UPNP_GetTotalPacketsSent(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalPacketsSent"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -110,7 +110,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -903,11 +903,11 @@ UPNP_GetFirewallStatus(const char * controlURL, if(ipa && fe) ret = UPNPCOMMAND_SUCCESS; if(fe) - *firewallEnabled = (int)my_atoui(fe); + *firewallEnabled = (int)my_custom_atoui(fe); /*else *firewallEnabled = 0;*/ if(ipa) - *inboundPinholeAllowed = (int)my_atoui(ipa); + *inboundPinholeAllowed = (int)my_custom_atoui(ipa); /*else *inboundPinholeAllowed = 0;*/ p = GetValueFromNameValueList(&pdata, "errorCode"); @@ -971,7 +971,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype ret = UPNPCOMMAND_SUCCESS; p = GetValueFromNameValueList(&pdata, "OutboundPinholeTimeout"); if(p) - *opTimeout = (int)my_atoui(p); + *opTimeout = (int)my_custom_atoui(p); } ClearNameValueList(&pdata); return ret; @@ -1175,7 +1175,7 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, p = GetValueFromNameValueList(&pdata, "IsWorking"); if(p) { - *isWorking = (int)my_atoui(p); + *isWorking = (int)my_custom_atoui(p); ret = UPNPCOMMAND_SUCCESS; } else @@ -1222,7 +1222,7 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, p = GetValueFromNameValueList(&pdata, "PinholePackets"); if(p) { - *packets = (int)my_atoui(p); + *packets = (int)my_custom_atoui(p); ret = UPNPCOMMAND_SUCCESS; } diff --git a/deps/stb/stb_image.h b/deps/stb/stb_image.h index 3349700b81..323ce6df12 100644 --- a/deps/stb/stb_image.h +++ b/deps/stb/stb_image.h @@ -5158,7 +5158,7 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int // Else if n is 128, noop. // Endloop - /* The RLE-compressed data is preceeded by a 2-byte data count + /* The RLE-compressed data is preceeded by a 2-byte data count * for each row in the data, which we're going to just skip. */ stbi__skip(s, h * channelCount * 2 ); @@ -5948,7 +5948,7 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { - /* not run-length encoded, so we have to + /* not run-length encoded, so we have to * actually use THIS data as a decoded * pixel (note this can't be a valid pixel * --one of RGB must be >= 128) */ diff --git a/deps/stb/stb_rect_pack.h b/deps/stb/stb_rect_pack.h index f31258adb9..6c658de33e 100644 --- a/deps/stb/stb_rect_pack.h +++ b/deps/stb/stb_rect_pack.h @@ -245,7 +245,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); - /* node 0 is the full width, + /* node 0 is the full width, * node 1 is the sentinel (lets us not store width explicitly) */ context->extra[0].x = 0; context->extra[0].y = 0; @@ -268,7 +268,7 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, int x1 = x0 + width; STBRP_ASSERT(first->x <= x0); - STBRP_ASSERT(node->next->x > x0); + STBRP_ASSERT(node->next->x > x0); STBRP_ASSERT(node->x <= x0); min_y = 0; @@ -417,7 +417,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt } } tail = tail->next; - } + } } fr.prev_link = best; diff --git a/deps/stb/stb_truetype.h b/deps/stb/stb_truetype.h index ba3dd5acc0..4e1b8a97e7 100644 --- a/deps/stb/stb_truetype.h +++ b/deps/stb/stb_truetype.h @@ -26,7 +26,7 @@ * "Zer" on mollyrocket (with fix) * Cass Everitt * stoiko (Haemimont Games) - * Brian Hook + * Brian Hook * Walter van Niftrik * David Gow * David Given @@ -230,7 +230,7 @@ * Curve tesselation 120 LOC \__ 550 LOC Bitmap creation * Bitmap management 100 LOC / * Baked bitmap interface 70 LOC / - * Font name matching & access 150 LOC ---- 150 + * Font name matching & access 150 LOC ---- 150 * C runtime library abstraction 60 LOC ---- 60 * * @@ -566,10 +566,10 @@ enum }; #endif -#ifndef stbtt_vertex +#ifndef stbtt_vertex /* can't use stbtt_int16 because that's not visible in the header file */ -#define stbtt_vertex_type short +#define stbtt_vertex_type short typedef struct { @@ -944,7 +944,7 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, i stbtt_uint32 encoding_record = cmap + 4 + 8 * i; /* find an encoding we understand: */ - + switch(ttUSHORT(data+encoding_record)) { case STBTT_PLATFORM_ID_MICROSOFT: @@ -1273,7 +1273,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s if (start_off) { - /* if we start off with an off-curve point, + /* if we start off with an off-curve point, * then when we need to find a point on the curve * where we can start, and we need to save some state for when we wraparound. */ scx = x; @@ -1555,7 +1555,7 @@ STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, } else { - /* move to integral bboxes + /* move to integral bboxes * (treating pixels as little squares, what pixels get touched)? */ if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); @@ -1667,7 +1667,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); if (!z) return z; - + /* round dx down to avoid overshooting */ if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); @@ -1750,7 +1750,7 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac } } } - + e = e->next; } } @@ -2092,7 +2092,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); /* update all active edges, - * remove all active edges that terminate + * remove all active edges that terminate * before the top of this scanline */ while (*step) { stbtt__active_edge * z = *step; @@ -2306,7 +2306,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou /* now sort the edges by their highest point (should snap to integer, and then by x) */ stbtt__sort_edges(e, n); - /* now, traverse the scanlines and find the + /* now, traverse the scanlines and find the * intersections on each scanline, use XOR winding rule */ stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); @@ -2449,7 +2449,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; - stbtt_vertex *vertices; + stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; @@ -2471,7 +2471,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; - + if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *)malloc(gbm.w * gbm.h); @@ -2485,7 +2485,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info free(vertices); return gbm.pixels; -} +} STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) @@ -2500,7 +2500,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; + stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; @@ -2526,7 +2526,7 @@ STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo * { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, @@ -2539,7 +2539,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, @@ -2667,7 +2667,7 @@ static void stbrp_init_target(stbrp_context *con, int pw, int ph, con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); + STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, @@ -2772,7 +2772,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, total = 0; - /* make kernel_width a constant in common cases + /* make kernel_width a constant in common cases * so compiler can optimize out the divide */ switch (kernel_width) { case 2: @@ -2912,7 +2912,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars_in_range; - + rects = (stbrp_rect *)malloc(sizeof(*rects) * n); if (rects == NULL) return 0; @@ -3045,7 +3045,7 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, /* font name matching -- recommended not to use this */ /* check if a UTF8 string contains a prefix which is the UTF16 string; if so return length of matching UTF8 string */ -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; @@ -3091,7 +3091,7 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 return i; } -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); } @@ -3150,8 +3150,8 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, if (matchlen >= 0) { /* check for target_id+1 immediately following, with same encoding & language */ - if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id - && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id + && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { slen = ttUSHORT(fc+loc+12+8); diff --git a/deps/stb/stb_vorbis.h b/deps/stb/stb_vorbis.h index fd27e6eedc..6adaff4940 100644 --- a/deps/stb/stb_vorbis.h +++ b/deps/stb/stb_vorbis.h @@ -426,7 +426,7 @@ struct stb_vorbis int current_loc_valid; /* per-blocksize precomputed data */ - + /* twiddle factors */ float *A[2],*B[2],*C[2]; float *window[2]; @@ -737,7 +737,7 @@ static void compute_sorted_huffman(Codebook *c, uint8_t *lengths, uint32_t *valu if (!c->sparse) { int k = 0; for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) + if (include_in_sort(c, lengths[i])) c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); assert(k == c->sorted_entries); } else { @@ -943,7 +943,7 @@ static int start_page_no_capturepattern(vorb *f) /* header flag */ f->page_flag = get8(f); /* absolute granule position */ - loc0 = get32(f); + loc0 = get32(f); loc1 = get32(f); /* @TODO: validate loc0,loc1 as valid positions? * stream serial number -- vorbis doesn't interleave, so discard */ @@ -1437,69 +1437,69 @@ static int predict_point(int x, int x0, int x1, int y0, int y1) /* the following table is block-copied from the specification */ static float inverse_db_table[256] = { - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, + 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, + 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, + 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, + 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, + 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, + 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, + 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, + 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, + 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, + 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, + 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, + 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, + 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, + 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, + 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, + 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, + 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, + 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, + 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, + 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, + 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, + 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, + 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, + 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, + 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, + 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, + 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, + 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, + 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, + 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, + 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, + 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, + 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, + 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, + 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, + 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, + 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, + 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, + 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, + 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, + 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, + 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, + 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, + 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, + 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, + 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, + 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, + 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, + 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, + 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, + 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, + 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, + 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, + 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, + 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, + 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, + 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, + 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, + 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, + 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, + 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, + 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, + 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, 0.82788260f, 0.88168307f, 0.9389798f, 1.0f }; @@ -1719,11 +1719,11 @@ static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int #if LIBVORBIS_MDCT /* directly call the vorbis MDCT using an interface documented * by Jeff Roberts... useful for performance comparison */ -typedef struct +typedef struct { int n; int log2n; - + float *trig; int *bitrev; @@ -1742,7 +1742,7 @@ void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) if (M1.n == n) M = &M1; else if (M2.n == n) M = &M2; else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } - else { + else { if (M2.n) __asm int 3; mdct_init(&M2, n); M = &M2; @@ -2157,7 +2157,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d1[0] = u[k4+1]; d0[1] = u[k4+2]; d0[0] = u[k4+3]; - + d0 -= 4; d1 -= 4; bitrev += 2; @@ -2239,7 +2239,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) float p0,p1,p2,p3; p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; + p2 = -e[6]*B[6] - e[7]*B[7]; d0[0] = p3; d1[3] = - p3; @@ -2247,7 +2247,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[3] = p2; p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; + p0 = -e[4]*B[4] - e[5]*B[5]; d0[1] = p1; d1[2] = - p1; @@ -2255,7 +2255,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[2] = p0; p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; + p2 = -e[2]*B[2] - e[3]*B[3]; d0[2] = p3; d1[1] = - p3; @@ -2263,7 +2263,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[1] = p2; p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; + p0 = -e[0]*B[0] - e[1]*B[1]; d0[3] = p1; d1[0] = - p1; @@ -2497,7 +2497,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, for (i=0; i < map->submaps; ++i) { float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; int r; - uint8_t do_not_decode[256]; + uint8_t do_not_decode[256] = {0}; int ch = 0; for (j=0; j < f->channels; ++j) { if (map->chan[j].mux == i) { @@ -2968,7 +2968,7 @@ static int start_decoder(vorb *f) } else { STBV_Point p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; + int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); @@ -3072,7 +3072,7 @@ static int start_decoder(vorb *f) f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; + Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); @@ -3473,7 +3473,7 @@ static int vorbis_analyze_page(stb_vorbis *f, ProbedPage *z) * will then require us to NOT discard all of the first frame we * decode, in some cases, which means an even weirder frame size * and extra code. what a fucking pain. - + * we're going to discard the first packet if we * start the seek here, so we don't care about it. (we could actually * do better; if the first packet is long, and the previous packet @@ -3567,7 +3567,7 @@ static int vorbis_seek_frame_from_page(stb_vorbis *f, uint32_t page_start, uint3 * then leave frame pending */ frames_to_skip = frame - 1; assert(frames_to_skip >= 0); - data_to_skip = -1; + data_to_skip = -1; } set_file_offset(f, page_start); @@ -3645,7 +3645,7 @@ static int vorbis_seek_base(stb_vorbis *f, unsigned int sample_number, int fine) return error(f, VORBIS_seek_failed); /* now we want to lerp between these for the target samples... */ - + /* step 1: we need to bias towards the page start... */ if (start_offset + 4000 < end_offset) end_offset -= 4000; @@ -3725,7 +3725,7 @@ unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) /* first, store the current decode position so we can restore it */ restore_offset = stb_vorbis_get_file_offset(f); - /* now we want to seek back 64K from the end (the last page must + /* now we want to seek back 64K from the end (the last page must * be at most a little less than 64K, but let's allow a little slop) */ if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) previous_safe = f->stream_len - 65536; diff --git a/dirs.c b/dirs.c index 486e9dcc2c..3fc81f2962 100644 --- a/dirs.c +++ b/dirs.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "dirs.h" @@ -82,7 +83,7 @@ bool dir_init_shader(void) bool dir_free_shader(void) { - struct rarch_dir_list *dir_list = + struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list; dir_list_free(dir_list->list); @@ -305,7 +306,7 @@ void dir_check_defaults(void) /* early return for people with a custom folder setup so it doesn't create unnecessary directories */ - if (path_file_exists("custom.ini")) + if (filestream_exists("custom.ini")) return; for (i = 0; i < DEFAULT_DIR_LAST; i++) diff --git a/dirs.h b/dirs.h index f69bb06715..e9bc186c69 100644 --- a/dirs.h +++ b/dirs.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/driver.c b/driver.c index 96fc0c2c73..7cadd24508 100644 --- a/driver.c +++ b/driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -44,17 +44,6 @@ #include "retroarch.h" #include "verbosity.h" -#define HASH_LOCATION_DRIVER 0x09189689U -#define HASH_CAMERA_DRIVER 0xf25db959U -#define HASH_MENU_DRIVER 0xd607fb05U -#define HASH_INPUT_DRIVER 0x4c087840U -#define HASH_INPUT_JOYPAD_DRIVER 0xab124146U -#define HASH_VIDEO_DRIVER 0x1805a5e7U -#define HASH_AUDIO_DRIVER 0x26594002U -#define HASH_AUDIO_RESAMPLER_DRIVER 0xedcba9ecU -#define HASH_RECORD_DRIVER 0x144cd2cfU -#define HASH_WIFI_DRIVER 0x64d7d17fU - /** * find_driver_nonempty: * @label : string of driver type to be found. @@ -72,62 +61,68 @@ static const void *find_driver_nonempty(const char *label, int i, char *s, size_t len) { const void *drv = NULL; - uint32_t hash = msg_hash_calculate(label); - switch (hash) + if (string_is_equal(label, "camera_driver")) { - case HASH_CAMERA_DRIVER: - drv = camera_driver_find_handle(i); - if (drv) - strlcpy(s, camera_driver_find_ident(i), len); - break; - case HASH_LOCATION_DRIVER: - drv = location_driver_find_handle(i); - if (drv) - strlcpy(s, location_driver_find_ident(i), len); - break; - case HASH_MENU_DRIVER: + drv = camera_driver_find_handle(i); + if (drv) + strlcpy(s, camera_driver_find_ident(i), len); + } + else if (string_is_equal(label, "location_driver")) + { + drv = location_driver_find_handle(i); + if (drv) + strlcpy(s, location_driver_find_ident(i), len); + } #ifdef HAVE_MENU - drv = menu_driver_find_handle(i); - if (drv) - strlcpy(s, menu_driver_find_ident(i), len); + else if (string_is_equal(label, "menu_driver")) + { + drv = menu_driver_find_handle(i); + if (drv) + strlcpy(s, menu_driver_find_ident(i), len); + } #endif - break; - case HASH_INPUT_DRIVER: - drv = input_driver_find_handle(i); - if (drv) - strlcpy(s, input_driver_find_ident(i), len); - break; - case HASH_INPUT_JOYPAD_DRIVER: - drv = joypad_driver_find_handle(i); - if (drv) - strlcpy(s, joypad_driver_find_ident(i), len); - break; - case HASH_VIDEO_DRIVER: - drv = video_driver_find_handle(i); - if (drv) - strlcpy(s, video_driver_find_ident(i), len); - break; - case HASH_AUDIO_DRIVER: - drv = audio_driver_find_handle(i); - if (drv) - strlcpy(s, audio_driver_find_ident(i), len); - break; - case HASH_RECORD_DRIVER: - drv = record_driver_find_handle(i); - if (drv) - strlcpy(s, record_driver_find_ident(i), len); - break; - case HASH_AUDIO_RESAMPLER_DRIVER: - drv = audio_resampler_driver_find_handle(i); - if (drv) - strlcpy(s, audio_resampler_driver_find_ident(i), len); - break; - case HASH_WIFI_DRIVER: - drv = wifi_driver_find_handle(i); - if (drv) - strlcpy(s, wifi_driver_find_ident(i), len); - break; + else if (string_is_equal(label, "input_driver")) + { + drv = input_driver_find_handle(i); + if (drv) + strlcpy(s, input_driver_find_ident(i), len); + } + else if (string_is_equal(label, "input_joypad_driver")) + { + drv = joypad_driver_find_handle(i); + if (drv) + strlcpy(s, joypad_driver_find_ident(i), len); + } + else if (string_is_equal(label, "video_driver")) + { + drv = video_driver_find_handle(i); + if (drv) + strlcpy(s, video_driver_find_ident(i), len); + } + else if (string_is_equal(label, "audio_driver")) + { + drv = audio_driver_find_handle(i); + if (drv) + strlcpy(s, audio_driver_find_ident(i), len); + } + else if (string_is_equal(label, "record_driver")) + { + drv = record_driver_find_handle(i); + if (drv) + strlcpy(s, record_driver_find_ident(i), len); + } + else if (string_is_equal(label, "audio_resampler_driver")) + { + drv = audio_resampler_driver_find_handle(i); + if (drv) + strlcpy(s, audio_resampler_driver_find_ident(i), len); + } + else if (string_is_equal(label, "wifi_driver")) + { + drv = wifi_driver_find_handle(i); + if (drv) + strlcpy(s, wifi_driver_find_ident(i), len); } return drv; @@ -150,7 +145,7 @@ static int driver_find_index(const char * label, const char *drv) str[0] = '\0'; - for (i = 0; + for (i = 0; find_driver_nonempty(label, i, str, sizeof(str)) != NULL; i++) { if (string_is_empty(str)) @@ -258,7 +253,7 @@ static void driver_adjust_system_rates(void) * * Sets audio and video drivers to nonblock state (if enabled). * - * If nonblock state is false, sets + * If nonblock state is false, sets * blocking state for both audio and video drivers instead. **/ void driver_set_nonblock_state(void) @@ -271,7 +266,7 @@ void driver_set_nonblock_state(void) settings_t *settings = config_get_ptr(); bool video_nonblock = enable; - if ( !settings->bools.video_vsync + if ( !settings->bools.video_vsync || rarch_ctl(RARCH_CTL_IS_NONBLOCK_FORCED, NULL)) video_nonblock = true; video_driver_set_nonblock_state(video_nonblock); @@ -284,7 +279,7 @@ void driver_set_nonblock_state(void) * driver_update_system_av_info: * @data : pointer to new A/V info * - * Update the system Audio/Video information. + * Update the system Audio/Video information. * Will reinitialize audio/video drivers. * Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO. * @@ -402,17 +397,17 @@ void drivers_init(int flags) **/ /** - * Driver ownership - set this to true if the platform in question needs to 'own' - * the respective handle and therefore skip regular RetroArch + * Driver ownership - set this to true if the platform in question needs to 'own' + * the respective handle and therefore skip regular RetroArch * driver teardown/reiniting procedure. * - * If to true, the 'free' function will get skipped. It is - * then up to the driver implementation to properly handle - * 'reiniting' inside the 'init' function and make sure it - * returns the existing handle instead of allocating and + * If to true, the 'free' function will get skipped. It is + * then up to the driver implementation to properly handle + * 'reiniting' inside the 'init' function and make sure it + * returns the existing handle instead of allocating and * returning a pointer to a new handle. * - * Typically, if a driver intends to make use of this, it should + * Typically, if a driver intends to make use of this, it should * set this to true at the end of its 'init' function. **/ void driver_uninit(int flags) diff --git a/driver.h b/driver.h index 1120253e65..49d61bbf07 100644 --- a/driver.h +++ b/driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -74,7 +74,7 @@ enum driver_ctl_state RARCH_DRIVER_CTL_NONE = 0, RARCH_DRIVER_CTL_DEINIT, - /* Attempts to find a default driver for + /* Attempts to find a default driver for * all driver types. * * Should be run before RARCH_DRIVER_CTL_INIT. @@ -86,7 +86,7 @@ enum driver_ctl_state * calls audio_monitor_set_refresh_rate(). */ RARCH_DRIVER_CTL_SET_REFRESH_RATE, - /* Update the system Audio/Video information. + /* Update the system Audio/Video information. * Will reinitialize audio/video drivers. * Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO. */ RARCH_DRIVER_CTL_UPDATE_SYSTEM_AV_INFO, diff --git a/dynamic.c b/dynamic.c index 7661316f22..2fdc566eb2 100644 --- a/dynamic.c +++ b/dynamic.c @@ -25,6 +25,9 @@ #include #include #include +#include +#define VFS_FRONTEND +#include #include @@ -199,11 +202,11 @@ static void libretro_get_environment_info(void (*func)(retro_environment_t), /* load_no_content gets set in this callback. */ func(environ_cb_get_system_info); - /* It's possible that we just set get_system_info callback + /* It's possible that we just set get_system_info callback * to the currently running core. * * Make sure we reset it to the actual environment callback. - * Ignore any environment callbacks here in case we're running + * Ignore any environment callbacks here in case we're running * on the non-current core. */ ignore_environment_cb = true; func(rarch_environment_cb); @@ -339,11 +342,11 @@ bool libretro_get_system_info(const char *path, /* load_no_content gets set in this callback. */ retro_set_environment(environ_cb_get_system_info); - /* It's possible that we just set get_system_info callback + /* It's possible that we just set get_system_info callback * to the currently running core. * * Make sure we reset it to the actual environment callback. - * Ignore any environment callbacks here in case we're running + * Ignore any environment callbacks here in case we're running * on the non-current core. */ ignore_environment_cb = true; retro_set_environment(rarch_environment_cb); @@ -712,11 +715,11 @@ static size_t mmap_add_bits_down(size_t n) n |= n >> 4; n |= n >> 8; n |= n >> 16; - + /* double shift to avoid warnings on 32bit (it's dead code, but compilers suck) */ if (sizeof(size_t) > 4) n |= n >> 16 >> 16; - + return n; } @@ -730,7 +733,7 @@ static size_t mmap_inflate(size_t addr, size_t mask) addr = ((addr & ~tmp) << 1) | (addr & tmp); mask = mask & (mask - 1); } - + return addr; } @@ -742,7 +745,7 @@ static size_t mmap_reduce(size_t addr, size_t mask) addr = (addr & tmp) | ((addr >> 1) & ~tmp); mask = (mask & (mask - 1)) >> 1; } - + return addr; } @@ -757,7 +760,7 @@ static bool mmap_preprocess_descriptors(rarch_memory_descriptor_t *first, unsign size_t top_addr = 1; rarch_memory_descriptor_t *desc = NULL; const rarch_memory_descriptor_t *end = first + count; - + for (desc = first; desc < end; desc++) { if (desc->core.select != 0) @@ -765,43 +768,43 @@ static bool mmap_preprocess_descriptors(rarch_memory_descriptor_t *first, unsign else top_addr |= desc->core.start + desc->core.len - 1; } - + top_addr = mmap_add_bits_down(top_addr); - + for (desc = first; desc < end; desc++) { if (desc->core.select == 0) { if (desc->core.len == 0) return false; - + if ((desc->core.len & (desc->core.len - 1)) != 0) return false; - + desc->core.select = top_addr & ~mmap_inflate(mmap_add_bits_down(desc->core.len - 1), desc->core.disconnect); } - + if (desc->core.len == 0) desc->core.len = mmap_add_bits_down(mmap_reduce(top_addr & ~desc->core.select, desc->core.disconnect)) + 1; - + if (desc->core.start & ~desc->core.select) return false; - + while (mmap_reduce(top_addr & ~desc->core.select, desc->core.disconnect) >> 1 > desc->core.len - 1) desc->core.disconnect |= mmap_highest_bit(top_addr & ~desc->core.select & ~desc->core.disconnect); - + desc->disconnect_mask = mmap_add_bits_down(desc->core.len - 1); desc->core.disconnect &= desc->disconnect_mask; - + while ((~desc->disconnect_mask) >> 1 & desc->core.disconnect) { desc->disconnect_mask >>= 1; desc->core.disconnect &= desc->disconnect_mask; } } - + return true; } @@ -942,7 +945,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) unsigned p; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = runloop_get_system_info(); - + if (ignore_environment_cb) return false; @@ -1238,7 +1241,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) { struct retro_hw_render_callback *cb = (struct retro_hw_render_callback*)data; - struct retro_hw_render_callback *hwr = + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); RARCH_LOG("Environ SET_HW_RENDER.\n"); @@ -1253,7 +1256,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) cb->get_proc_address = video_driver_get_proc_address; /* Old ABI. Don't copy garbage. */ - if (cmd & RETRO_ENVIRONMENT_EXPERIMENTAL) + if (cmd & RETRO_ENVIRONMENT_EXPERIMENTAL) memcpy(hwr, cb, offsetof(struct retro_hw_render_callback, stencil)); else @@ -1392,7 +1395,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) cb->get_cpu_features = cpu_features_get; cb->get_perf_counter = cpu_features_get_perf_counter; - cb->perf_register = performance_counter_register; + cb->perf_register = performance_counter_register; cb->perf_start = core_performance_counter_start; cb->perf_stop = core_performance_counter_stop; cb->perf_log = retro_perf_log; @@ -1494,7 +1497,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) } break; } - + case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: { if (system) @@ -1575,9 +1578,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) { const struct retro_game_geometry *in_geom = NULL; struct retro_game_geometry *geom = NULL; - struct retro_system_av_info *av_info = + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - + if (av_info) geom = (struct retro_game_geometry*)&av_info->geometry; @@ -1617,7 +1620,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE: return video_driver_get_hw_render_interface( (const struct retro_hw_render_interface**)data); - + case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS: #ifdef HAVE_CHEEVOS { @@ -1649,8 +1652,34 @@ bool rarch_environment_cb(unsigned cmd, void *data) core_set_shared_context = true; break; } + + case RETRO_ENVIRONMENT_GET_VFS_INTERFACE: + { + const uint32_t supported_vfs_version = 1; + static struct retro_vfs_interface vfs_iface = + { + retro_vfs_file_get_path_impl, + retro_vfs_file_open_impl, + retro_vfs_file_close_impl, + retro_vfs_file_size_impl, + retro_vfs_file_tell_impl, + retro_vfs_file_seek_impl, + retro_vfs_file_read_impl, + retro_vfs_file_write_impl, + retro_vfs_file_flush_impl, + retro_vfs_file_remove_impl + }; + + struct retro_vfs_interface_info *vfs_iface_info = (struct retro_vfs_interface_info *) data; + if (vfs_iface_info->required_interface_version <= supported_vfs_version) + { + vfs_iface_info->required_interface_version = supported_vfs_version; + vfs_iface_info->iface = &vfs_iface; + } + + break; + } - /* Default */ default: RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd); return false; diff --git a/dynamic.h b/dynamic.h index d2b529520b..2432704e48 100644 --- a/dynamic.h +++ b/dynamic.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ struct retro_core_t void (*retro_set_input_poll)(retro_input_poll_t); void (*retro_set_input_state)(retro_input_state_t); void (*retro_set_controller_port_device)(unsigned, unsigned); - void (*retro_reset)(void); + void (*retro_reset)(void); void (*retro_run)(void); size_t (*retro_serialize_size)(void); bool (*retro_serialize)(void*, size_t); @@ -122,7 +122,7 @@ bool libretro_get_shared_context(void); /** * init_libretro_sym: * @type : Type of core to be loaded. - * If CORE_TYPE_DUMMY, will + * If CORE_TYPE_DUMMY, will * load dummy symbols. * * Initializes libretro symbols and diff --git a/file_path_str.c b/file_path_str.c index ce976bf261..219c719720 100644 --- a/file_path_str.c +++ b/file_path_str.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 7d3b7b6b28..015d7e0ae4 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -129,7 +129,7 @@ static void frontend_ctr_deinit(void *data) cfguExit(); ndspExit(); - csndExit(); + csndExit(); gfxTopRightFramebuffers[0] = NULL; gfxTopRightFramebuffers[1] = NULL; gfxExit(); @@ -322,7 +322,7 @@ static void frontend_ctr_init(void *data) verbosity_enable(); - gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false); + gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false); u32 topSize = 400 * 240 * 3; u32 bottomSize = 320 * 240 * 2; diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index df2ff6c28f..4b1096a33c 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -51,6 +51,7 @@ #include #include #include +#include #include #ifdef HAVE_MENU @@ -416,7 +417,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(assets_zip_path, bundle_path_buf, "assets.zip", sizeof(assets_zip_path)); - if (path_file_exists(assets_zip_path)) + if (filestream_exists(assets_zip_path)) { settings_t *settings = config_get_ptr(); diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 8443348c63..9de04586cb 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -42,6 +42,7 @@ #include #endif #include +#include #include "../frontend_driver.h" #include "../../defaults.h" @@ -405,7 +406,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) sizeof(salamander_basename)); /* FIXME/TODO - hack - * direct loading failed (out of memory), + * direct loading failed (out of memory), * try to jump to Salamander, * then load the correct core */ fill_pathname_join(s, g_defaults.dirs[DEFAULT_DIR_CORE], @@ -424,7 +425,7 @@ static void frontend_gx_process_args(int *argc, char *argv[]) { char path[PATH_MAX_LENGTH] = {0}; strlcpy(path, strrchr(argv[0], '/') + 1, sizeof(path)); - if (path_file_exists(path)) + if (filestream_exists(path)) rarch_ctl(RARCH_CTL_SET_LIBRETRO_PATH, path); } #endif diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 9360feef2d..6e959f45ca 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -33,6 +33,7 @@ #include #include +#include #include #ifndef IS_SALAMANDER #include @@ -56,7 +57,7 @@ SYS_PROCESS_PARAM(1001, 0x100000) #else SYS_PROCESS_PARAM(1001, 0x200000) #endif - + #ifdef HAVE_MULTIMAN #define MULTIMAN_SELF_FILE "/dev_hdd0/game/BLES80608/USRDIR/RELOAD.SELF" static bool multiman_detected = false; @@ -125,7 +126,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], #ifdef HAVE_MULTIMAN /* not launched from external launcher, set default path */ // second param is multiMAN SELF file - if(path_file_exists(argv[2]) && *argc > 1 + if ( filestream_exists(argv[2]) && *argc > 1 && (string_is_equal(argv[2], EMULATOR_CONTENT_DIR))) { multiman_detected = true; @@ -189,7 +190,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], break; } - if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) + if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); @@ -588,7 +589,7 @@ static void frontend_ps3_process_args(int *argc, char *argv[]) { char path[PATH_MAX_LENGTH] = {0}; strlcpy(path, argv[0], sizeof(path)); - if (path_file_exists(path)) + if (filestream_exists(path)) rarch_ctl(RARCH_CTL_SET_LIBRETRO_PATH, path); } #endif diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index b115e22520..e1497b3b57 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "../../defaults.h" @@ -45,7 +46,7 @@ static void frontend_qnx_shutdown(bool unused) static int frontend_qnx_get_rating(void) { - /* TODO/FIXME - look at unique identifier per device and + /* TODO/FIXME - look at unique identifier per device and * determine rating for some */ return -1; } @@ -54,12 +55,13 @@ static void frontend_qnx_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { unsigned i; - char assets_path[PATH_MAX] = {0}; - char data_path[PATH_MAX] = {0}; - char user_path[PATH_MAX] = {0}; - char tmp_path[PATH_MAX] = {0}; + char data_assets_path[PATH_MAX] = {0}; + char assets_path[PATH_MAX] = {0}; + char data_path[PATH_MAX] = {0}; + char user_path[PATH_MAX] = {0}; + char tmp_path[PATH_MAX] = {0}; + char workdir[PATH_MAX] = {0}; - char workdir[PATH_MAX] = {0}; getcwd(workdir, sizeof(workdir)); if(!string_is_empty(workdir)) @@ -140,20 +142,20 @@ static void frontend_qnx_get_environment_settings(int *argc, char *argv[], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); /* bundle copy */ - char data_assets_path[PATH_MAX] = {0}; sprintf(data_assets_path, "%s/%s", data_path, "assets"); - if(!path_file_exists(data_assets_path)) + + if (!filestream_exists(data_assets_path)) { + char copy_command[PATH_MAX] = {0}; + RARCH_LOG( "Copying application assets to data directory...\n" ); - char copy_command[PATH_MAX] = {0}; sprintf(copy_command, "cp -r %s/. %s", assets_path, data_path); - if(system(copy_command) == -1) { + if(system(copy_command) == -1) RARCH_LOG( "Asset copy failed: Shell could not be run.\n" ); - } else { + else RARCH_LOG( "Asset copy successful.\n"); - } } for (i = 0; i < DEFAULT_DIR_LAST; i++) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 80bd183322..15d93a7554 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -667,7 +667,7 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery, snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); - if (!path_file_exists(path)) + if (!filestream_exists(path)) goto end; if (!filestream_read_file(path, (void**)&buf, &length)) @@ -795,8 +795,9 @@ static void check_proc_acpi_sysfs_battery(const char *node, snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status"); - if (!path_file_exists(path)) + if (!filestream_exists(path)) return; + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; @@ -842,8 +843,9 @@ static void check_proc_acpi_ac_adapter(const char * node, bool *have_ac) path[0] = '\0'; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); - if (!path_file_exists(path)) + if (!filestream_exists(path)) return; + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; @@ -873,8 +875,9 @@ static void check_proc_acpi_sysfs_ac_adapter(const char * node, bool *have_ac) path[0] = '\0'; snprintf(path, sizeof(path), "%s/%s", base, "online"); - if (!path_file_exists(path)) + if (!filestream_exists(path)) return; + if (filestream_read_file(path, (void**)&buf, &length) != 1) return; @@ -928,8 +931,9 @@ static bool frontend_unix_powerstate_check_apm( char *buf = NULL; char *str = NULL; - if (!path_file_exists(proc_apm_path)) + if (!filestream_exists(proc_apm_path)) goto error; + if (filestream_read_file(proc_apm_path, (void**)&buf, &length) != 1) goto error; @@ -1212,8 +1216,20 @@ static void frontend_unix_get_os(char *s, return; sscanf(buffer.release, "%d.%d.%u", major, minor, &krel); +#if defined(__FreeBSD__) + strlcpy(s, "FreeBSD", len); +#elif defined(__NetBSD__) + strlcpy(s, "NetBSD", len); +#elif defined(__OpenBSD__) + strlcpy(s, "OpenBSD", len); +#elif defined(__DragonFly__) + strlcpy(s, "DragonFly BSD", len); +#elif defined(BSD) + strlcpy(s, "BSD", len); +#else strlcpy(s, "Linux", len); #endif +#endif } #ifdef HAVE_LAKKA @@ -1502,7 +1518,7 @@ static void frontend_unix_get_env(int *argc, __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: app dir: [%s]\n", app_dir); - /* set paths depending on the ability to write + /* set paths depending on the ability to write * to internal_storage_path */ if(!string_is_empty(internal_storage_path)) @@ -1592,7 +1608,7 @@ static void frontend_unix_get_env(int *argc, internal_storage_app_path, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); - if(!string_is_empty(screenshot_dir) + if(!string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], @@ -1606,7 +1622,7 @@ static void frontend_unix_get_env(int *argc, sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - if(!string_is_empty(downloads_dir) + if(!string_is_empty(downloads_dir) && test_permissions(downloads_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], @@ -1621,7 +1637,7 @@ static void frontend_unix_get_env(int *argc, } break; - + /* only the internal app dir is writable, this should never happen*/ case INTERNAL_STORAGE_NOT_WRITABLE: fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], @@ -1650,7 +1666,7 @@ static void frontend_unix_get_env(int *argc, app_dir, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); - if( !string_is_empty(screenshot_dir) + if( !string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], @@ -1664,7 +1680,7 @@ static void frontend_unix_get_env(int *argc, sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - if(!string_is_empty(downloads_dir) + if(!string_is_empty(downloads_dir) && test_permissions(downloads_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], @@ -1768,7 +1784,7 @@ static void frontend_unix_get_env(int *argc, #endif #if 0 - /* Set the OK/cancel menu buttons to the default + /* Set the OK/cancel menu buttons to the default * ones used for Shield */ g_defaults.menu.controls.set = true; g_defaults.menu.controls.menu_btn_ok = RETRO_DEVICE_ID_JOYPAD_B; @@ -2035,7 +2051,7 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content) menu_entries_append_enum(list, "/storage", msg_hash_to_str(MSG_REMOVABLE_STORAGE), - enum_idx, + enum_idx, FILE_TYPE_DIRECTORY, 0, 0); #endif @@ -2175,7 +2191,7 @@ VALGRIND_PRINTF_BACKTRACE("SIGINT"); if (unix_sighandler_quit == 1) {} if (unix_sighandler_quit == 2) exit(1); /* in case there's a second deadlock in a C++ destructor or something */ - if (unix_sighandler_quit >= 3) abort(); + if (unix_sighandler_quit >= 3) abort(); } static void frontend_unix_install_signal_handlers(void) diff --git a/frontend/drivers/platform_unix.h b/frontend/drivers/platform_unix.h index db5eacceb3..c5a028ccc8 100644 --- a/frontend/drivers/platform_unix.h +++ b/frontend/drivers/platform_unix.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -244,7 +244,7 @@ enum /** * Command from main thread: the app should generate a new saved state - * for itself, to restore from later if needed. + * for itself, to restore from later if needed. */ APP_CMD_SAVE_STATE, diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index ac5ebfaea3..51b0d9c148 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -74,9 +74,9 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) } /* a relative path */ else if ( - (strstr(dolpath, "sd:/") != dolpath) && + (strstr(dolpath, "sd:/") != dolpath) && (strstr(dolpath, "usb:/") != dolpath) && - (strstr(dolpath, "carda:/") != dolpath) && + (strstr(dolpath, "carda:/") != dolpath) && (strstr(dolpath, "cardb:/") != dolpath) ) { @@ -119,7 +119,7 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length); } -/* WARNING: after we move any data +/* WARNING: after we move any data * into EXECUTE_ADDR, we can no longer use any * heap memory and are restricted to the stack only. */ void system_exec_wii(const char *_path, bool should_load_game) @@ -133,7 +133,7 @@ void system_exec_wii(const char *_path, bool should_load_game) bool original_verbose = verbosity_is_enabled(); #endif - /* copy heap info into stack so it survives + /* copy heap info into stack so it survives * us moving the .dol into MEM2. */ strlcpy(path, _path, sizeof(path)); if (should_load_game) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index c97ec97139..925f820652 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -58,7 +58,9 @@ #include #include -#include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#if defined(ENABLE_CONTROLLER_PATCHER) + #include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#endif #include #include @@ -430,7 +432,7 @@ int main(int argc, char **argv) KPADInit(); #endif verbosity_enable(); -#ifndef IS_SALAMANDER +#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER) ControllerPatcherInit(); #endif fflush(stdout); @@ -492,7 +494,7 @@ int main(int argc, char **argv) } while (1); -#ifndef IS_SALAMANDER +#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER) ControllerPatcherDeInit(); #endif main_exit(NULL); @@ -523,22 +525,25 @@ void __eabi() __attribute__((weak)) void __init(void) { - extern void(*__CTOR_LIST__[])(void); - void(**ctor)(void) = __CTOR_LIST__; + extern void (*const __CTOR_LIST__)(void); + extern void (*const __CTOR_END__)(void); - while (*ctor) + void (*const *ctor)(void) = &__CTOR_LIST__; + while (ctor < &__CTOR_END__) { (*ctor++)(); + } } - __attribute__((weak)) void __fini(void) { - extern void(*__DTOR_LIST__[])(void); - void(**ctor)(void) = __DTOR_LIST__; + extern void (*const __DTOR_LIST__)(void); + extern void (*const __DTOR_END__)(void); - while (*ctor) - (*ctor++)(); + void (*const *dtor)(void) = &__DTOR_LIST__; + while (dtor < &__DTOR_END__) { + (*dtor++)(); + } } /* libiosuhax related */ @@ -633,7 +638,7 @@ int __entry_menu(int argc, char **argv) int ret = main(argc, argv); fsdev_exit(); -// __fini(); + __fini(); memoryRelease(); return ret; } @@ -648,7 +653,10 @@ void _start(int argc, char **argv) main(argc, argv); fsdev_exit(); -// __fini(); + +/* TODO: fix elf2rpl so it doesn't error with "Could not find matching symbol + for relocation" then uncomment this */ +// __fini(); memoryRelease(); SYSRelaunchTitle(0, 0); exit(0); diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 02ae1dd7d3..31b238c814 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -1,5 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -25,6 +26,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -40,8 +42,8 @@ #include "../../retroarch.h" #include "../../verbosity.h" -/* We only load this library once, so we let it be - * unloaded at application shutdown, since unloading +/* We only load this library once, so we let it be + * unloaded at application shutdown, since unloading * it early seems to cause issues on some systems. */ @@ -87,10 +89,10 @@ static bool gfx_init_dwm(void) return false; } - DragAcceptFiles_func = + DragAcceptFiles_func = (VOID (WINAPI*)(HWND, BOOL))dylib_proc(shell32lib, "DragAcceptFiles"); - mmcss = + mmcss = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { @@ -114,7 +116,7 @@ static void gfx_set_dwm(void) if (settings->bools.video_disable_composition == dwm_composition_disabled) return; - composition_enable = + composition_enable = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); if (!composition_enable) { @@ -130,40 +132,113 @@ static void gfx_set_dwm(void) static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) { - uint32_t version = GetVersion(); + char buildStr[11] = {0}; + bool server = false; + const char *arch = ""; + bool serverR2 = false; - *major = (DWORD)(LOBYTE(LOWORD(version))); - *minor = (DWORD)(HIBYTE(LOWORD(version))); +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and later */ + SYSTEM_INFO si = {0}; + OSVERSIONINFOEX vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - switch (*major) + GetSystemInfo(&si); + + /* Available from NT 3.5 and Win95 */ + GetVersionEx((OSVERSIONINFO*)&vi); + + server = vi.wProductType != VER_NT_WORKSTATION; + serverR2 = GetSystemMetrics(SM_SERVERR2); + + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + arch = "x64"; + break; + case PROCESSOR_ARCHITECTURE_INTEL: + arch = "x86"; + break; + case PROCESSOR_ARCHITECTURE_ARM: + arch = "ARM"; + break; + default: + break; + } +#else + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + /* Available from NT 3.5 and Win95 */ + GetVersionEx(&vi); +#endif + + + if (major) + *major = vi.dwMajorVersion; + + if (minor) + *minor = vi.dwMinorVersion; + + if (vi.dwMajorVersion == 4 && vi.dwMinorVersion == 0) + snprintf(buildStr, sizeof(buildStr), "%lu", (DWORD)(LOWORD(vi.dwBuildNumber))); /* Windows 95 build number is in the low-order word only */ + else + snprintf(buildStr, sizeof(buildStr), "%lu", vi.dwBuildNumber); + + switch (vi.dwMajorVersion) { case 10: - strlcpy(s, "Windows 10", len); + if (server) + strlcpy(s, "Windows Server 2016", len); + else + strlcpy(s, "Windows 10", len); break; case 6: - switch (*minor) + switch (vi.dwMinorVersion) { case 3: - strlcpy(s, "Windows 8.1", len); + if (server) + strlcpy(s, "Windows Server 2012 R2", len); + else + strlcpy(s, "Windows 8.1", len); break; case 2: - strlcpy(s, "Windows 8", len); + if (server) + strlcpy(s, "Windows Server 2012", len); + else + strlcpy(s, "Windows 8", len); break; case 1: - strlcpy(s, "Windows 7/2008 R2", len); + if (server) + strlcpy(s, "Windows Server 2008 R2", len); + else + strlcpy(s, "Windows 7", len); break; case 0: - strlcpy(s, "Windows Vista/2008", len); + if (server) + strlcpy(s, "Windows Server 2008", len); + else + strlcpy(s, "Windows Vista", len); break; default: break; } break; case 5: - switch (*minor) + switch (vi.dwMinorVersion) { case 2: - strlcpy(s, "Windows 2003", len); + if (server) + if (serverR2) + strlcpy(s, "Windows Server 2003 R2", len); + else + strlcpy(s, "Windows Server 2003", len); + else + { + /* Yes, XP Pro x64 is a higher version number than XP x86 */ + if (string_is_equal(arch, "x64")) + strlcpy(s, "Windows XP", len); + } break; case 1: strlcpy(s, "Windows XP", len); @@ -174,10 +249,15 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) } break; case 4: - switch (*minor) + switch (vi.dwMinorVersion) { case 0: - strlcpy(s, "Windows NT 4.0", len); + if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + strlcpy(s, "Windows 95", len); + else if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) + strlcpy(s, "Windows NT 4.0", len); + else + strlcpy(s, "Unknown", len); break; case 90: strlcpy(s, "Windows ME", len); @@ -188,20 +268,35 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) } break; default: - sprintf(s, "Windows %i.%i", *major, *minor); + snprintf(s, len, "Windows %i.%i", *major, *minor); break; } + + if (!string_is_empty(arch)) + { + strlcat(s, " ", len); + strlcat(s, arch, len); + } + + strlcat(s, " Build ", len); + strlcat(s, buildStr, len); + + if (!string_is_empty(vi.szCSDVersion)) + { + strlcat(s, " ", len); + strlcat(s, vi.szCSDVersion, len); + } } static void frontend_win32_init(void *data) { typedef BOOL (WINAPI *isProcessDPIAwareProc)(); typedef BOOL (WINAPI *setProcessDPIAwareProc)(); - HMODULE handle = + HMODULE handle = GetModuleHandle("User32.dll"); - isProcessDPIAwareProc isDPIAwareProc = + isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware"); - setProcessDPIAwareProc setDPIAwareProc = + setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware"); if (isDPIAwareProc) @@ -212,7 +307,7 @@ static void frontend_win32_init(void *data) setDPIAwareProc(); } } - + } enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent) @@ -246,7 +341,28 @@ enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percen enum frontend_architecture frontend_win32_get_architecture(void) { - /* stub */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and later */ + SYSTEM_INFO si = {0}; + + GetSystemInfo(&si); + + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + return FRONTEND_ARCH_X86_64; + break; + case PROCESSOR_ARCHITECTURE_INTEL: + return FRONTEND_ARCH_X86; + break; + case PROCESSOR_ARCHITECTURE_ARM: + return FRONTEND_ARCH_ARM; + break; + default: + break; + } +#endif + return FRONTEND_ARCH_NONE; } @@ -340,7 +456,7 @@ static uint64_t frontend_win32_get_mem_total(void) { /* OSes below 2000 don't have the Ex version, * and non-Ex cannot work with >4GB RAM */ -#if _WIN32_WINNT > 0x0400 +#if _WIN32_WINNT >= 0x0500 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&mem_info); @@ -355,9 +471,9 @@ static uint64_t frontend_win32_get_mem_total(void) static uint64_t frontend_win32_get_mem_used(void) { - /* OSes below 2000 don't have the Ex version, + /* OSes below 2000 don't have the Ex version, * and non-Ex cannot work with >4GB RAM */ -#if _WIN32_WINNT > 0x0400 +#if _WIN32_WINNT >= 0x0500 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&mem_info); @@ -376,24 +492,24 @@ static void frontend_win32_attach_console(void) #ifdef _WIN32_WINNT_WINXP /* msys will start the process with FILE_TYPE_PIPE connected. - * cmd will start the process with FILE_TYPE_UNKNOWN connected + * cmd will start the process with FILE_TYPE_UNKNOWN connected * (since this is subsystem windows application - * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK + * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK * will be connected most likely) * explorer will start the process with NOTHING connected. * * Now, let's not reconnect anything that's already connected. * If any are disconnected, open a console, and connect to them. - * In case we're launched from msys or cmd, try attaching to the + * In case we're launched from msys or cmd, try attaching to the * parent process console first. * - * Take care to leave a record of what we did, so we can + * Take care to leave a record of what we did, so we can * undo it precisely. */ - bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) + bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_UNKNOWN); - bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) + bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_UNKNOWN); if(need_stdout || need_stderr) @@ -418,8 +534,8 @@ static void frontend_win32_detach_console(void) if(console_needs_free) { - /* we don't reconnect stdout/stderr to anything here, - * because by definition, they weren't connected to + /* we don't reconnect stdout/stderr to anything here, + * because by definition, they weren't connected to * anything in the first place. */ FreeConsole(); console_needs_free = false; diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 3c626285d8..e67d5935ba 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -240,10 +240,10 @@ typedef struct _FILE_FS_SIZE_INFORMATION { #define DEVICE_TYPE ULONG // Structure of FileFsDeviceInformation -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; +typedef struct _FILE_FS_DEVICE_INFORMATION { + DEVICE_TYPE DeviceType; + ULONG Characteristics; +} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; // DEVICE_TYPEs (I took a guess as to which the XBOX might have.) #define FILE_DEVICE_CD_ROM 0x00000002 @@ -993,12 +993,12 @@ extern "C" // Thanks and credit go to Team Evox extern VOID WINAPI HalReturnToFirmware(DWORD); - extern INT WINAPI XNetLoadConfigParams(LPBYTE); - extern INT WINAPI XNetSaveConfigParams(LPBYTE); + extern INT WINAPI XNetLoadConfigParams(LPBYTE); + extern INT WINAPI XNetSaveConfigParams(LPBYTE); extern INT WINAPI XWriteTitleInfoNoReboot(LPVOID,LPVOID,DWORD,DWORD,LPVOID); - extern DWORD* LaunchDataPage; + extern DWORD* LaunchDataPage; } #endif @@ -1006,7 +1006,7 @@ extern "C" static enum frontend_fork xdk_fork_mode = FRONTEND_FORK_NONE; #ifdef _XBOX360 -typedef struct _STRING +typedef struct _STRING { USHORT Length; USHORT MaximumLength; @@ -1016,7 +1016,7 @@ typedef struct _STRING #ifdef __cplusplus extern "C" { #endif -VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); +VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); HRESULT ObDeleteSymbolicLink(PSTRING SymbolicLinkName); HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName); #ifdef __cplusplus diff --git a/frontend/frontend.c b/frontend/frontend.c index b6dcca2cd2..137d9fa0bf 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -102,7 +102,7 @@ int rarch_main(int argc, char *argv[], void *data) rarch_ctl(RARCH_CTL_PREINIT, NULL); frontend_driver_init_first(args); rarch_ctl(RARCH_CTL_INIT, NULL); - + if (frontend_driver_is_inited()) { content_ctx_info_t info; diff --git a/frontend/frontend.h b/frontend/frontend.h index fed99639ce..ef821097c4 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -34,14 +34,14 @@ RETRO_BEGIN_DECLS * and (optionally) autosave state. **/ void main_exit(void *args); - + /** * main_entry: * * Main function of RetroArch. * * If HAVE_MAIN is not defined, will contain main loop and will not - * be exited from until we exit the program. Otherwise, will + * be exited from until we exit the program. Otherwise, will * just do initialization. * * Returns: varies per platform. diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index e8c2441e29..52868ec0c8 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -56,7 +56,7 @@ static void find_first_libretro_core(char *first_file, RARCH_LOG("Searching for valid libretro implementation in: \"%s\".\n", dir); - + for (i = 0; i < list->size && !ret; i++) { char fname[PATH_MAX_LENGTH] = {0}; @@ -94,7 +94,7 @@ static void find_first_libretro_core(char *first_file, dir_list_free(list); } -/* Last fallback - we'll need to start the first executable file +/* Last fallback - we'll need to start the first executable file * we can find in the RetroArch cores directory. */ static void find_and_set_first_file(char *s, size_t len, @@ -135,9 +135,9 @@ static void salamander_init(char *s, size_t len) strlcpy(s, tmp_str, len); } #ifdef GEKKO - /* stupid libfat bug or something; sometimes it says + /* stupid libfat bug or something; sometimes it says * the file is there when it doesn't. */ - else + else { config_exists = false; } diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index 07976b7393..5de2e746c9 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -111,7 +111,7 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, const char *path, unsigned width, unsigned height, unsigned miplevels, unsigned usage, D3DFORMAT format, D3DPOOL pool, unsigned filter, unsigned mipfilter, - D3DCOLOR color_key, void *src_info_data, + D3DCOLOR color_key, void *src_info_data, PALETTEENTRY *palette) { HRESULT hr; @@ -535,7 +535,7 @@ void d3d_clear(LPDIRECT3DDEVICE dev, #if defined(_XBOX1) D3DDevice_Clear(count, rects, flags, color, z, stencil); #elif defined(_XBOX360) - D3DDevice_Clear(dev, count, rects, flags, color, z, + D3DDevice_Clear(dev, count, rects, flags, color, z, stencil, false); #elif defined(HAVE_D3D9) && !defined(__cplusplus) IDirect3DDevice9_Clear(dev, count, rects, flags, @@ -646,10 +646,10 @@ void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, #if defined(_XBOX1) D3DDevice_SetTexture(sampler, tex); #elif defined(_XBOX360) - unsigned fetchConstant = + unsigned fetchConstant = GPU_CONVERT_D3D_TO_HARDWARE_TEXTUREFETCHCONSTANT(sampler); - uint64_t pendingMask3 = - D3DTAG_MASKENCODE(D3DTAG_START(D3DTAG_FETCHCONSTANTS) + uint64_t pendingMask3 = + D3DTAG_MASKENCODE(D3DTAG_START(D3DTAG_FETCHCONSTANTS) + fetchConstant, D3DTAG_START(D3DTAG_FETCHCONSTANTS) + fetchConstant); #if defined(__cplusplus) @@ -976,7 +976,7 @@ D3DTEXTUREFILTERTYPE d3d_translate_filter(unsigned type) return D3DTEXF_POINT; } - + void *d3d_matrix_transpose(void *_pout, const void *_pm) { unsigned i,j; diff --git a/gfx/common/d3d_common.h b/gfx/common/d3d_common.h index 8fd61d2aad..fa88fb2e55 100644 --- a/gfx/common/d3d_common.h +++ b/gfx/common/d3d_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -45,7 +45,7 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, const char *path, unsigned width, unsigned height, unsigned miplevels, unsigned usage, D3DFORMAT format, D3DPOOL pool, unsigned filter, unsigned mipfilter, - D3DCOLOR color_key, void *src_info, + D3DCOLOR color_key, void *src_info, PALETTEENTRY *palette); void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no, diff --git a/gfx/common/dbus_common.c b/gfx/common/dbus_common.c index 4fd335a8f6..7270510337 100644 --- a/gfx/common/dbus_common.c +++ b/gfx/common/dbus_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -30,7 +30,7 @@ void dbus_ensure_connection(void) #ifdef HAVE_DBUS DBusError err; int ret; - + dbus_error_init(&err); dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); diff --git a/gfx/common/dbus_common.h b/gfx/common/dbus_common.h index c8a4e5f3e4..97f6b2a97c 100644 --- a/gfx/common/dbus_common.h +++ b/gfx/common/dbus_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index b1d11ec999..33052c83e1 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/drm_common.h b/gfx/common/drm_common.h index e66e1c1704..87458dac9a 100644 --- a/gfx/common/drm_common.h +++ b/gfx/common/drm_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 691213f7b6..a0dd747c24 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -174,7 +174,7 @@ void egl_swap_buffers(void *data) void egl_set_swap_interval(egl_ctx_data_t *egl, unsigned interval) { /* Can be called before initialization. - * Some contexts require that swap interval + * Some contexts require that swap interval * is known at startup time. */ egl->interval = interval; diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 70f48b666d..e82f889567 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index f349938427..98a4c41c58 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -14,16 +14,13 @@ * If not, see . */ -#include #include #ifdef HAVE_CONFIG_H #include "../../config.h" #endif -#include "../drivers/gl_symlinks.h" -#include "../video_coord_array.h" - +#include "gl_common.h" static void gl_size_format(GLint* internalFormat) { diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 5d5c1fa284..46b1c0b621 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -17,7 +17,9 @@ #ifndef __GL_COMMON_H #define __GL_COMMON_H +#include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -32,14 +34,124 @@ #include "../font_driver.h" #include "../video_coord_array.h" #include "../video_driver.h" -#include "../drivers/gl_symlinks.h" +#include RETRO_BEGIN_DECLS -#define MAX_FENCES 4 +#if defined(HAVE_PSGL) +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT +#else +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0 +#endif -#ifndef ARB_sync -typedef struct __GLsync *GLsync; +#if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER +#if defined(HAVE_OPENGLES2) +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES +#else +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 +#endif +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT +#elif defined(HAVE_PSGL) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES +#else +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT +#endif + +#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT +#elif defined(HAVE_PSGL) +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES +#else +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE +#endif + +#if defined(HAVE_PSGL) +#define glGenerateMipmap glGenerateMipmapOES +#endif + +#if defined(__APPLE__) || defined(HAVE_PSGL) +#define GL_RGBA32F GL_RGBA32F_ARB +#endif + +#if defined(HAVE_PSGL) +#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_RGB5 +#elif defined(HAVE_OPENGLES) +/* Imgtec/SGX headers have this missing. */ +#ifndef GL_BGRA_EXT +#define GL_BGRA_EXT 0x80E1 +#endif +#ifndef GL_BGRA8_EXT +#define GL_BGRA8_EXT 0x93A1 +#endif +#ifdef IOS +/* Stupid Apple */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA +#else +#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT +#endif +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT +#define RARCH_GL_TEXTURE_TYPE16 GL_RGB +#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE +#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 +#else +/* On desktop, we always use 32-bit. */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV + +/* GL_RGB565 internal format isn't in desktop GL + * until 4.1 core (ARB_ES2_compatibility). + * Check for this. */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif +#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 +#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB +#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 +#endif + +#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ +#define NO_GL_CLAMP_TO_BORDER +#endif + +#if defined(HAVE_OPENGLES) +#ifndef GL_UNPACK_ROW_LENGTH +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#endif + +#ifndef GL_SRGB_ALPHA_EXT +#define GL_SRGB_ALPHA_EXT 0x8C42 +#endif #endif typedef struct gl @@ -54,11 +166,7 @@ typedef struct gl bool fbo_inited; bool fbo_feedback_enable; bool hw_render_fbo_init; - bool hw_render_depth_init; bool has_fbo; - bool has_srgb_fbo_gles3; - bool has_fp_fbo; - bool has_srgb_fbo; bool hw_render_use; bool core_context_in_use; @@ -71,7 +179,6 @@ typedef struct gl bool have_full_npot_support; bool have_mipmap; - bool egl_images; bool overlay_enable; bool overlay_full_screen; bool menu_texture_enable; @@ -82,7 +189,6 @@ typedef struct gl int version_major; int version_minor; - int fbo_pass; GLuint tex_mag_filter; GLuint tex_min_filter; @@ -91,13 +197,9 @@ typedef struct gl GLuint pbo; GLuint *overlay_tex; GLuint menu_texture; - GLuint vao; GLuint pbo_readback[4]; GLuint texture[GFX_MAX_TEXTURES]; - GLuint fbo[GFX_MAX_SHADERS]; - GLuint fbo_texture[GFX_MAX_SHADERS]; GLuint hw_render_fbo[GFX_MAX_TEXTURES]; - GLuint hw_render_depth[GFX_MAX_TEXTURES]; unsigned tex_index; /* For use with PREV. */ unsigned textures; @@ -110,7 +212,6 @@ typedef struct gl unsigned base_size; /* 2 or 4 */ unsigned overlays; unsigned pbo_readback_index; - unsigned fence_count; unsigned last_width[GFX_MAX_TEXTURES]; unsigned last_height[GFX_MAX_TEXTURES]; @@ -134,9 +235,7 @@ typedef struct gl video_info_t video_info; struct video_tex_info prev_info[GFX_MAX_TEXTURES]; struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; - struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; - GLsync fences[MAX_FENCES]; const gl_renderchain_driver_t *renderchain_driver; void *renderchain_data; } gl_t; diff --git a/gfx/common/vita2d_common.h b/gfx/common/vita2d_common.h index 010f3fca10..39006586a8 100644 --- a/gfx/common/vita2d_common.h +++ b/gfx/common/vita2d_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -41,12 +41,12 @@ struct vita_overlay_data { vita2d_texture *tex; float x; - float y; - float w; + float y; + float w; float h; float tex_x; - float tex_y; - float tex_w; + float tex_y; + float tex_w; float tex_h; float alpha_mod; float width; @@ -76,14 +76,14 @@ typedef struct vita_video bool should_resize; vita_menu_t menu; - + #ifdef HAVE_OVERLAY struct vita_overlay_data *overlay; unsigned overlays; bool overlay_enable; bool overlay_full_screen; #endif - + } vita_video_t; #endif diff --git a/gfx/common/vksym.h b/gfx/common/vksym.h index 02717d7d3f..257952d93a 100644 --- a/gfx/common/vksym.h +++ b/gfx/common/vksym.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 461e61131e..91990eadb4 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1,6 +1,6 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -28,6 +28,7 @@ #endif #include "vulkan_common.h" +#include "../../libretro-common/include/retro_timers.h" #include "../../configuration.h" static dylib_t vulkan_library; @@ -161,14 +162,14 @@ void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd, vulkan_sync_texture_to_gpu(vk, staging); vulkan_transition_texture(vk, cmd, staging); - /* We don't have to sync against previous TRANSFER, - * since we observed the completion by fences. + /* We don't have to sync against previous TRANSFER, + * since we observed the completion by fences. * * If we have a single texture_optimal, we would need to sync against * previous transfers to avoid races. * - * We would also need to optionally maintain extra textures due to - * changes in resolution, so this seems like the sanest and + * We would also need to optionally maintain extra textures due to + * changes in resolution, so this seems like the sanest and * simplest solution. */ vulkan_image_layout_transition(vk, cmd, dynamic->image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -412,7 +413,7 @@ struct vk_texture vulkan_create_texture(vk_t *vk, /* If the texture is STREAMED and it's not DEVICE_LOCAL, we expect to hit a slower path, * so fallback to copy path. */ - if (type == VULKAN_TEXTURE_STREAMED && + if (type == VULKAN_TEXTURE_STREAMED && (vk->context->memory_properties.memoryTypes[alloc.memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0) { @@ -656,8 +657,8 @@ struct vk_texture vulkan_create_texture(vk_t *vk, vkQueueSubmit(vk->context->queue, 1, &submit_info, VK_NULL_HANDLE); - /* TODO: Very crude, but texture uploads only happen - * during init, so waiting for GPU to complete transfer + /* TODO: Very crude, but texture uploads only happen + * during init, so waiting for GPU to complete transfer * and blocking isn't a big deal. */ vkQueueWaitIdle(vk->context->queue); #ifdef HAVE_THREADS @@ -732,7 +733,7 @@ static void vulkan_write_quad_descriptors( void vulkan_transition_texture(vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture) { /* Transition to GENERAL layout for linear streamed textures. - * We're using linear textures here, so only + * We're using linear textures here, so only * GENERAL layout is supported. * If we're already in GENERAL, add a host -> shader read memory barrier * to invalidate texture caches. @@ -773,7 +774,7 @@ static void vulkan_check_dynamic_state( if (vk->tracker.dirty & VULKAN_DIRTY_DYNAMIC_BIT) { VkRect2D sci; - + sci.offset.x = vk->vp.x; sci.offset.y = vk->vp.y; sci.extent.width = vk->vp.width; @@ -872,7 +873,7 @@ void vulkan_draw_quad(vk_t *vk, const struct vk_draw_quad *quad) if ( string_is_equal_fast(quad->mvp, - &vk->tracker.mvp, sizeof(*quad->mvp)) + &vk->tracker.mvp, sizeof(*quad->mvp)) || quad->texture->view != vk->tracker.view || quad->sampler != vk->tracker.sampler) { @@ -938,7 +939,7 @@ void vulkan_image_layout_transition( VkPipelineStageFlags srcStages, VkPipelineStageFlags dstStages) { - VkImageMemoryBarrier barrier = + VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; barrier.srcAccessMask = srcAccess; @@ -981,12 +982,12 @@ struct vk_buffer vulkan_create_buffer( alloc.memoryTypeIndex = vulkan_find_memory_type( &context->memory_properties, mem_reqs.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); vkAllocateMemory(context->device, &alloc, NULL, &buffer.memory); vkBindBufferMemory(context->device, buffer.buffer, buffer.memory, 0); - buffer.size = alloc.allocationSize; + buffer.size = size; vkMapMemory(context->device, buffer.memory, 0, buffer.size, 0, &buffer.mapped); @@ -1010,12 +1011,12 @@ static struct vk_descriptor_pool *vulkan_alloc_descriptor_pool( const struct vk_descriptor_manager *manager) { unsigned i; - VkDescriptorPoolCreateInfo pool_info = { + VkDescriptorPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; - VkDescriptorSetAllocateInfo alloc_info = { + VkDescriptorSetAllocateInfo alloc_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; - struct vk_descriptor_pool *pool = + struct vk_descriptor_pool *pool = (struct vk_descriptor_pool*)calloc(1, sizeof(*pool)); if (!pool) return NULL; @@ -1119,12 +1120,12 @@ static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, range->data = (uint8_t*)chain->current->buffer.mapped + chain->offset; range->buffer = chain->current->buffer.buffer; range->offset = chain->offset; - chain->offset = (next_offset + chain->alignment - 1) + chain->offset = (next_offset + chain->alignment - 1) & ~(chain->alignment - 1); return true; } - + return false; } @@ -1148,7 +1149,7 @@ struct vk_buffer_chain vulkan_buffer_chain_init( VkBufferUsageFlags usage) { struct vk_buffer_chain chain; - + chain.block_size = block_size; chain.alignment = alignment; chain.offset = 0; @@ -1193,7 +1194,7 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, } /* We have to allocate a new node, might allocate larger - * buffer here than block_size in case we have + * buffer here than block_size in case we have * a very large allocation. */ if (size < chain->block_size) size = chain->block_size; @@ -1398,7 +1399,6 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) { bool use_device_ext; uint32_t queue_count; - VkResult res; unsigned i; static const float one = 1.0f; bool found_queue = false; @@ -1684,7 +1684,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, } RARCH_LOG("Vulkan dynamic library loaded.\n"); - + GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dylib_proc(vulkan_library, "vkGetInstanceProcAddr"); @@ -2012,7 +2012,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, PFN_vkCreateWaylandSurfaceKHR create; if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(vk->context.instance, "vkCreateWaylandSurfaceKHR", create)) return false; - VkWaylandSurfaceCreateInfoKHR surf_info; + VkWaylandSurfaceCreateInfoKHR surf_info; memset(&surf_info, 0, sizeof(surf_info)); @@ -2091,7 +2091,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.window = *(const Window*)surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2114,7 +2114,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.window = *(const xcb_window_t*)surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2136,7 +2136,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.mirSurface = surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2163,6 +2163,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, vk, width, height, swap_interval)) return false; + vulkan_acquire_next_image(vk); return true; } @@ -2172,6 +2173,13 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) VkResult result = VK_SUCCESS; VkResult err = VK_SUCCESS; + /* We're still waiting for a proper swapchain, so just fake it. */ + if (vk->swapchain == VK_NULL_HANDLE) + { + retro_sleep(10); + return; + } + present.swapchainCount = 1; present.pSwapchains = &vk->swapchain; present.pImageIndices = &index; @@ -2254,17 +2262,72 @@ void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, } } +static void vulkan_acquire_clear_fences(gfx_ctx_vulkan_data_t *vk) +{ + unsigned i; + for (i = 0; i < vk->context.num_swapchain_images; i++) + { + if (vk->context.swapchain_fences[i]) + { + vkDestroyFence(vk->context.device, + vk->context.swapchain_fences[i], NULL); + vk->context.swapchain_fences[i] = VK_NULL_HANDLE; + vk->context.swapchain_fences_signalled[i] = false; + } + } +} + +static void vulkan_acquire_wait_fences(gfx_ctx_vulkan_data_t *vk) +{ + VkFenceCreateInfo fence_info = + { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; + + unsigned index = vk->context.current_swapchain_index; + VkFence *next_fence = &vk->context.swapchain_fences[index]; + + if (*next_fence != VK_NULL_HANDLE) + { + if (vk->context.swapchain_fences_signalled[index]) + vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); + vkResetFences(vk->context.device, 1, next_fence); + vk->context.swapchain_fences_signalled[index] = false; + } + else + vkCreateFence(vk->context.device, &fence_info, NULL, next_fence); +} + void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) { unsigned index; VkResult err; VkFence fence; - VkSemaphoreCreateInfo sem_info = - { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; VkFenceCreateInfo fence_info = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; - VkFence *next_fence = NULL; + VkSemaphoreCreateInfo sem_info = + { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; + bool is_retrying = false; + if (vk->swapchain == VK_NULL_HANDLE) + { + /* We don't have a swapchain, try to create one now. */ + if (!vulkan_create_swapchain(vk, vk->context.swapchain_width, + vk->context.swapchain_height, vk->context.swap_interval)) + { + RARCH_ERR("[Vulkan]: Failed to create new swapchain.\n"); + return; + } + + if (vk->swapchain == VK_NULL_HANDLE) + { + /* We still don't have a swapchain, so just fake it ... */ + vk->context.current_swapchain_index = 0; + vulkan_acquire_clear_fences(vk); + vulkan_acquire_wait_fences(vk); + return; + } + } + +retry: vkCreateFence(vk->context.device, &fence_info, NULL, &fence); err = vkAcquireNextImageKHR(vk->context.device, @@ -2276,24 +2339,35 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) vkCreateSemaphore(vk->context.device, &sem_info, NULL, &vk->context.swapchain_semaphores[index]); - vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX); + if (err == VK_SUCCESS) + vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX); vkDestroyFence(vk->context.device, fence, NULL); - next_fence = &vk->context.swapchain_fences[index]; - - if (*next_fence != VK_NULL_HANDLE) - { - vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); - - vkResetFences(vk->context.device, 1, next_fence); - } - else - vkCreateFence(vk->context.device, &fence_info, NULL, next_fence); + vulkan_acquire_wait_fences(vk); if (err != VK_SUCCESS) { - RARCH_LOG("[Vulkan]: AcquireNextImage failed, invalidating swapchain.\n"); - vk->context.invalid_swapchain = true; + if (is_retrying) + { + RARCH_ERR("[Vulkan]: Tried acquring next swapchain image after creating new one, but failed ...\n"); + } + else + { + RARCH_LOG("[Vulkan]: AcquireNextImage failed, invalidating swapchain.\n"); + vk->context.invalid_swapchain = true; + + RARCH_LOG("[Vulkan]: AcquireNextImage failed, so trying to recreate swapchain.\n"); + if (!vulkan_create_swapchain(vk, vk->context.swapchain_width, + vk->context.swapchain_height, vk->context.swap_interval)) + { + RARCH_ERR("[Vulkan]: Failed to create new swapchain.\n"); + } + else + { + is_retrying = true; + goto retry; + } + } } } @@ -2312,7 +2386,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, VkExtent2D swapchain_size; VkSwapchainKHR old_swapchain; VkSurfaceTransformFlagBitsKHR pre_transform; - VkSwapchainCreateInfoKHR info = { + VkSwapchainCreateInfoKHR info = { VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR; settings_t *settings = config_get_ptr(); @@ -2347,7 +2421,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, swapchain_present_mode = VK_PRESENT_MODE_MAILBOX_KHR; break; } - else if (!swap_interval && present_modes[i] + else if (!swap_interval && present_modes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR) { swapchain_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR; @@ -2408,6 +2482,43 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, else swapchain_size = surface_properties.currentExtent; +#if 0 + /* Tests for deferred creation. */ + static unsigned retry_count = 0; + if (++retry_count < 50) + { + surface_properties.maxImageExtent.width = 0; + surface_properties.maxImageExtent.height = 0; + surface_properties.minImageExtent.width = 0; + surface_properties.minImageExtent.height = 0; + } +#endif + + /* Clamp swapchain size to boundaries. */ + if (swapchain_size.width > surface_properties.maxImageExtent.width) + swapchain_size.width = surface_properties.maxImageExtent.width; + if (swapchain_size.width < surface_properties.minImageExtent.width) + swapchain_size.width = surface_properties.minImageExtent.width; + if (swapchain_size.height > surface_properties.maxImageExtent.height) + swapchain_size.height = surface_properties.maxImageExtent.height; + if (swapchain_size.height < surface_properties.minImageExtent.height) + swapchain_size.height = surface_properties.minImageExtent.height; + + if (swapchain_size.width == 0 && swapchain_size.height == 0) + { + /* Cannot create swapchain yet, try again later. */ + if (vk->swapchain != VK_NULL_HANDLE) + vkDestroySwapchainKHR(vk->context.device, vk->swapchain, NULL); + vk->swapchain = VK_NULL_HANDLE; + vk->context.swapchain_width = width; + vk->context.swapchain_height = height; + vk->context.num_swapchain_images = 1; + + memset(vk->context.swapchain_images, 0, sizeof(vk->context.swapchain_images)); + RARCH_LOG("[Vulkan]: Cannot create a swapchain yet. Will try again later ...\n"); + return true; + } + RARCH_LOG("[Vulkan]: Using swapchain size %u x %u.\n", swapchain_size.width, swapchain_size.height); @@ -2420,11 +2531,11 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, if (desired_swapchain_images < surface_properties.minImageCount) desired_swapchain_images = surface_properties.minImageCount; - if ((surface_properties.maxImageCount > 0) + if ((surface_properties.maxImageCount > 0) && (desired_swapchain_images > surface_properties.maxImageCount)) desired_swapchain_images = surface_properties.maxImageCount; - if (surface_properties.supportedTransforms + if (surface_properties.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) pre_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; else @@ -2454,7 +2565,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, info.presentMode = swapchain_present_mode; info.clipped = true; info.oldSwapchain = old_swapchain; - info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT + info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; if (vkCreateSwapchainKHR(vk->context.device, @@ -2509,17 +2620,8 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, RARCH_LOG("[Vulkan]: Got %u swapchain images.\n", vk->context.num_swapchain_images); - for (i = 0; i < vk->context.num_swapchain_images; i++) - { - if (vk->context.swapchain_fences[i]) - { - vkDestroyFence(vk->context.device, - vk->context.swapchain_fences[i], NULL); - vk->context.swapchain_fences[i] = VK_NULL_HANDLE; - } - } - - vulkan_acquire_next_image(vk); + vulkan_acquire_clear_fences(vk); + vk->context.invalid_swapchain = true; return true; } diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 04785517fd..e4714142ef 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -22,7 +22,7 @@ #define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS 16 #define VULKAN_MAX_DESCRIPTOR_POOL_SIZES 16 -#define VULKAN_BUFFER_BLOCK_SIZE (4 * 1024) +#define VULKAN_BUFFER_BLOCK_SIZE (64 * 1024) #define VULKAN_MAX_SWAPCHAIN_IMAGES 8 @@ -109,6 +109,7 @@ typedef struct vulkan_context VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES]; + bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkFormat swapchain_format; diff --git a/gfx/common/wayland_common.h b/gfx/common/wayland_common.h index 4cec21d386..e48f450907 100644 --- a/gfx/common/wayland_common.h +++ b/gfx/common/wayland_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 40a807a2c0..766838e671 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -45,6 +45,7 @@ #include "../../input/input_driver.h" #include "../../input/input_keymaps.h" #include "../video_thread_wrapper.h" +#include "../video_display_server.h" #include #ifdef HAVE_MENU @@ -53,8 +54,8 @@ #include -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 @@ -672,8 +673,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, if (gdi && gdi->memDC) { RECT rect; - HBRUSH brush = CreateSolidBrush(RGB(1,81,127)); - + HBRUSH brush = CreateSolidBrush(RGB(1,81,127)); + GetClientRect(hwnd, &rect); StretchBlt(gdi->winDC, @@ -742,6 +743,7 @@ bool win32_window_create(void *data, unsigned style, RECT *mon_rect, unsigned width, unsigned height, bool fullscreen) { + settings_t *settings = config_get_ptr(); #ifndef _XBOX main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", @@ -756,6 +758,14 @@ bool win32_window_create(void *data, unsigned style, video_driver_display_type_set(RARCH_DISPLAY_WIN32); video_driver_display_set(0); video_driver_window_set((uintptr_t)main_window.hwnd); + +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and above use layered windows to enable transparency */ + SetWindowLongPtr(main_window.hwnd, + GWL_EXSTYLE, + GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + SetLayeredWindowAttributes(main_window.hwnd, 0, (255 * settings->uints.video_window_opacity) / 100, LWA_ALPHA); +#endif #endif return true; } diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c87a991fdb..9df4db8246 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 20eebf8da3..75095a5c2a 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -39,7 +40,9 @@ #include +#ifdef HAVE_DBUS #include "dbus_common.h" +#endif #include "../../frontend/frontend_driver.h" #include "../../input/input_driver.h" @@ -138,7 +141,7 @@ void x11_move_window(Display *dpy, Window win, int x, int y, xev.xclient.message_type = XA_NET_MOVERESIZE_WINDOW; xev.xclient.window = win; xev.xclient.format = 32; - xev.xclient.data.l[0] = (1 << MOVERESIZE_X_SHIFT) + xev.xclient.data.l[0] = (1 << MOVERESIZE_X_SHIFT) | (1 << MOVERESIZE_Y_SHIFT); xev.xclient.data.l[1] = x; xev.xclient.data.l[2] = y; @@ -159,19 +162,27 @@ static void x11_set_window_class(Display *dpy, Window win) static void x11_set_window_pid(Display *dpy, Window win) { + long scret; + char *hostname; pid_t pid = getpid(); - char hostname[HOST_NAME_MAX + 1]; - XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_PID", False), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_PID", False), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); - if(gethostname(hostname, HOST_NAME_MAX + 1) == -1) - RARCH_WARN("Failed to get hostname.\n"); - else - { - XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, - PropModeReplace, (unsigned char *)hostname, strlen(hostname)); - } + errno = 0; + if((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno) + return; + if((hostname = malloc(scret + 1)) == NULL) + return; + + if(gethostname(hostname, scret + 1) == -1) + RARCH_WARN("Failed to get hostname.\n"); + else + { + XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, + PropModeReplace, (unsigned char *)hostname, strlen(hostname)); + } + free(hostname); } void x11_set_window_attr(Display *dpy, Window win) @@ -243,7 +254,7 @@ static bool get_video_mode(video_frame_info_t *video_info, *desktop_mode = *modes[0]; - /* If we use black frame insertion, we fake a 60 Hz monitor + /* If we use black frame insertion, we fake a 60 Hz monitor * for 120 Hz one, etc, so try to match that. */ refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; @@ -382,7 +393,7 @@ static void x11_handle_key_event(XEvent *event, XIC ic, bool filter) bool down = event->type == KeyPress; int num = 0; KeySym keysym = 0; - + chars[0] = '\0'; if (!filter) @@ -398,7 +409,7 @@ static void x11_handle_key_event(XEvent *event, XIC ic, bool filter) /* XwcLookupString doesn't seem to work. */ num = Xutf8LookupString(ic, &event->xkey, keybuf, ARRAY_SIZE(keybuf), &keysym, &status); - /* libc functions need UTF-8 locale to work properly, + /* libc functions need UTF-8 locale to work properly, * which makes mbrtowc a bit impractical. * * Use custom UTF8 -> UTF-32 conversion. */ @@ -455,7 +466,7 @@ bool x11_alive(void *data) switch (event.type) { case ClientMessage: - if (event.xclient.window == g_x11_win && + if (event.xclient.window == g_x11_win && (Atom)event.xclient.data.l[0] == g_x11_quit_atom) frontend_driver_set_signal_handler_state(1); break; @@ -595,7 +606,9 @@ bool x11_connect(void) return false; } +#ifdef HAVE_DBUS dbus_ensure_connection(); +#endif return true; } diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index d70f2d28c6..23fc4898bc 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/xinerama_common.c b/gfx/common/xinerama_common.c index 0ce48c66ed..34879e8275 100644 --- a/gfx/common/xinerama_common.c +++ b/gfx/common/xinerama_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/xinerama_common.h b/gfx/common/xinerama_common.h index e66c17b849..3a7e00e4cf 100644 --- a/gfx/common/xinerama_common.h +++ b/gfx/common/xinerama_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/display_servers/dispserv_null.c b/gfx/display_servers/dispserv_null.c new file mode 100644 index 0000000000..40697ac0b8 --- /dev/null +++ b/gfx/display_servers/dispserv_null.c @@ -0,0 +1,44 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include "../video_display_server.h" + +static void* null_display_server_init(void) +{ + return NULL; +} + +static void null_display_server_destroy(void) +{ + +} + +static bool null_set_window_opacity(void *data, unsigned opacity) +{ + (void)data; + (void)opacity; + return true; +} + +const video_display_server_t dispserv_null = { + null_display_server_init, + null_display_server_destroy, + null_set_window_opacity, + "null" +}; + diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c new file mode 100644 index 0000000000..8165d9e3bf --- /dev/null +++ b/gfx/display_servers/dispserv_win32.c @@ -0,0 +1,60 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include "../video_display_server.h" +#include "../common/win32_common.h" + +typedef struct +{ + unsigned opacity; +} dispserv_win32_t; + +static void* win32_display_server_init(void) +{ + dispserv_win32_t *dispserv = (dispserv_win32_t*)calloc(1, sizeof(*dispserv)); + + return dispserv; +} + +static void win32_display_server_destroy(void) +{ + +} + +static bool win32_set_window_opacity(void *data, unsigned opacity) +{ + HWND hwnd = win32_get_window(); + dispserv_win32_t *serv = (dispserv_win32_t*)data; + + serv->opacity = opacity; + +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Set window transparency on Windows 2000 and above */ + return SetLayeredWindowAttributes(hwnd, 0, (255 * opacity) / 100, LWA_ALPHA); +#else + return false; +#endif +} + +const video_display_server_t dispserv_win32 = { + win32_display_server_init, + win32_display_server_destroy, + win32_set_window_opacity, + "win32" +}; + diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c new file mode 100644 index 0000000000..1d53ca9052 --- /dev/null +++ b/gfx/display_servers/dispserv_x11.c @@ -0,0 +1,64 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "../video_display_server.h" +#include "../common/x11_common.h" +#include "../../configuration.h" + +typedef struct +{ + unsigned opacity; +} dispserv_x11_t; + +static void* x11_display_server_init(void) +{ + dispserv_x11_t *dispserv = (dispserv_x11_t*)calloc(1, sizeof(*dispserv)); + + return dispserv; +} + +static void x11_display_server_destroy(void) +{ + +} + +static bool x11_set_window_opacity(void *data, unsigned opacity) +{ + dispserv_x11_t *serv = (dispserv_x11_t*)data; + Atom net_wm_opacity = XInternAtom(g_x11_dpy, "_NET_WM_WINDOW_OPACITY", False); + Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); + settings_t *settings = config_get_ptr(); + + serv->opacity = opacity; + + opacity = opacity * ((unsigned)-1 / 100.0); + + if (opacity == (unsigned)-1) + XDeleteProperty(g_x11_dpy, g_x11_win, net_wm_opacity); + else + XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, 32, PropModeReplace, (const unsigned char*)&opacity, 1); + + return true; +} + +const video_display_server_t dispserv_x11 = { + x11_display_server_init, + x11_display_server_destroy, + x11_set_window_opacity, + "x11" +}; + diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 0aabb51ccd..720fac0834 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -436,7 +436,7 @@ static void* ctr_init(const video_info_t* video, driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate); aptHook(&ctr->lcd_aptHook, ctr_lcd_aptHook, ctr); - font_driver_init_osd(ctr, false, + font_driver_init_osd(ctr, false, video->is_threaded, FONT_DRIVER_RENDER_CTR); @@ -826,7 +826,7 @@ static bool ctr_frame(void* data, const void* frame, topFramebufferInfo.unk = 0x00000000; u8* framebufferInfoHeader = gfxSharedMemory+0x200+gfxThreadID*0x80; - GSPGPU_FramebufferInfo* + GSPGPU_FramebufferInfo* framebufferInfo = (GSPGPU_FramebufferInfo*)&framebufferInfoHeader[0x4]; framebufferInfoHeader[0x0] ^= 1; framebufferInfo[framebufferInfoHeader[0x0]] = topFramebufferInfo; diff --git a/gfx/drivers/d3d.c b/gfx/drivers/d3d.c index 48aefd123e..4ef1375f90 100644 --- a/gfx/drivers/d3d.c +++ b/gfx/drivers/d3d.c @@ -333,8 +333,8 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info) return; @@ -372,7 +372,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, video_frame_info_t *video_info, vert[i][7] = 1.0f; vert[i][8] = overlay->alpha_mod; } - + d3d_viewport_info(d3d, &vp); overlay_width = vp.width; @@ -514,7 +514,7 @@ void d3d_make_d3dpp(void *data, #ifdef _XBOX d3dpp->Windowed = false; #else - d3dpp->Windowed = settings->bools.video_windowed_fullscreen + d3dpp->Windowed = settings->bools.video_windowed_fullscreen || !info->fullscreen; #endif FS_PRESENTINTERVAL(d3dpp) = D3DPRESENT_INTERVAL_IMMEDIATE; @@ -545,13 +545,13 @@ void d3d_make_d3dpp(void *data, d3dpp->BackBufferFormat = #ifdef _XBOX360 global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : #endif info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; #else d3dpp->hDeviceWindow = win32_get_window(); - d3dpp->BackBufferFormat = !d3dpp->Windowed ? + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; #endif @@ -647,7 +647,7 @@ static bool d3d_init_base(void *data, const video_info_t *info) #endif if (!d3d_create_device(&d3d->dev, &d3dpp, - g_pD3D, + g_pD3D, focus_window, d3d->cur_mon_id) ) @@ -724,8 +724,8 @@ static void d3d_calculate_rect(void *data, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } @@ -823,7 +823,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) strlcpy(settings->paths.path_font, "game:\\media\\Arial_12.xpr", sizeof(settings->paths.path_font)); #endif - font_driver_init_osd(d3d, false, + font_driver_init_osd(d3d, false, info->is_threaded, FONT_DRIVER_RENDER_DIRECT3D_API); @@ -1513,8 +1513,8 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer, bool is_idle) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->read_viewport) return false; @@ -1660,7 +1660,7 @@ static void video_texture_load_d3d(d3d_video_t *d3d, uintptr_t *id) { *id = (uintptr_t)d3d_texture_new(d3d->dev, NULL, - ti->width, ti->height, 1, + ti->width, ti->height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); } diff --git a/gfx/drivers/d3d.h b/gfx/drivers/d3d.h index efd0d7ca76..dc72306b8e 100644 --- a/gfx/drivers/d3d.h +++ b/gfx/drivers/d3d.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 18afe085ae..5eeaf51e7b 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -32,7 +32,7 @@ struct dispmanx_page { - /* Each page contains it's own resource handler + /* Each page contains it's own resource handler * instead of pointing to in by page number */ DISPMANX_RESOURCE_HANDLE_T resource; bool used; @@ -40,11 +40,11 @@ struct dispmanx_page * isolating it's used flag access. */ slock_t *page_used_mutex; - /* This field will allow us to access the + /* This field will allow us to access the * main _dispvars struct from the vsync CB function */ struct dispmanx_video *dispvars; - /* This field will allow us to access the + /* This field will allow us to access the * surface the page belongs to. */ struct dispmanx_surface *surface; }; @@ -60,23 +60,23 @@ struct dispmanx_surface * already when we enter the surface update function. No time to wait * for free pages before blitting and showing the just rendered frame! */ struct dispmanx_page *next_page; - unsigned int bpp; + unsigned int bpp; VC_RECT_T src_rect; VC_RECT_T dst_rect; VC_RECT_T bmp_rect; - /* Each surface has it's own element, and the + /* Each surface has it's own element, and the * resources are contained one in each page */ DISPMANX_ELEMENT_HANDLE_T element; - VC_DISPMANX_ALPHA_T alpha; + VC_DISPMANX_ALPHA_T alpha; VC_IMAGE_TYPE_T pixformat; - /* Surfaces with a higher layer will be on top of + /* Surfaces with a higher layer will be on top of * the ones with lower. Default is 0. */ int layer; - /* We need to keep this value for the blitting on + /* We need to keep this value for the blitting on * the surface_update function. */ int pitch; }; @@ -111,17 +111,17 @@ struct dispmanx_video bool rgb32; - /* We use this to keep track of internal resolution changes + /* We use this to keep track of internal resolution changes * done by cores in the main surface or in the menu. * We need these outside the surface because we free surfaces * and then we want to test if these values have changed before * recreating them. */ - int core_width; - int core_height; + int core_width; + int core_height; int core_pitch; - int menu_width; + int menu_width; int menu_height; - int menu_pitch; + int menu_pitch; /* Both main and menu surfaces are going to have the same aspect, * so we keep it here for future reference. */ float aspect_ratio; @@ -145,7 +145,7 @@ static struct dispmanx_page *dispmanx_get_free_page(struct dispmanx_video *_disp break; } } - + /* If no page is free at the moment, * wait until a free page is freed by vsync CB. */ if (!page) @@ -171,7 +171,7 @@ static void dispmanx_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) struct dispmanx_surface *surface = page->surface; /* Marking the page as free must be done before the signaling - * so when update_main continues (it won't continue until we signal) + * so when update_main continues (it won't continue until we signal) * we can chose this page as free */ if (surface->current_page) { @@ -181,13 +181,13 @@ static void dispmanx_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) surface->current_page->used = false; slock_unlock(surface->current_page->page_used_mutex); } - + /* The page on which we issued the flip that * caused this callback becomes the visible one */ surface->current_page = page; - /* These two things must be isolated "atomically" to avoid getting - * a false positive in the pending_mutex test in update_main. */ + /* These two things must be isolated "atomically" to avoid getting + * a false positive in the pending_mutex test in update_main. */ slock_lock(page->dispvars->pending_mutex); page->dispvars->pageflip_pending--; @@ -202,19 +202,19 @@ static void dispmanx_surface_free(struct dispmanx_video *_dispvars, int i; struct dispmanx_surface *surface = *sp; - /* What if we run into the vsync cb code after freeing the surface? + /* What if we run into the vsync cb code after freeing the surface? * We could be trying to get non-existant lock, signal non-existant condition.. - * So we wait for any pending flips to complete before freeing any surface. */ + * So we wait for any pending flips to complete before freeing any surface. */ slock_lock(_dispvars->pending_mutex); if (_dispvars->pageflip_pending > 0) scond_wait(_dispvars->vsync_condition, _dispvars->pending_mutex); slock_unlock(_dispvars->pending_mutex); for (i = 0; i < surface->numpages; i++) - { + { vc_dispmanx_resource_delete(surface->pages[i].resource); - surface->pages[i].used = false; - slock_free(surface->pages[i].page_used_mutex); + surface->pages[i].used = false; + slock_free(surface->pages[i].page_used_mutex); } free(surface->pages); @@ -238,12 +238,12 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, *sp = calloc(1, sizeof(struct dispmanx_surface)); - surface = *sp; + surface = *sp; /* Setup surface parameters */ surface->numpages = numpages; - /* We receive the pitch for what we consider "useful info", - * excluding things that are between scanlines. + /* We receive the pitch for what we consider "useful info", + * excluding things that are between scanlines. * Then we align it to 16 pixels (not bytes) for performance reasons. */ surface->pitch = ALIGN_UP(visible_pitch, (pixformat == VC_IMAGE_XRGB8888 ? 64 : 32)); @@ -258,10 +258,10 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].used = false; - surface->pages[i].surface = surface; - surface->pages[i].dispvars = _dispvars; - surface->pages[i].page_used_mutex = slock_new(); + surface->pages[i].used = false; + surface->pages[i].surface = surface; + surface->pages[i].dispvars = _dispvars; + surface->pages[i].page_used_mutex = slock_new(); } /* No need to mutex this access to the "used" member because @@ -269,16 +269,16 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, surface->next_page = &(surface->pages[0]); surface->next_page->used = true; - /* The "visible" width obtained from the core pitch. We blit based on + /* The "visible" width obtained from the core pitch. We blit based on * the "visible" width, for cores with things between scanlines. */ visible_width = visible_pitch / (bpp / 8); - + dst_width = _dispvars->dispmanx_height * aspect; dst_height = _dispvars->dispmanx_height; /* If we obtain a scaled image width that is bigger than the physical screen width, * then we keep the physical screen width as our maximun width. */ - if (dst_width > _dispvars->dispmanx_width) + if (dst_width > _dispvars->dispmanx_width) dst_width = _dispvars->dispmanx_width; dst_xpos = (_dispvars->dispmanx_width - dst_width) / 2; @@ -291,15 +291,15 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].resource = vc_dispmanx_resource_create(pixformat, + surface->pages[i].resource = vc_dispmanx_resource_create(pixformat, visible_width, src_height, &(_dispvars->vc_image_ptr)); } /* Add element. */ _dispvars->update = vc_dispmanx_update_start(0); surface->element = vc_dispmanx_element_add( - _dispvars->update,_dispvars->display, layer, - &surface->dst_rect, surface->pages[0].resource, + _dispvars->update,_dispvars->display, layer, + &surface->dst_rect, surface->pages[0].resource, &surface->src_rect, DISPMANX_PROTECTION_NONE, &surface->alpha, 0, (DISPMANX_TRANSFORM_T)0); @@ -309,7 +309,7 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, static void dispmanx_surface_update_async(const void *frame, struct dispmanx_surface *surface) { struct dispmanx_page *page = NULL; - + /* Since it's an async update, there's no need for multiple pages */ page = &(surface->pages[0]); @@ -363,20 +363,20 @@ static void dispmanx_blank_console (struct dispmanx_video *_dispvars) /* Since pitch will be aligned to 16 pixels (not bytes) we use a * 16 pixels image to save the alignment */ uint16_t image[16] = {0x0000}; - float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height; + float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height; dispmanx_surface_setup(_dispvars, - 16, - 1, - 32, - 16, + 16, + 1, + 32, + 16, VC_IMAGE_RGB565, 255, aspect, 1, -1, &_dispvars->back_surface); - + /* Updating 1-page surface synchronously asks for truble, since the 1st CB will * signal but not free because the only page is on screen, so get_free will wait forever. */ dispmanx_surface_update_async(image, _dispvars->back_surface); @@ -393,8 +393,8 @@ static void *dispmanx_gfx_init(const video_info_t *video, bcm_host_init(); _dispvars->display = vc_dispmanx_display_open(0 /* LCD */); - /* If the console framebuffer has active overscan settings, - * the user must have overscan_scale=1 in config.txt to have + /* If the console framebuffer has active overscan settings, + * the user must have overscan_scale=1 in config.txt to have * the same size for both fb console and dispmanx. */ graphics_get_display_size(_dispvars->display, &_dispvars->dispmanx_width, &_dispvars->dispmanx_height); @@ -403,11 +403,11 @@ static void *dispmanx_gfx_init(const video_info_t *video, _dispvars->vc_image_ptr = 0; _dispvars->pageflip_pending = 0; _dispvars->menu_active = false; - _dispvars->rgb32 = video->rgb32; + _dispvars->rgb32 = video->rgb32; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _dispvars->aspect_ratio = video_driver_get_aspect_ratio(); @@ -424,8 +424,8 @@ static void *dispmanx_gfx_init(const video_info_t *video, if (input && input_data) *input = NULL; - - /* Enable/disable dispmanx bilinear filtering. */ + + /* Enable/disable dispmanx bilinear filtering. */ dispmanx_set_scaling(video->smooth); dispmanx_blank_console(_dispvars); @@ -442,8 +442,8 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, if (!frame) return true; - if ( (width != _dispvars->core_width) || - (height != _dispvars->core_height) || + if ( (width != _dispvars->core_width) || + (height != _dispvars->core_height) || (_dispvars->aspect_ratio != aspect)) { /* Sanity check. */ @@ -455,25 +455,25 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->core_pitch = pitch; _dispvars->aspect_ratio = aspect; - if (_dispvars->main_surface != NULL) + if (_dispvars->main_surface != NULL) dispmanx_surface_free(_dispvars, &_dispvars->main_surface); - /* Internal resolution or ratio has changed, so we need + /* Internal resolution or ratio has changed, so we need * to recreate the main surface. */ - dispmanx_surface_setup(_dispvars, - width, - height, - pitch, + dispmanx_surface_setup(_dispvars, + width, + height, + pitch, _dispvars->rgb32 ? 32 : 16, _dispvars->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 255, - _dispvars->aspect_ratio, + _dispvars->aspect_ratio, video_info->max_swapchain_images, 0, &_dispvars->main_surface); - /* We need to recreate the menu surface too, if it exists already, so we - * free it and let dispmanx_set_texture_frame() recreate it as it detects it's NULL.*/ + /* We need to recreate the menu surface too, if it exists already, so we + * free it and let dispmanx_set_texture_frame() recreate it as it detects it's NULL.*/ if (_dispvars->menu_active && _dispvars->menu_surface) dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); } @@ -514,14 +514,14 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32 _dispvars->menu_pitch = width * (rgb32 ? 4 : 2); /* Menu surface only needs a page as it will be updated asynchronously. */ - dispmanx_surface_setup(_dispvars, - width, - height, - _dispvars->menu_pitch, + dispmanx_surface_setup(_dispvars, + width, + height, + _dispvars->menu_pitch, 16, VC_IMAGE_RGBA16, 210, - _dispvars->aspect_ratio, + _dispvars->aspect_ratio, 1, 0, &_dispvars->menu_surface); @@ -583,7 +583,7 @@ static bool dispmanx_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void dispmanx_gfx_set_rotation(void *data, unsigned rotation) @@ -600,15 +600,15 @@ static bool dispmanx_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle return true; } -static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { /* Due to RetroArch setting the data pointer to NULL internally * on core change, data is going to be NULL here after we load - * a new core from the GUI, so we can't count on accessing it - * to store the aspect ratio we are going to use, so we tell RA + * a new core from the GUI, so we can't count on accessing it + * to store the aspect ratio we are going to use, so we tell RA * to keep track of the new aspect ratio and we get it in gfx_frame() - * with video_driver_get_aspect_ratio() to find out if it has changed. */ - + * with video_driver_get_aspect_ratio() to find out if it has changed. */ + switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: @@ -669,7 +669,7 @@ static void dispmanx_gfx_free(void *data) dispmanx_surface_free(_dispvars, &_dispvars->main_surface); dispmanx_surface_free(_dispvars, &_dispvars->back_surface); - if (_dispvars->menu_surface) + if (_dispvars->menu_surface) dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); /* Close display and deinitialize. */ diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 01fb0dec6a..4516bd10e1 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -68,18 +68,18 @@ struct drm_rect struct drm_page { - struct modeset_buf buf; + struct modeset_buf buf; bool used; /* Each page has it's own mutex for * isolating it's used flag access. */ slock_t *page_used_mutex; - /* This field will allow us to access the + /* This field will allow us to access the * main _dispvars struct from the vsync CB function */ - struct drm_video *drmvars; + struct drm_video *drmvars; - /* This field will allow us to access the + /* This field will allow us to access the * surface the page belongs to. */ struct drm_surface *surface; }; @@ -93,18 +93,18 @@ struct drm_surface /* the page that's currently on screen */ struct drm_page *current_page; - unsigned int bpp; + unsigned int bpp; uint32_t pixformat; - + /* The internal buffers size. */ int src_width; int src_height; - /* Surfaces with a higher layer will be on top of + /* Surfaces with a higher layer will be on top of * the ones with lower. Default is 0. */ int layer; - /* We need to keep this value for the blitting on + /* We need to keep this value for the blitting on * the surface_update function. */ int pitch; int total_pitch; @@ -123,7 +123,7 @@ struct drm_struct drmModeCrtcPtr orig_crtc; - uint32_t plane_id; + uint32_t plane_id; uint32_t plane_fb_prop_id; drmModeEncoder *encoder; @@ -136,13 +136,13 @@ struct drm_video struct drm_surface *main_surface; struct drm_surface *menu_surface; - /* Total dispmanx video dimensions. + /* Total dispmanx video dimensions. * Not counting overscan settings. */ unsigned int kms_width; unsigned int kms_height; /* For threading */ - scond_t *vsync_condition; + scond_t *vsync_condition; slock_t *vsync_cond_mutex; slock_t *pending_mutex; @@ -151,13 +151,13 @@ struct drm_video bool rgb32; - /* We use this to keep track of internal resolution changes + /* We use this to keep track of internal resolution changes * done by cores in the main surface or in the menu. * We need these outside the surface because we free surfaces * and then we want to test if these values have changed before * recreating them. */ - int core_width; - int core_height; + int core_width; + int core_height; int core_pitch; /* Both main and menu surfaces are going to have the same aspect, * so we keep it here for future reference. */ @@ -172,15 +172,15 @@ static int modeset_create_dumbfb(int fd, static void deinit_drm(void) { - /* Restore the original videomode/connector/scanoutbuffer(fb) - * combination (the original CRTC, that is). */ + /* Restore the original videomode/connector/scanoutbuffer(fb) + * combination (the original CRTC, that is). */ drmModeSetCrtc(drm.fd, drm.orig_crtc->crtc_id, drm.orig_crtc->buffer_id, drm.orig_crtc->x, drm.orig_crtc->y, - &drm.connector_id, 1, &drm.orig_crtc->mode); + &drm.connector_id, 1, &drm.orig_crtc->mode); #if 0 - /* TODO: Free surfaces here along + /* TODO: Free surfaces here along * with their pages (framebuffers)! */ if (bufs[0].fb_id) @@ -193,12 +193,12 @@ static void deinit_drm(void) static void drm_surface_free(void *data, struct drm_surface **sp) { - int i; + int i; struct drm_video *_drmvars = data; struct drm_surface *surface = *sp; for (i = 0; i < surface->numpages; i++) - surface->pages[i].used = false; + surface->pages[i].used = false; free(surface->pages); @@ -212,9 +212,9 @@ static void drm_surface_set_aspect(struct drm_surface *surface, float aspect) surface->aspect = aspect; } -static void drm_surface_setup(void *data, int src_width, int src_height, +static void drm_surface_setup(void *data, int src_width, int src_height, int pitch, int bpp, uint32_t pixformat, - int alpha, float aspect, int numpages, int layer, + int alpha, float aspect, int numpages, int layer, struct drm_surface **sp) { struct drm_video *_drmvars = data; @@ -223,23 +223,23 @@ static void drm_surface_setup(void *data, int src_width, int src_height, *sp = calloc (1, sizeof(struct drm_surface)); - surface = *sp; + surface = *sp; /* Setup surface parameters */ surface->numpages = numpages; - /* We receive the total pitch, including things that are - * between scanlines and we calculate the visible pitch - * from the visible width. + /* We receive the total pitch, including things that are + * between scanlines and we calculate the visible pitch + * from the visible width. * * These will be used to increase the offsets for blitting. */ surface->total_pitch = pitch; - surface->pitch = src_width * bpp; + surface->pitch = src_width * bpp; surface->bpp = bpp; surface->pixformat = pixformat; surface->src_width = src_width; surface->src_height = src_height; surface->aspect = aspect; - + /* Allocate memory for all the pages in each surface * and initialize variables inside each page's struct. */ surface->pages = (struct drm_page*) @@ -247,10 +247,10 @@ static void drm_surface_setup(void *data, int src_width, int src_height, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].used = false; - surface->pages[i].surface = surface; - surface->pages[i].drmvars = _drmvars; - surface->pages[i].page_used_mutex = slock_new(); + surface->pages[i].used = false; + surface->pages[i].surface = surface; + surface->pages[i].drmvars = _drmvars; + surface->pages[i].page_used_mutex = slock_new(); } /* Create the framebuffer for each one of the pages of the surface. */ @@ -259,7 +259,7 @@ static void drm_surface_setup(void *data, int src_width, int src_height, surface->pages[i].buf.width = src_width; surface->pages[i].buf.height = src_height; int ret = modeset_create_dumbfb( - drm.fd, &surface->pages[i].buf, bpp, pixformat); + drm.fd, &surface->pages[i].buf, bpp, pixformat); if (ret) { @@ -272,20 +272,20 @@ static void drm_surface_setup(void *data, int src_width, int src_height, static void drm_page_flip(struct drm_surface *surface) { - /* We alredy have the id of the FB_ID property of + /* We alredy have the id of the FB_ID property of * the plane on which we are going to do a pageflip: * we got it back in drm_plane_setup() */ int ret; static drmModeAtomicReqPtr req = NULL; - req = drmModeAtomicAlloc(); + req = drmModeAtomicAlloc(); - /* We add the buffer to the plane properties we want to - * set on an atomically, in a single step. + /* We add the buffer to the plane properties we want to + * set on an atomically, in a single step. * We pass the plane id, the property id and the new fb id. */ - ret = drmModeAtomicAddProperty(req, - drm.plane_id, - drm.plane_fb_prop_id, + ret = drmModeAtomicAddProperty(req, + drm.plane_id, + drm.plane_fb_prop_id, surface->pages[surface->flip_page].buf.fb_id); if (ret < 0) @@ -294,9 +294,9 @@ static void drm_page_flip(struct drm_surface *surface) } /*... now we just need to do the commit */ - /* REMEMBER!!! The DRM_MODE_PAGE_FLIP_EVENT flag asks the kernel - * to send you an event to the drm.fd once the - * pageflip is complete. If you don't want -12 errors + /* REMEMBER!!! The DRM_MODE_PAGE_FLIP_EVENT flag asks the kernel + * to send you an event to the drm.fd once the + * pageflip is complete. If you don't want -12 errors * (ENOMEM), namely "Cannot allocate memory", then * you must drain the event queue of that fd. */ ret = drmModeAtomicCommit(drm.fd, req, 0, NULL); @@ -324,7 +324,7 @@ static void drm_surface_update(void *data, const void *frame, for (line = 0; line < surface->src_height; line++) { memcpy ( - surface->pages[surface->flip_page].buf.map + dst_offset, + surface->pages[surface->flip_page].buf.map + dst_offset, (uint8_t*)frame + src_offset, surface->pitch); src_offset += surface->total_pitch; @@ -342,7 +342,7 @@ static uint32_t get_plane_prop_id(uint32_t obj_id, const char *name) int i,j; drmModePlaneRes *plane_resources; drmModePlane *plane; - drmModeObjectProperties *props; + drmModeObjectProperties *props; drmModePropertyRes **props_info; char format_str[5]; @@ -354,16 +354,16 @@ static uint32_t get_plane_prop_id(uint32_t obj_id, const char *name) if (plane->plane_id != obj_id) continue; - /* TODO: Improvement. We get all the properties of the + /* TODO: Improvement. We get all the properties of the * plane and info about the properties. - * We should have done this already... + * We should have done this already... * This implementation must be improved. */ props = drmModeObjectGetProperties(drm.fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); props_info = malloc(props->count_props * sizeof *props_info); for (j = 0; j < props->count_props; ++j) - props_info[j] = drmModeGetProperty(drm.fd, props->props[j]); + props_info[j] = drmModeGetProperty(drm.fd, props->props[j]); /* We look for the prop_id we need */ for (j = 0; j < props->count_props; j++) @@ -409,7 +409,7 @@ static uint64_t drm_plane_type(drmModePlane *plane) * access them simultaneously here. * We are interested in OVERLAY planes only, that's type 0 or DRM_PLANE_TYPE_OVERLAY * (see /usr/xf86drmMode.h for definition). */ - drmModeObjectPropertiesPtr props = + drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(drm.fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); for (j = 0; j < props->count_props; j++) @@ -421,14 +421,14 @@ static uint64_t drm_plane_type(drmModePlane *plane) return (0); } -/* This configures our only overlay plane to render the given surface. */ +/* This configures our only overlay plane to render the given surface. */ static void drm_plane_setup(struct drm_surface *surface) { int i,j; char fmt_name[5]; /* Get plane resources */ - drmModePlane *plane; + drmModePlane *plane; drmModePlaneRes *plane_resources; plane_resources = drmModeGetPlaneResources(drm.fd); if (!plane_resources) @@ -437,14 +437,14 @@ static void drm_plane_setup(struct drm_surface *surface) } RARCH_LOG ("DRM: Number of planes on FD %d is %d\n", - drm.fd, plane_resources->count_planes); + drm.fd, plane_resources->count_planes); - /* dump_planes(drm.fd); */ + /* dump_planes(drm.fd); */ - /* Look for a plane/overlay we can use with the configured CRTC + /* Look for a plane/overlay we can use with the configured CRTC * Find a plane which can be connected to our CRTC. Find the * CRTC index first, then iterate over available planes. - * Yes, strangely we need the in-use CRTC index to mask possible_crtc + * Yes, strangely we need the in-use CRTC index to mask possible_crtc * during the planes iteration... */ unsigned int crtc_index = 0; for (i = 0; i < (unsigned int)drm.resources->count_crtcs; i++) @@ -457,8 +457,8 @@ static void drm_plane_setup(struct drm_surface *surface) } } - /* Programmer!! Save your sanity!! Primary planes have to - * cover the entire CRTC, and if you don't do that, you + /* Programmer!! Save your sanity!! Primary planes have to + * cover the entire CRTC, and if you don't do that, you * will get dmesg error "Plane must cover entire CRTC". * * Look at linux/source/drivers/gpu/drm/drm_plane_helper.c comments for more info. @@ -473,20 +473,20 @@ static void drm_plane_setup(struct drm_surface *surface) continue; } - /* We are only interested in overlay planes. No overlay, no fun. + /* We are only interested in overlay planes. No overlay, no fun. * (no scaling, must cover crtc..etc) so we skip primary planes */ if (drm_plane_type(plane) != DRM_PLANE_TYPE_OVERLAY) { RARCH_LOG ("DRM: plane with ID %d is not an overlay. May be primary or cursor. Not usable.\n", plane->plane_id); continue; - } + } if (!format_support(plane, surface->pixformat)) { RARCH_LOG ("DRM: plane with ID %d does not support framebuffer format\n", plane->plane_id); continue; - } + } drm.plane_id = plane->plane_id; drmModeFreePlane(plane); @@ -504,7 +504,7 @@ static void drm_plane_setup(struct drm_surface *surface) } /* We are going to be changing the framebuffer ID property of the chosen overlay every time - * we do a pageflip, so we get the property ID here to have it handy on the PageFlip function. */ + * we do a pageflip, so we get the property ID here to have it handy on the PageFlip function. */ drm.plane_fb_prop_id = get_plane_prop_id(drm.plane_id, "FB_ID"); if (!drm.plane_fb_prop_id) { @@ -531,14 +531,14 @@ static void drm_plane_setup(struct drm_surface *surface) uint32_t src_x = 0; uint32_t src_y = 0; - /* We have to set a buffer for the plane, whatever buffer we want, + /* We have to set a buffer for the plane, whatever buffer we want, * but we must set a buffer so the plane starts reading from it now. */ - if (drmModeSetPlane(drm.fd, drm.plane_id, drm.crtc_id, + if (drmModeSetPlane(drm.fd, drm.plane_id, drm.crtc_id, surface->pages[surface->flip_page].buf.fb_id, plane_flags, plane_x, plane_y, plane_w, plane_h, src_x<<16, src_y<<16, src_w<<16, src_h<<16)) { - RARCH_ERR("[DRM]: failed to enable plane: %s\n", strerror(errno)); + RARCH_ERR("[DRM]: failed to enable plane: %s\n", strerror(errno)); } RARCH_LOG("[DRM]: src_w %d, src_h %d, plane_w %d, plane_h %d\n", @@ -615,7 +615,7 @@ static bool init_drm(void) * VERY important or we won't get all the available planes on drmGetPlaneResources()! * We also need to enable the ATOMIC cap to see the atomic properties in objects!! */ ret = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - if (ret) + if (ret) RARCH_ERR ("DRM: can't set UNIVERSAL PLANES cap.\n"); else RARCH_LOG ("DRM: UNIVERSAL PLANES cap set\n"); @@ -623,8 +623,8 @@ static bool init_drm(void) ret = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_ATOMIC, 1); if (ret) - { - /*If this happens, check kernel support and kernel parameters + { + /*If this happens, check kernel support and kernel parameters * (add i915.nuclear_pageflip=y to the kernel boot line for example) */ RARCH_ERR ("DRM: can't set ATOMIC caps: %s\n", strerror(errno)); } @@ -674,7 +674,7 @@ static bool init_drm(void) drm.crtc_id = drm.encoder->crtc_id; drm.connector_id = connector->connector_id; - /* Backup original crtc and it's mode, so we can restore the original video mode + /* Backup original crtc and it's mode, so we can restore the original video mode * on exit in case we change it. */ drm.orig_crtc = drmModeGetCrtc(drm.fd, drm.encoder->crtc_id); drm.current_mode = &(drm.orig_crtc->mode); @@ -683,7 +683,7 @@ static bool init_drm(void) struct modeset_buf buf; buf.width = drm.current_mode->hdisplay; buf.height = drm.current_mode->vdisplay; - ret = modeset_create_dumbfb(drm.fd, &buf, 4, DRM_FORMAT_XRGB8888); + ret = modeset_create_dumbfb(drm.fd, &buf, 4, DRM_FORMAT_XRGB8888); if (ret) { RARCH_ERR ("DRM: can't create dumb fb\n"); @@ -692,7 +692,7 @@ static bool init_drm(void) if (drmModeSetCrtc(drm.fd, drm.crtc_id, buf.fb_id, 0, 0, &drm.connector_id, 1, drm.current_mode)) { - RARCH_ERR ("DRM: failed to set mode\n"); + RARCH_ERR ("DRM: failed to set mode\n"); return false; } @@ -710,11 +710,11 @@ static void *drm_gfx_init(const video_info_t *video, /* Setup surface parameters */ _drmvars->menu_active = false; - _drmvars->rgb32 = video->rgb32; + _drmvars->rgb32 = video->rgb32; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _drmvars->current_aspect = video_driver_get_aspect_ratio(); @@ -743,9 +743,9 @@ static void *drm_gfx_init(const video_info_t *video, RARCH_LOG ("DRM: Init successful.\n"); } - _drmvars->kms_width = drm.current_mode->hdisplay; - _drmvars->kms_height = drm.current_mode->vdisplay; - + _drmvars->kms_width = drm.current_mode->hdisplay; + _drmvars->kms_height = drm.current_mode->vdisplay; + return _drmvars; } @@ -755,7 +755,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, { struct drm_video *_drmvars = data; - if ( ( width != _drmvars->core_width) || + if ( ( width != _drmvars->core_width) || (height != _drmvars->core_height)) { /* Sanity check. */ @@ -766,22 +766,22 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, _drmvars->core_height = height; _drmvars->core_pitch = pitch; - if (_drmvars->main_surface != NULL) + if (_drmvars->main_surface != NULL) drm_surface_free(_drmvars, &_drmvars->main_surface); /* We need to recreate the main surface and it's pages (buffers). */ - drm_surface_setup(_drmvars, - width, - height, - pitch, + drm_surface_setup(_drmvars, + width, + height, + pitch, _drmvars->rgb32 ? 4 : 2, _drmvars->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565, 255, - _drmvars->current_aspect, + _drmvars->current_aspect, 3, 0, &_drmvars->main_surface); - + /* We need to change the plane to read from the main surface */ drm_plane_setup(_drmvars->main_surface); } @@ -820,34 +820,34 @@ static void drm_set_texture_frame(void *data, const void *frame, bool rgb32, if (!_drmvars->menu_active) return; - /* If menu is active in this frame but the + /* If menu is active in this frame but the * menu surface is NULL, we allocate a new one.*/ if (!_drmvars->menu_surface) { - drm_surface_setup(_drmvars, - width, - height, - width * 4, + drm_surface_setup(_drmvars, + width, + height, + width * 4, 4, DRM_FORMAT_XRGB8888, 210, - _drmvars->current_aspect, + _drmvars->current_aspect, 2, 0, &_drmvars->menu_surface); - /* We need to re-setup the ONLY plane as the setup + /* We need to re-setup the ONLY plane as the setup * depends on input buffers dimensions. */ drm_plane_setup(_drmvars->menu_surface); } - /* We have to go on a pixel format conversion adventure - * for now, until we can convince RGUI to output + /* We have to go on a pixel format conversion adventure + * for now, until we can convince RGUI to output * in an 8888 format. */ - unsigned int src_pitch = width * 2; + unsigned int src_pitch = width * 2; unsigned int dst_pitch = width * 4; unsigned int dst_width = width; - uint32_t line[dst_width]; + uint32_t line[dst_width]; /* The output pixel array with the converted pixels. */ char *frame_output = (char *) malloc (dst_pitch * height); @@ -859,12 +859,12 @@ static void drm_set_texture_frame(void *data, const void *frame, bool rgb32, { for (j = 0; j < src_pitch / 2; j++) { - uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); + uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); /* The hex AND is for keeping only the part we need for each component. */ uint32_t R = (src_pix << 8) & 0x00FF0000; uint32_t G = (src_pix << 4) & 0x0000FF00; uint32_t B = (src_pix << 0) & 0x000000FF; - line[j] = (0 | R | G | B); + line[j] = (0 | R | G | B); } memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); } @@ -923,7 +923,7 @@ static bool drm_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void drm_gfx_set_rotation(void *data, unsigned rotation) @@ -940,20 +940,20 @@ static bool drm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) return true; } -static void drm_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void drm_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { struct drm_video *_drmvars = data; /* Here we obtain the new aspect ratio. */ float new_aspect = aspectratio_lut[aspect_ratio_idx].value; if (_drmvars->current_aspect != new_aspect) - { + { _drmvars->current_aspect = new_aspect; drm_surface_set_aspect(_drmvars->main_surface, new_aspect); if (_drmvars->menu_active) { drm_surface_set_aspect(_drmvars->menu_surface, new_aspect); - drm_plane_setup(_drmvars->menu_surface); + drm_plane_setup(_drmvars->menu_surface); } } } @@ -996,13 +996,13 @@ static void drm_gfx_free(void *data) drm_surface_free(_drmvars, &_drmvars->main_surface); - if (_drmvars->menu_surface) + if (_drmvars->menu_surface) drm_surface_free(_drmvars, &_drmvars->menu_surface); /* Destroy mutexes and conditions. */ slock_free(_drmvars->pending_mutex); slock_free(_drmvars->vsync_cond_mutex); - scond_free(_drmvars->vsync_condition); + scond_free(_drmvars->vsync_condition); free(_drmvars); } diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 4b0476f4b5..6d0efe41e7 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -195,10 +195,10 @@ static int exynos_get_device_index(void) return index; } -/* The main pageflip handler, which the DRM executes +/* The main pageflip handler, which the DRM executes * when it flips to the page. * - * Decreases the pending pageflip count and + * Decreases the pending pageflip count and * updates the current page. */ static void exynos_page_flip_handler(int fd, unsigned frame, unsigned sec, @@ -222,7 +222,7 @@ static struct exynos_page *exynos_get_free_page( { unsigned i; - for (i = 0; i < cnt; ++i) + for (i = 0; i < cnt; ++i) { if (!p[i].used) return &p[i]; @@ -1513,7 +1513,7 @@ static bool exynos_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static bool exynos_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 59e18af6b8..c28aa01784 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -190,7 +190,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, bool draw = true; gdi_t *gdi = (gdi_t*)data; HWND hwnd = win32_get_window(); - BITMAPINFO *info; + BITMAPINFO *info; if (!frame || !frame_width || !frame_height) return true; @@ -356,7 +356,8 @@ static bool gdi_gfx_alive(void *data) unsigned temp_height = 0; bool quit = false; bool resize = false; - + bool ret = false; + /* Needed because some context drivers don't track their sizes */ video_driver_get_size(&temp_width, &temp_height); @@ -365,12 +366,13 @@ static bool gdi_gfx_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - video_context_driver_check_window(&size_data); + if (video_context_driver_check_window(&size_data)) + ret = !quit; if (temp_width != 0 && temp_height != 0) video_driver_set_size(&temp_width, &temp_height); - return true; + return ret; } static bool gdi_gfx_focus(void *data) @@ -491,7 +493,7 @@ static void gdi_set_texture_frame(void *data, } } -static void gdi_set_osd_msg(void *data, +static void gdi_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, const void *params, void *font) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 8c2d230194..27c79b9a1e 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -40,6 +40,7 @@ #include #include +#include #include "../../configuration.h" #include "../../dynamic.h" @@ -543,11 +544,9 @@ static void gl_init_textures_data(gl_t *gl) static void gl_init_textures(gl_t *gl, const video_info_t *video) { unsigned i; - GLenum internal_fmt, texture_type = 0, texture_fmt = 0; - - /* Use regular textures if we use HW render. */ - gl->egl_images = !gl->hw_render_use && gl_check_capability(GL_CAPS_EGLIMAGE) && - video_context_driver_init_image_buffer(video); + GLenum internal_fmt = gl->internal_fmt; + GLenum texture_type = gl->texture_type; + GLenum texture_fmt = gl->texture_fmt; #ifdef HAVE_PSGL if (!gl->pbo) @@ -559,10 +558,6 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) NULL, GL_STREAM_DRAW); #endif - internal_fmt = gl->internal_fmt; - texture_type = gl->texture_type; - texture_fmt = gl->texture_fmt; - #if defined(HAVE_OPENGLES) && !defined(HAVE_PSGL) /* GLES is picky about which format we use here. * Without extensions, we can *only* render to 16-bit FBOs. */ @@ -594,7 +589,7 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) if (gl->renderchain_driver->init_texture_reference) gl->renderchain_driver->init_texture_reference( - gl, i, internal_fmt, + gl, gl->renderchain_data, i, internal_fmt, texture_fmt, texture_type); } @@ -745,19 +740,19 @@ static void gl_render_osd_background( video_coords_t coords; struct uniform_info uniform_param; float colors[4]; - const unsigned + const unsigned vertices_total = 6; float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); float *verts = (float*)malloc(2 * vertices_total * sizeof(float)); settings_t *settings = config_get_ptr(); - int msg_width = + int msg_width = font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f); /* shader driver expects vertex coords as 0..1 */ float x = video_info->font_msg_pos_x; float y = video_info->font_msg_pos_y; float width = msg_width / (float)video_info->width; - float height = + float height = settings->floats.video_font_size / (float)video_info->height; float x2 = 0.005f; /* extend background around text */ @@ -801,7 +796,7 @@ static void gl_render_osd_background( coords_data.handle_data = NULL; coords_data.data = &coords; - + video_driver_set_viewport(video_info->width, video_info->height, true, false); @@ -893,11 +888,11 @@ static void gl_pbo_async_readback(gl_t *gl) gl->pbo_readback_valid[gl->pbo_readback_index] = true; if (gl->renderchain_driver->readback) - gl->renderchain_driver->readback(gl, + gl->renderchain_driver->readback(gl, gl->renderchain_data, video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)), fmt, type, NULL); if (gl->renderchain_driver->unbind_pbo) - gl->renderchain_driver->unbind_pbo(); + gl->renderchain_driver->unbind_pbo(gl, gl->renderchain_data); } static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info) @@ -982,7 +977,7 @@ static bool gl_frame(void *data, const void *frame, context_bind_hw_render(false); if (gl->core_context_in_use && gl->renderchain_driver->bind_vao) - gl->renderchain_driver->bind_vao(gl); + gl->renderchain_driver->bind_vao(gl, gl->renderchain_data); video_info->cb_shader_use(gl, video_info->shader_data, 1, true); @@ -996,11 +991,12 @@ static bool gl_frame(void *data, const void *frame, { if (gl->renderchain_driver->recompute_pass_sizes) gl->renderchain_driver->recompute_pass_sizes( - gl, frame_width, frame_height, + gl, gl->renderchain_data, frame_width, frame_height, gl->vp_out_width, gl->vp_out_height); if (gl->renderchain_driver->start_render) - gl->renderchain_driver->start_render(gl, video_info); + gl->renderchain_driver->start_render(gl, gl->renderchain_data, + video_info); } if (gl->should_resize) @@ -1018,12 +1014,14 @@ static bool gl_frame(void *data, const void *frame, if (gl->fbo_inited) { if (gl->renderchain_driver->check_fbo_dimensions) - gl->renderchain_driver->check_fbo_dimensions(gl); + gl->renderchain_driver->check_fbo_dimensions(gl, + gl->renderchain_data); /* Go back to what we're supposed to do, * render to FBO #0. */ if (gl->renderchain_driver->start_render) - gl->renderchain_driver->start_render(gl, video_info); + gl->renderchain_driver->start_render(gl, gl->renderchain_data, + video_info); } else gl_set_viewport(gl, video_info, width, height, false, true); @@ -1035,14 +1033,14 @@ static bool gl_frame(void *data, const void *frame, glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); /* Can be NULL for frame dupe / NULL render. */ - if (frame) + if (frame) { if (!gl->hw_render_fbo_init) { gl_update_input_size(gl, frame_width, frame_height, pitch, true); if (gl->renderchain_driver->copy_frame) - gl->renderchain_driver->copy_frame(gl, + gl->renderchain_driver->copy_frame(gl, gl->renderchain_data, video_info, frame, frame_width, frame_height, pitch); } @@ -1060,12 +1058,12 @@ static bool gl_frame(void *data, const void *frame, if (!gl->fbo_inited) { if (gl->renderchain_driver->bind_backbuffer) - gl->renderchain_driver->bind_backbuffer(); + gl->renderchain_driver->bind_backbuffer(gl, gl->renderchain_data); gl_set_viewport(gl, video_info, width, height, false, true); } if (gl->renderchain_driver->restore_default_state) - gl->renderchain_driver->restore_default_state(gl); + gl->renderchain_driver->restore_default_state(gl, gl->renderchain_data); glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); @@ -1084,7 +1082,7 @@ static bool gl_frame(void *data, const void *frame, if (gl->fbo_feedback_enable) { - const struct video_fbo_rect + const struct video_fbo_rect *rect = &gl->fbo_rect[gl->fbo_feedback_pass]; GLfloat xamt = (GLfloat)rect->img_width / rect->width; GLfloat yamt = (GLfloat)rect->img_height / rect->height; @@ -1127,12 +1125,14 @@ static bool gl_frame(void *data, const void *frame, glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (gl->fbo_inited && gl->renderchain_driver->renderchain_render) - gl->renderchain_driver->renderchain_render(gl, video_info, + gl->renderchain_driver->renderchain_render(gl, gl->renderchain_data, + video_info, frame_count, &gl->tex_info, &feedback_info); /* Set prev textures. */ if (gl->renderchain_driver->bind_prev_texture) - gl->renderchain_driver->bind_prev_texture(gl, &gl->tex_info); + gl->renderchain_driver->bind_prev_texture(gl, gl->renderchain_data, + &gl->tex_info); #if defined(HAVE_MENU) if (gl->menu_texture_enable) @@ -1167,7 +1167,8 @@ static bool gl_frame(void *data, const void *frame, glBindTexture(GL_TEXTURE_2D, 0); if (gl->renderchain_driver->disable_client_arrays) - gl->renderchain_driver->disable_client_arrays(); + gl->renderchain_driver->disable_client_arrays(gl, + gl->renderchain_data); } /* Screenshots. */ @@ -1175,6 +1176,7 @@ static bool gl_frame(void *data, const void *frame, { if (gl->renderchain_driver->readback) gl->renderchain_driver->readback(gl, + gl->renderchain_data, 4, GL_RGBA, GL_UNSIGNED_BYTE, gl->readback_buffer_screenshot); } @@ -1207,12 +1209,14 @@ static bool gl_frame(void *data, const void *frame, if (gl->renderchain_driver->fence_iterate) gl->renderchain_driver->fence_iterate(gl, + gl->renderchain_data, video_info->hard_sync_frames); } if (gl->core_context_in_use && gl->renderchain_driver->unbind_vao) - gl->renderchain_driver->unbind_vao(gl); + gl->renderchain_driver->unbind_vao(gl, + gl->renderchain_data); context_bind_hw_render(true); @@ -1242,7 +1246,7 @@ static void gl_deinit_chain(gl_t *gl) return; if (gl->renderchain_driver->chain_free) - gl->renderchain_driver->chain_free(gl->renderchain_data); + gl->renderchain_driver->chain_free(gl, gl->renderchain_data); gl->renderchain_driver = NULL; gl->renderchain_data = NULL; @@ -1259,14 +1263,14 @@ static void gl_free(void *data) if (gl->have_sync) { if (gl->renderchain_driver->fence_free) - gl->renderchain_driver->fence_free(gl); + gl->renderchain_driver->fence_free(gl, gl->renderchain_data); } font_driver_free_osd(); video_shader_driver_deinit(); if (gl->renderchain_driver->disable_client_arrays) - gl->renderchain_driver->disable_client_arrays(); + gl->renderchain_driver->disable_client_arrays(gl, gl->renderchain_data); glDeleteTextures(gl->textures, gl->texture); @@ -1295,13 +1299,13 @@ static void gl_free(void *data) if (gl->core_context_in_use) { if (gl->renderchain_driver->unbind_vao) - gl->renderchain_driver->unbind_vao(gl); + gl->renderchain_driver->unbind_vao(gl, gl->renderchain_data); if (gl->renderchain_driver->free_vao) - gl->renderchain_driver->free_vao(gl); + gl->renderchain_driver->free_vao(gl, gl->renderchain_data); } if (gl->renderchain_driver->free) - gl->renderchain_driver->free(gl); + gl->renderchain_driver->free(gl, gl->renderchain_data); gl_deinit_chain(gl); video_context_driver_free(); @@ -1329,7 +1333,7 @@ static void gl_set_nonblock_state(void *data, bool state) context_bind_hw_render(true); } -static bool resolve_extensions(gl_t *gl, const char *context_ident) +static bool resolve_extensions(gl_t *gl, const char *context_ident, const video_info_t *video) { settings_t *settings = config_get_ptr(); @@ -1342,25 +1346,21 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) * * have_sync - Use ARB_sync to reduce latency. */ - gl->has_srgb_fbo = false; gl->has_fbo = gl_check_capability(GL_CAPS_FBO); gl->have_full_npot_support = gl_check_capability(GL_CAPS_FULL_NPOT_SUPPORT); gl->have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); gl->have_es2_compat = gl_check_capability(GL_CAPS_ES2_COMPAT); - gl->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO); gl->support_unpack_row_length = gl_check_capability(GL_CAPS_UNPACK_ROW_LENGTH); gl->have_sync = gl_check_capability(GL_CAPS_SYNC); - /* GLES3 has unpack_subimage and sRGB in core. */ - gl->has_srgb_fbo_gles3 = gl_check_capability(GL_CAPS_SRGB_FBO_ES3); - - if (!settings->bools.video_force_srgb_disable) - gl->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); if (gl->have_sync && settings->bools.video_hard_sync) RARCH_LOG("[GL]: Using ARB_sync to reduce latency.\n"); video_driver_unset_rgba(); + if (gl->renderchain_driver->resolve_extensions) + gl->renderchain_driver->resolve_extensions(gl, gl->renderchain_data, context_ident, video); + #if defined(HAVE_OPENGLES) && !defined(HAVE_PSGL) if (!gl_check_capability(GL_CAPS_BGRA8888)) { @@ -1463,7 +1463,7 @@ static bool gl_init_pbo_readback(gl_t *gl) gl->vp.height * sizeof(uint32_t), NULL); } if (gl->renderchain_driver->unbind_pbo) - gl->renderchain_driver->unbind_pbo(); + gl->renderchain_driver->unbind_pbo(gl, gl->renderchain_data); #ifndef HAVE_OPENGLES3 { @@ -1775,16 +1775,16 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo } if (gl->renderchain_driver->restore_default_state) - gl->renderchain_driver->restore_default_state(gl); + gl->renderchain_driver->restore_default_state(gl, gl->renderchain_data); if (hwr->context_type == RETRO_HW_CONTEXT_OPENGL_CORE) if (gl->renderchain_driver->new_vao) - gl->renderchain_driver->new_vao(gl); + gl->renderchain_driver->new_vao(gl, gl->renderchain_data); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); - if (!resolve_extensions(gl, ctx_driver->ident)) + if (!resolve_extensions(gl, ctx_driver->ident, video)) goto error; #ifdef GL_DEBUG @@ -1927,13 +1927,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl_init_textures_data(gl); if (gl->renderchain_driver->init) - gl->renderchain_driver->init(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init(gl, gl->renderchain_data, gl->tex_w, gl->tex_h); if (gl->has_fbo) { if (gl->hw_render_use && gl->renderchain_driver->init_hw_render && - !gl->renderchain_driver->init_hw_render(gl, gl->tex_w, gl->tex_h)) + !gl->renderchain_driver->init_hw_render(gl, gl->renderchain_data, gl->tex_w, gl->tex_h)) { RARCH_ERR("[GL]: Hardware rendering context initialization failed.\n"); goto error; @@ -1946,7 +1946,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo video_context_driver_input_driver(&inp); if (video->font_enable) - font_driver_init_osd(gl, false, + font_driver_init_osd(gl, false, video->is_threaded, FONT_DRIVER_RENDER_OPENGL_API); @@ -2111,7 +2111,7 @@ static bool gl_set_shader(void *data, if (gl->fbo_inited) { if (gl->renderchain_driver->deinit_fbo) - gl->renderchain_driver->deinit_fbo(gl); + gl->renderchain_driver->deinit_fbo(gl, gl->renderchain_data); glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); } @@ -2143,7 +2143,7 @@ static bool gl_set_shader(void *data, { if (gl->hw_render_use && gl->fbo_inited && gl->renderchain_driver->deinit_hw_render) - gl->renderchain_driver->deinit_hw_render(gl); + gl->renderchain_driver->deinit_hw_render(gl, gl->renderchain_data); glDeleteTextures(gl->textures, gl->texture); #if defined(HAVE_PSGL) @@ -2157,11 +2157,13 @@ static bool gl_set_shader(void *data, gl_init_textures_data(gl); if (gl->hw_render_use && gl->renderchain_driver->init_hw_render) - gl->renderchain_driver->init_hw_render(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init_hw_render(gl, gl->renderchain_data, + gl->tex_w, gl->tex_h); } if (gl->renderchain_driver->init) - gl->renderchain_driver->init(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init(gl, gl->renderchain_data, + gl->tex_w, gl->tex_h); /* Apparently need to set viewport for passes when we aren't using FBOs. */ gl_set_shader_viewports(gl); @@ -2185,7 +2187,7 @@ static void gl_viewport_info(void *data, struct video_viewport *vp) gl_t *gl = (gl_t*)data; if (!gl->renderchain_driver || !gl->renderchain_driver->viewport_info) return; - gl->renderchain_driver->viewport_info(data, vp); + gl->renderchain_driver->viewport_info(gl, gl->renderchain_data, vp); } static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle) @@ -2193,7 +2195,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle) gl_t *gl = (gl_t*)data; if (!gl->renderchain_driver || !gl->renderchain_driver->read_viewport) return false; - return gl->renderchain_driver->read_viewport(data, buffer, is_idle); + return gl->renderchain_driver->read_viewport(gl, gl->renderchain_data, + buffer, is_idle); } #if 0 @@ -2524,7 +2527,7 @@ static void gl_set_coords(void *handle_data, void *shader_data, { gl_t *gl = (gl_t*)handle_data; if (gl && gl->renderchain_driver->set_coords) - gl->renderchain_driver->set_coords(handle_data, + gl->renderchain_driver->set_coords(gl, gl->renderchain_data, shader_data, coords); } @@ -2533,7 +2536,7 @@ static void gl_set_mvp(void *data, void *shader_data, { gl_t *gl = (gl_t*)data; if (gl && gl->renderchain_driver->set_mvp) - gl->renderchain_driver->set_mvp(data, + gl->renderchain_driver->set_mvp(gl, gl->renderchain_data, shader_data, mat_data); } diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h new file mode 100644 index 0000000000..c6ad48e071 --- /dev/null +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -0,0 +1,76 @@ +/* credits to: TheTimJames + https://www.shadertoy.com/view/Md2GRw +*/ + +#include "shaders_common.h" + +static const char* stock_fragment_xmb_snowflake = GLSL( + uniform float time; + uniform vec2 OutputSize; + vec2 uv; + + float atime; + + float rand(vec2 co) + { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); + } + + float rand_float(float x) + { + return rand(vec2(x, 1.0)); + } + + float snow(vec3 pos, vec2 uv, float o) + { + vec2 d = (pos.xy - uv); + float a = atan(d.y,d.x) + sin(atime*1.0 + o) * 10.0; + + float dist = d.x*d.x + d.y*d.y; + + if(dist < pos.z/400.0) + { + float col = 0.0; + if(sin(a * 8.0) < 0.0) + { + col=1.0; + } + if(dist < pos.z/800.0) + { + col+=1.0; + } + return col * pos.z; + } + + return 0.0; + } + + float col(vec2 c) + { + float color = 0.0; + for (int i = 1; i < 15; i++) + { + float o = rand_float(float(i) / 3.0) * 15.0; + float z = rand_float(float(i) + 13.0); + float x = 1.8 - (3.6) * (rand_float(floor((time*((z + 1.0) / 2.0) +o) / 2.0)) + sin(time * o /1000.0) / 10.0); + float y = 1.0 - mod((time * ((z + 1.0)/2.0)) + o, 2.0); + + color += snow(vec3(x,y,z), c, o); + } + + return color; + } + + void main(void) + { + uv = gl_FragCoord.xy / OutputSize.xy; + uv = uv * 2.0 - 1.0; + vec2 p = uv; + p.x *= OutputSize.x / OutputSize.y; + + atime = (time + 1.0) / 4.0; + + gl_FragColor = vec4(col(p)); + } + +); \ No newline at end of file diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h index 256ae4378b..52f2385bbe 100644 --- a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h +++ b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h @@ -51,7 +51,7 @@ static const char *stock_xmb_ribbon_simple = CG( float4 color : COLOR; }; - output main_fragment(uniform input IN) + output main_fragment(uniform input IN) { output OUT; OUT.color = float4(0.05, 0.05, 0.05, 1.0); diff --git a/gfx/drivers/gl_symlinks.h b/gfx/drivers/gl_symlinks.h deleted file mode 100644 index 8628698f3e..0000000000 --- a/gfx/drivers/gl_symlinks.h +++ /dev/null @@ -1,159 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2012-2015 - Michael Lelli - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef _GL_SYMLINKS_H -#define _GL_SYMLINKS_H - -#include -#include - -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if defined(HAVE_PSGL) -#define glGenFramebuffers glGenFramebuffersOES -#define glBindFramebuffer glBindFramebufferOES -#define glFramebufferTexture2D glFramebufferTexture2DOES -#define glCheckFramebufferStatus glCheckFramebufferStatusOES -#define glDeleteFramebuffers glDeleteFramebuffersOES -#define glGenRenderbuffers glGenRenderbuffersOES -#define glBindRenderbuffer glBindRenderbufferOES -#define glFramebufferRenderbuffer glFramebufferRenderbufferOES -#define glRenderbufferStorage glRenderbufferStorageOES -#define glDeleteRenderbuffers glDeleteRenderbuffersOES -#endif - -#if defined(HAVE_PSGL) -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT -#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT -#else -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0 -#endif - -#if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER -#if defined(HAVE_OPENGLES2) -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES -#else -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 -#endif -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT -#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT -#elif defined(HAVE_PSGL) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES -#else -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT -#endif - -#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT -#elif defined(HAVE_PSGL) -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES -#else -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE -#endif - -#if defined(HAVE_PSGL) -#define glGenerateMipmap glGenerateMipmapOES -#endif - -#if defined(__APPLE__) || defined(HAVE_PSGL) -#define GL_RGBA32F GL_RGBA32F_ARB -#endif - -#if defined(HAVE_PSGL) -#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_RGB5 -#elif defined(HAVE_OPENGLES) -/* Imgtec/SGX headers have this missing. */ -#ifndef GL_BGRA_EXT -#define GL_BGRA_EXT 0x80E1 -#endif -#ifndef GL_BGRA8_EXT -#define GL_BGRA8_EXT 0x93A1 -#endif -#ifdef IOS -/* Stupid Apple */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA -#else -#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT -#endif -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT -#define RARCH_GL_TEXTURE_TYPE16 GL_RGB -#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE -#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 -#else -/* On desktop, we always use 32-bit. */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV - -/* GL_RGB565 internal format isn't in desktop GL - * until 4.1 core (ARB_ES2_compatibility). - * Check for this. */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif -#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 -#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB -#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 -#endif - -#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ -#define NO_GL_CLAMP_TO_BORDER -#endif - -#if defined(HAVE_OPENGLES) -#ifndef GL_UNPACK_ROW_LENGTH -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#endif - -#ifndef GL_SRGB_ALPHA_EXT -#define GL_SRGB_ALPHA_EXT 0x8C42 -#endif -#endif - -#endif diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index bf7727909e..7726a4a876 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -21,7 +21,8 @@ #include #include -#include +#include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -269,7 +270,7 @@ static void retrace_callback(u32 retrace_count) static bool gx_isValidXOrigin(int origin) { - if(origin < 0 || origin + gx_used_system_xOrigin < 0 || + if(origin < 0 || origin + gx_used_system_xOrigin < 0 || gx_mode.viWidth + origin + gx_used_system_xOrigin > 720) return false; return true; @@ -303,7 +304,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, VIDEO_SetPostRetraceCallback(NULL); g_draw_done = false; /* wait for next even field */ - /* this prevents screen artifacts when switching + /* this prevents screen artifacts when switching * between interlaced & non-interlaced modes */ do VIDEO_WaitVSync(); while (!VIDEO_GetNextField()); @@ -417,7 +418,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, } gx_mode.viXOrigin = gx_xOrigin = tmpOrigin; - gx_mode.viYOrigin = gx_yOrigin = + gx_mode.viYOrigin = gx_yOrigin = (max_height - gx_mode.viHeight) / (2 * viHeightMultiplier); gx_xOriginNeg = 0, gx_xOriginPos = 0; @@ -484,7 +485,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, GX_SetDispCopyDst((u16)xfbWidth, (u16)xfbHeight); GX_SetCopyFilter(gx_mode.aa, gx_mode.sample_pattern, - (gx_mode.xfbMode == VI_XFBMODE_SF) + (gx_mode.xfbMode == VI_XFBMODE_SF) ? GX_FALSE : settings->bools.video_vfilter, gx_mode.vfilter); GXColor color = { 0, 0, 0, 0xff }; @@ -494,7 +495,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_InvalidateTexAll(); GX_Flush(); - + /* Now apply all the configuration to the screen */ VIDEO_Configure(&gx_mode); VIDEO_ClearFrameBuffer(&gx_mode, gx->framebuf[0], COLOR_BLACK); @@ -506,7 +507,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, VIDEO_SetBlack(false); VIDEO_Flush(); VIDEO_WaitVSync(); - + RARCH_LOG("[GX]: Resolution: %dx%d (%s)\n", gx_mode.fbWidth, gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? "interlaced" : "progressive"); @@ -523,7 +524,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, if (modetype == VI_NON_INTERLACE) refresh_rate = 59.8261f; } - + driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate); } @@ -719,12 +720,14 @@ static void gx_efb_screenshot(void) { int x, y; uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00}; - RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, -1); + intfstream_t *out = intfstream_open("/screenshot.tga", + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!out) return; - filestream_write(out, tga_header, sizeof(tga_header)); + intfstream_write(out, tga_header, sizeof(tga_header)); for (y = 479; y >= 0; --y) { @@ -739,10 +742,11 @@ static void gx_efb_screenshot(void) line[i++] = color.g; line[i++] = color.r; } - filestream_write(out, line, sizeof(line)); + intfstream_write(out, line, sizeof(line)); } - filestream_close(out); + intfstream_close(out); + free(out); } #endif @@ -973,8 +977,8 @@ static void gx_resize(void *data) #endif if (fabs(device_aspect - desired_aspect) < 0.0001) { - /* If the aspect ratios of screen and desired aspect ratio - * are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect ratio + * are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) @@ -1107,8 +1111,8 @@ static void gx_blit_line(gx_video_t *gx, { uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7); unsigned offset = (i + j * FONT_WIDTH) >> 3; - bool col = - (bitmap_bin[FONT_OFFSET((unsigned char)*message) + offset] + bool col = + (bitmap_bin[FONT_OFFSET((unsigned char)*message) + offset] & rem); GXColor c = b; @@ -1209,7 +1213,7 @@ static void gx_set_texture_enable(void *data, bool enable, bool full_screen) return; gx->menu_texture_enable = enable; - /* need to make sure the game texture is the right pixel + /* need to make sure the game texture is the right pixel * format for menu overlay. */ gx->should_resize = true; } @@ -1375,7 +1379,7 @@ static bool gx_overlay_load(void *data, images[i].height * sizeof(uint32_t)); /* Default. Stretch to whole screen. */ - gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); + gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); gx_overlay_vertex_geom(gx, i, 0, 0, 1, 1); gx->overlay[i].alpha_mod = 1.0f; } @@ -1643,7 +1647,7 @@ static bool gx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_gx = { diff --git a/gfx/drivers/gx_gfx_vi_encoder.c b/gfx/drivers/gx_gfx_vi_encoder.c index 104650f040..5b7a4ca905 100644 --- a/gfx/drivers/gx_gfx_vi_encoder.c +++ b/gfx/drivers/gx_gfx_vi_encoder.c @@ -1,413 +1,413 @@ -/**************************************************************************** - * vi_encoder.c - * - * Wii Audio/Video Encoder support - * - * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include "../../defines/gx_defines.h" - -void udelay(int us); - -static u32 i2cIdentFirst = 0; -static u32 i2cIdentFlag = 1; -static vu32* const _i2cReg = (u32*)0xCD800000; - -static INLINE void __viOpenI2C(u32 channel) -{ - u32 val = ((_i2cReg[49]&~0x8000)|0x4000) | _SHIFTL(channel,15,1); - _i2cReg[49] = val; -} - -static INLINE void __viSetSCL(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x4000) | _SHIFTL(channel,14,1); - _i2cReg[48] = val; -} - -static INLINE void __viSetSDA(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x8000) | _SHIFTL(channel,15,1); - _i2cReg[48] = val; -} - -#define __viGetSDA() (_SHIFTR(_i2cReg[50],15,1)) - -static u32 __sendSlaveAddress(u8 addr) -{ - u32 i; - - __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(0); - for(i=0;i<8;i++) - { - if (addr&0x80) - __viSetSDA(i2cIdentFlag); - else - __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(1); - udelay(2); - - __viSetSCL(0); - addr <<= 1; - } - - __viOpenI2C(0); - udelay(2); - - __viSetSCL(1); - udelay(2); - - if ((i2cIdentFlag == 1) && __viGetSDA()!=0) - return 0; - - __viSetSDA(i2cIdentFlag^1); - __viOpenI2C(1); - __viSetSCL(0); - - return 1; -} - -static u32 __VISendI2CData(u8 addr,void *val,u32 len) -{ - u8 c; - s32 i,j; - u32 level,ret; - - if(i2cIdentFirst==0) - { - __viOpenI2C(0); - udelay(4); - - i2cIdentFlag = 0; - if(__viGetSDA()!=0) - i2cIdentFlag = 1; - i2cIdentFirst = 1; - } - - _CPU_ISR_Disable(level); - - __viOpenI2C(1); - __viSetSCL(1); - - __viSetSDA(i2cIdentFlag); - udelay(4); - - ret = __sendSlaveAddress(addr); - - if(ret == 0) - { - _CPU_ISR_Restore(level); - return 0; - } - - __viOpenI2C(1); - for(i=0;i +#include +#include +#include +#include + +#include + +#include "../../defines/gx_defines.h" + +void udelay(int us); + +static u32 i2cIdentFirst = 0; +static u32 i2cIdentFlag = 1; +static vu32* const _i2cReg = (u32*)0xCD800000; + +static INLINE void __viOpenI2C(u32 channel) +{ + u32 val = ((_i2cReg[49]&~0x8000)|0x4000) | _SHIFTL(channel,15,1); + _i2cReg[49] = val; +} + +static INLINE void __viSetSCL(u32 channel) +{ + u32 val = (_i2cReg[48]&~0x4000) | _SHIFTL(channel,14,1); + _i2cReg[48] = val; +} + +static INLINE void __viSetSDA(u32 channel) +{ + u32 val = (_i2cReg[48]&~0x8000) | _SHIFTL(channel,15,1); + _i2cReg[48] = val; +} + +#define __viGetSDA() (_SHIFTR(_i2cReg[50],15,1)) + +static u32 __sendSlaveAddress(u8 addr) +{ + u32 i; + + __viSetSDA(i2cIdentFlag^1); + udelay(2); + + __viSetSCL(0); + for(i=0;i<8;i++) + { + if (addr&0x80) + __viSetSDA(i2cIdentFlag); + else + __viSetSDA(i2cIdentFlag^1); + udelay(2); + + __viSetSCL(1); + udelay(2); + + __viSetSCL(0); + addr <<= 1; + } + + __viOpenI2C(0); + udelay(2); + + __viSetSCL(1); + udelay(2); + + if ((i2cIdentFlag == 1) && __viGetSDA()!=0) + return 0; + + __viSetSDA(i2cIdentFlag^1); + __viOpenI2C(1); + __viSetSCL(0); + + return 1; +} + +static u32 __VISendI2CData(u8 addr,void *val,u32 len) +{ + u8 c; + s32 i,j; + u32 level,ret; + + if(i2cIdentFirst==0) + { + __viOpenI2C(0); + udelay(4); + + i2cIdentFlag = 0; + if(__viGetSDA()!=0) + i2cIdentFlag = 1; + i2cIdentFirst = 1; + } + + _CPU_ISR_Disable(level); + + __viOpenI2C(1); + __viSetSCL(1); + + __viSetSDA(i2cIdentFlag); + udelay(4); + + ret = __sendSlaveAddress(addr); + + if(ret == 0) + { + _CPU_ISR_Restore(level); + return 0; + } + + __viOpenI2C(1); + for(i=0;ifbname, &status); @@ -873,7 +873,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) int base_x, base_y; int glyph_width, glyph_height; const uint8_t *src = NULL; - const struct font_glyph *glyph = + const struct font_glyph *glyph = vid->font_driver->get_glyph(vid->font, (uint8_t)*msg); if (!glyph) @@ -888,7 +888,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) glyph_width = glyph->width; glyph_height = glyph->height; - src = atlas->buffer + glyph->atlas_offset_x + + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -1085,7 +1085,7 @@ static bool omap_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void omap_gfx_set_rotation(void *data, unsigned rotation) diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 128fab83b5..8133a8dcf5 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -122,7 +122,7 @@ typedef struct psp1_video #define PSP_FRAME_SLICE_COUNT (PSP_FRAME_ROWS_COUNT * PSP_FRAME_COLUMNS_COUNT) #define PSP_FRAME_VERTEX_COUNT (PSP_FRAME_SLICE_COUNT * 2) -static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords, +static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords, int x, int y, int width, int height, unsigned rotation) { int i; @@ -261,7 +261,7 @@ static void psp_on_vblank(u32 sub, psp1_video_t *psp) static void *psp_init(const video_info_t *video, const input_driver_t **input, void **input_data) { - /* TODO : add ASSERT() checks or use main RAM if + /* TODO : add ASSERT() checks or use main RAM if * VRAM is too low for desired video->input_scale. */ int pixel_format, lut_pixel_format, lut_block_count; @@ -284,11 +284,11 @@ static void *psp_init(const video_info_t *video, psp->vp.full_width = SCEGU_SCR_WIDTH; psp->vp.full_height = SCEGU_SCR_HEIGHT; - /* Make sure anything using uncached pointers reserves + /* Make sure anything using uncached pointers reserves * whole cachelines (memory address and size need to be a multiple of 64) * so it isn't overwritten by an unlucky cache writeback. * - * This includes display lists since the Gu library uses + * This includes display lists since the Gu library uses * uncached pointers to write to them. */ /* Allocate more space if bigger display lists are needed. */ @@ -367,8 +367,8 @@ static void *psp_init(const video_info_t *video, psp->draw_buffer = SCEGU_VRAM_BP_0; psp->bpp_log2 = 1; - pixel_format = - (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) + pixel_format = + (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) ? GU_PSM_5551 : GU_PSM_5650 ; lut_pixel_format = GU_PSM_T16; @@ -410,7 +410,7 @@ static void *psp_init(const video_info_t *video, sceGuFinish(); sceGuSync(0, 0); - + /* TODO : check if necessary */ sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); @@ -428,10 +428,10 @@ static void *psp_init(const video_info_t *video, /* green only */ sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x0000FF00, 0xFFFFFFFF); - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); - + /* restore */ sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF); @@ -446,7 +446,7 @@ static void *psp_init(const video_info_t *video, sceGuClutMode(pixel_format, 0, color_mask, 0); sceGuClutLoad(lut_block_count, LUT_b); - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); @@ -544,10 +544,10 @@ static bool psp_frame(void *data, const void *frame, sceGuTexFilter(psp->tex_filter, psp->tex_filter); sceGuClear(GU_COLOR_BUFFER_BIT); - /* frame in VRAM ? texture/palette was + /* frame in VRAM ? texture/palette was * set in core so draw directly */ - if (psp->hw_render) - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + if (psp->hw_render) + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); else @@ -672,7 +672,7 @@ static void psp_set_texture_frame(void *data, const void *frame, bool rgb32, #endif sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); ; - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, psp->menu.frame_coords); sceGuFinish(); @@ -725,7 +725,7 @@ static void psp_update_viewport(psp1_video_t* psp, if ((fabsf(device_aspect - desired_aspect) < 0.0001f) || (fabsf((16.0/9.0) - desired_aspect) < 0.02f)) { - /* If the aspect ratios of screen and desired aspect + /* If the aspect ratios of screen and desired aspect * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ @@ -825,7 +825,7 @@ static void psp_apply_state_changes(void *data) static void psp_viewport_info(void *data, struct video_viewport *vp) { psp1_video_t *psp = (psp1_video_t*)data; - + if (psp) *vp = psp->vp; } @@ -951,7 +951,7 @@ static bool psp_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_psp1 = { diff --git a/gfx/drivers/psp1_gfx.h b/gfx/drivers/psp1_gfx.h index 4d2021379c..5798f56149 100644 --- a/gfx/drivers/psp1_gfx.h +++ b/gfx/drivers/psp1_gfx.h @@ -32,7 +32,7 @@ typedef struct int ge_callback_id; GuSwapBuffersCallback swapBuffersCallback; - int swapBuffersBehaviour; + int swapBuffersBehaviour; } GuSettings; typedef struct diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 8431ebb531..a77061f6e5 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -178,7 +178,7 @@ static void sdl2_render_msg(sdl2_video_t *vid, const char *msg) { SDL_Rect src_rect, dst_rect; int off_x, off_y, tex_x, tex_y; - const struct font_glyph *gly = + const struct font_glyph *gly = vid->font_driver->get_glyph(vid->font_data, (uint8_t)*msg); if (!gly) @@ -292,7 +292,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) vid->video.force_aspect); else if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const struct video_viewport *custom = + const struct video_viewport *custom = (const struct video_viewport*)video_viewport_get_custom(); vid->vp.x = custom->x; @@ -694,7 +694,7 @@ static void sdl2_poke_texture_enable(void *data, bool enable, bool full_screen) vid->menu.active = enable; } -static void sdl2_poke_set_osd_msg(void *data, +static void sdl2_poke_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, const void *params, void *font) @@ -760,7 +760,7 @@ static bool sdl2_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_sdl2 = { diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 7f2060296c..0e2d2d473a 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -152,7 +152,7 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, base_x = msg_base_x + glyph->draw_offset_x; base_y = msg_base_y + glyph->draw_offset_y; - src = atlas->buffer + glyph->atlas_offset_x + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -470,7 +470,7 @@ static void sdl_apply_state_changes(void *data) static void sdl_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - enum scaler_pix_fmt format = rgb32 + enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; sdl_video_t *vid = (sdl_video_t*)data; @@ -560,7 +560,7 @@ static bool sdl_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void sdl_gfx_set_rotation(void *data, unsigned rotation) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 90a9eadbc5..2c4eecbe5f 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -492,7 +492,7 @@ void pixman_composite_src_8888_8888_asm_neon(int width, uint16_t *src, int src_stride_pixels); -/* Pointer to the blitting function. Will be asigned +/* Pointer to the blitting function. Will be asigned * when we find out what bpp the core uses. */ void (*pixman_blit) (int width, int height, @@ -503,7 +503,7 @@ void (*pixman_blit) (int width, struct sunxi_page { - uint32_t *address; + uint32_t *address; unsigned int offset; }; @@ -523,13 +523,13 @@ struct sunxi_video unsigned int src_pitch; unsigned int src_bpp; unsigned int src_bytes_per_pixel; - unsigned int src_pixels_per_line; + unsigned int src_pixels_per_line; unsigned int dst_pitch; unsigned int dst_pixels_per_line; - unsigned int bytes_per_pixel; + unsigned int bytes_per_pixel; - struct sunxi_page *pages; - struct sunxi_page *nextPage; + struct sunxi_page *pages; + struct sunxi_page *nextPage; bool pageflip_pending; /* Keep the vsync while loop going. Set to false to exit. */ @@ -541,7 +541,7 @@ struct sunxi_video /* For threading */ sthread_t *vsync_thread; - scond_t *vsync_condition; + scond_t *vsync_condition; slock_t *pending_mutex; /* menu data */ @@ -611,7 +611,7 @@ static void sunxi_vsync_thread_func(void *data) _dispvars->pageflip_pending = false; scond_signal(_dispvars->vsync_condition); slock_unlock(_dispvars->pending_mutex); - } + } } static void *sunxi_gfx_init(const video_info_t *video, @@ -642,9 +642,9 @@ static void *sunxi_gfx_init(const video_info_t *video, _dispvars->keep_vsync = true; _dispvars->menu_active = false; _dispvars->bytes_per_pixel = video->rgb32 ? 4 : 2; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _dispvars->aspect_ratio = video_driver_get_aspect_ratio(); @@ -688,15 +688,15 @@ static void sunxi_gfx_free(void *data) _dispvars->keep_vsync = false; sthread_join(_dispvars->vsync_thread); } - - slock_free(_dispvars->pending_mutex); + + slock_free(_dispvars->pending_mutex); scond_free(_dispvars->vsync_condition); - free(_dispvars->pages); + free(_dispvars->pages); /* Restore text console contents and reactivate cursor blinking. */ sunxi_restore_console(_dispvars); - + sunxi_disp_close(_dispvars->sunxi_disp); free(_dispvars); } @@ -714,14 +714,14 @@ static void sunxi_update_main(const void *frame, struct sunxi_video *_dispvars) pixman_blit( _dispvars->src_width, _dispvars->src_height, - _dispvars->nextPage->address, + _dispvars->nextPage->address, _dispvars->dst_pixels_per_line, (uint16_t*)frame, _dispvars->src_pixels_per_line ); /* Issue pageflip. Will flip on next vsync. */ - sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, _dispvars->sunxi_disp->bits_per_pixel, + sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, _dispvars->sunxi_disp->bits_per_pixel, _dispvars->nextPage->offset, _dispvars->src_width, _dispvars->src_height, _dispvars->sunxi_disp->xres); @@ -740,16 +740,16 @@ static void sunxi_setup_scale (void *data, _dispvars->src_width = width; _dispvars->src_height = height; - /* Total pitch, including things the + /* Total pitch, including things the * cores render between "visible" scanlines. */ - _dispvars->src_pitch = pitch; + _dispvars->src_pitch = pitch; /* Pixels per line */ _dispvars->src_pixels_per_line = _dispvars->src_pitch/_dispvars->bytes_per_pixel; - /* Incremental offset that sums up on + /* Incremental offset that sums up on * each previous page offset. - * Total offset of each page has to + * Total offset of each page has to * be adjusted when internal resolution changes. */ for (i = 0; i < NUMPAGES; i++) { @@ -758,7 +758,7 @@ static void sunxi_setup_scale (void *data, } visible_width = _dispvars->sunxi_disp->yres * _dispvars->aspect_ratio; - xpos = (_dispvars->sunxi_disp->xres - visible_width) / 2; + xpos = (_dispvars->sunxi_disp->xres - visible_width) / 2; /* setup layer window */ sunxi_layer_set_output_window(_dispvars->sunxi_disp, xpos, 0, visible_width, _dispvars->sunxi_disp->yres); @@ -854,7 +854,7 @@ static bool sunxi_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void sunxi_set_texture_enable(void *data, bool state, bool full_screen) @@ -863,7 +863,7 @@ static void sunxi_set_texture_enable(void *data, bool state, bool full_screen) /* If it wasn't active and starts being active... */ if (!_dispvars->menu_active && state) - { + { /* Stop the vsync thread. */ _dispvars->keep_vsync = false; sthread_join(_dispvars->vsync_thread); @@ -889,10 +889,10 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, /* We have to go on a pixel format conversion adventure for now, until we can * convince RGUI to output in an 8888 format. */ - unsigned int src_pitch = width * 2; + unsigned int src_pitch = width * 2; unsigned int dst_pitch = _dispvars->sunxi_disp->xres * 4; unsigned int dst_width = _dispvars->sunxi_disp->xres; - uint32_t line[dst_width]; + uint32_t line[dst_width]; /* Remember, memcpy() works with 8bits pointers for increments. */ char *dst_base_addr = (char*)(_dispvars->pages[0].address); @@ -901,24 +901,24 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, { for (j = 0; j < src_pitch / 2; j++) { - uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); + uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); /* The hex AND is for keeping only the part we need for each component. */ uint32_t R = (src_pix << 8) & 0x00FF0000; uint32_t G = (src_pix << 4) & 0x0000FF00; uint32_t B = (src_pix << 0) & 0x000000FF; - line[j] = (0 | R | G | B); + line[j] = (0 | R | G | B); } memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); } /* Issue pageflip. Will flip on next vsync. */ sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, - _dispvars->sunxi_disp->bits_per_pixel, + _dispvars->sunxi_disp->bits_per_pixel, _dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres); } } -static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { struct sunxi_video *_dispvars = (struct sunxi_video*)data; float new_aspect = aspectratio_lut[aspect_ratio_idx].value; diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 9bbf431186..301dec6e19 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -139,7 +139,7 @@ static void *vga_gfx_init(const video_info_t *video, vga_gfx_create(); if (video->font_enable) - font_driver_init_osd(NULL, false, + font_driver_init_osd(NULL, false, video->is_threaded, FONT_DRIVER_RENDER_VGA); return vga; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 8cc1ba72be..8e4c13ee35 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -42,7 +42,7 @@ extern void *memcpy_neon(void *dst, const void *src, size_t n); static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate); - + static void *vita2d_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { @@ -86,7 +86,7 @@ static void *vita2d_gfx_init(const video_info_t *video, vita->vsync = video->vsync; vita->rgb32 = video->rgb32; - vita->tex_filter = video->smooth + vita->tex_filter = video->smooth ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; video_driver_set_size(&temp_width, &temp_height); @@ -106,7 +106,7 @@ static void *vita2d_gfx_init(const video_info_t *video, #ifdef HAVE_OVERLAY vita->overlay_enable = false; #endif - font_driver_init_osd(vita, false, + font_driver_init_osd(vita, false, video->is_threaded, FONT_DRIVER_RENDER_VITA2D); @@ -479,21 +479,21 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) { - delta = (desired_aspect / device_aspect - 1.0f) + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = (int)roundf(viewport_width * (0.5f - delta)); viewport_width = (unsigned)roundf(2.0f * viewport_width * delta); } else { - delta = (device_aspect / desired_aspect - 1.0f) + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; y = (int)roundf(viewport_height * (0.5f - delta)); viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); @@ -569,7 +569,7 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth) if (vita) { - vita->tex_filter = smooth ? + vita->tex_filter = smooth ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; vita2d_texture_set_filters(vita->texture,vita->tex_filter, vita->tex_filter); @@ -696,13 +696,13 @@ static uintptr_t vita_load_texture(void *video_data, void *data, uint32_t *tex32 = NULL; const uint32_t *frame32 = NULL; struct texture_image *image = (struct texture_image*)data; - struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width, + struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width, image->height,SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB); if (!texture) return 0; - if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) || + if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) || (filter_type == TEXTURE_FILTER_LINEAR)) vita2d_texture_set_filters(texture, SCE_GXM_TEXTURE_FILTER_LINEAR, @@ -771,7 +771,7 @@ static bool vita_get_current_sw_framebuffer(void *data, framebuffer->data = vita2d_texture_get_datap(vita->texture); framebuffer->pitch = vita2d_texture_get_stride(vita->texture); - framebuffer->format = vita->rgb32 + framebuffer->format = vita->rgb32 ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; framebuffer->memory_flags = 0; @@ -849,7 +849,7 @@ static bool vita2d_overlay_load(void *data, const void *image_data, unsigned num for (j = 0; j < o->height; j++) for (k = 0; k < o->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + vita2d_overlay_tex_geom(vita, i, 0, 0, 1, 1); /* Default. Stretch to whole screen. */ vita2d_overlay_vertex_geom(vita, i, 0, 0, 1, 1); vita->overlay[i].alpha_mod = 1.0f; @@ -881,7 +881,7 @@ static void vita2d_overlay_vertex_geom(void *data, unsigned image, { vita_video_t *vita = (vita_video_t*)data; struct vita_overlay_data *o = NULL; - + /* Flipped, so we preserve top-down semantics. */ /*y = 1.0f - y; h = -h;*/ @@ -891,7 +891,7 @@ static void vita2d_overlay_vertex_geom(void *data, unsigned image, if (o) { - + o->w = w*PSP_FB_WIDTH/o->width; o->h = h*PSP_FB_HEIGHT/o->height; o->x = PSP_FB_WIDTH*(1-w)/2+x; @@ -924,14 +924,14 @@ static void vita2d_render_overlay(void *data) for (i = 0; i < vita->overlays; i++) { - vita2d_draw_texture_tint_part_scale(vita->overlay[i].tex, - vita->overlay[i].x, - vita->overlay[i].y, - vita->overlay[i].tex_x, - vita->overlay[i].tex_y, - vita->overlay[i].tex_w, - vita->overlay[i].tex_h, - vita->overlay[i].w, + vita2d_draw_texture_tint_part_scale(vita->overlay[i].tex, + vita->overlay[i].x, + vita->overlay[i].y, + vita->overlay[i].tex_x, + vita->overlay[i].tex_y, + vita->overlay[i].tex_w, + vita->overlay[i].tex_h, + vita->overlay[i].w, vita->overlay[i].h, RGBA8(0xFF,0xFF,0xFF,(uint8_t)(vita->overlay[i].alpha_mod * 255.0f))); } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 45be4a4e70..f18f2ba290 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -78,7 +78,7 @@ static void vulkan_init_render_pass( VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; VkAttachmentDescription attachment = {0}; VkSubpassDescription subpass = {0}; - VkAttachmentReference color_ref = { 0, + VkAttachmentReference color_ref = { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; /* Backbuffer format. */ @@ -93,7 +93,7 @@ static void vulkan_init_render_pass( attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - /* The image layout will be attachment_optimal + /* The image layout will be attachment_optimal * when we're executing the renderpass. */ attachment.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; attachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; @@ -128,7 +128,14 @@ static void vulkan_init_framebuffers( VkFramebufferCreateInfo info = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; - vk->swapchain[i].backbuffer.image = vk->context->swapchain_images[i]; + vk->swapchain[i].backbuffer.image = vk->context->swapchain_images[i]; + + if (vk->context->swapchain_images[i] == VK_NULL_HANDLE) + { + vk->swapchain[i].backbuffer.view = VK_NULL_HANDLE; + vk->swapchain[i].backbuffer.framebuffer = VK_NULL_HANDLE; + continue; + } /* Create an image view which we can render into. */ view.viewType = VK_IMAGE_VIEW_TYPE_2D; @@ -163,9 +170,9 @@ static void vulkan_init_framebuffers( static void vulkan_init_pipeline_layout( vk_t *vk) { - VkDescriptorSetLayoutCreateInfo set_layout_info = { + VkDescriptorSetLayoutCreateInfo set_layout_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; - VkPipelineLayoutCreateInfo layout_info = { + VkPipelineLayoutCreateInfo layout_info = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; VkDescriptorSetLayoutBinding bindings[2] = {{0}}; @@ -238,22 +245,22 @@ static void vulkan_init_pipelines( ; unsigned i; - VkPipelineInputAssemblyStateCreateInfo input_assembly = { + VkPipelineInputAssemblyStateCreateInfo input_assembly = { VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; - VkPipelineVertexInputStateCreateInfo vertex_input = { + VkPipelineVertexInputStateCreateInfo vertex_input = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; - VkPipelineRasterizationStateCreateInfo raster = { + VkPipelineRasterizationStateCreateInfo raster = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO }; VkPipelineColorBlendAttachmentState blend_attachment = {0}; - VkPipelineColorBlendStateCreateInfo blend = { + VkPipelineColorBlendStateCreateInfo blend = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; - VkPipelineViewportStateCreateInfo viewport = { + VkPipelineViewportStateCreateInfo viewport = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; - VkPipelineDepthStencilStateCreateInfo depth_stencil = { + VkPipelineDepthStencilStateCreateInfo depth_stencil = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO }; - VkPipelineMultisampleStateCreateInfo multisample = { + VkPipelineMultisampleStateCreateInfo multisample = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO }; - VkPipelineDynamicStateCreateInfo dynamic = { + VkPipelineDynamicStateCreateInfo dynamic = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO }; VkPipelineShaderStageCreateInfo shader_stages[2] = { @@ -261,9 +268,9 @@ static void vulkan_init_pipelines( { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO }, }; - VkGraphicsPipelineCreateInfo pipe = { + VkGraphicsPipelineCreateInfo pipe = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; - VkShaderModuleCreateInfo module_info = { + VkShaderModuleCreateInfo module_info = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO }; VkVertexInputAttributeDescription attributes[3] = {{0}}; VkVertexInputBindingDescription binding = {0}; @@ -510,13 +517,13 @@ static void vulkan_init_command_buffers(vk_t *vk) for (i = 0; i < vk->num_swapchain_images; i++) { - VkCommandPoolCreateInfo pool_info = { + VkCommandPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; - VkCommandBufferAllocateInfo info = { + VkCommandBufferAllocateInfo info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; pool_info.queueFamilyIndex = vk->context->graphics_queue_index; - pool_info.flags = + pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; vkCreateCommandPool(vk->context->device, @@ -615,7 +622,7 @@ static void vulkan_init_descriptor_pool(vk_t *vk) for (i = 0; i < vk->num_swapchain_images; i++) { - vk->swapchain[i].descriptor_manager = + vk->swapchain[i].descriptor_manager = vulkan_create_descriptor_manager( vk->context->device, pool_sizes, 2, vk->pipelines.set_layout); @@ -716,10 +723,17 @@ static void vulkan_deinit_framebuffers(vk_t *vk) unsigned i; for (i = 0; i < vk->num_swapchain_images; i++) { - vkDestroyFramebuffer(vk->context->device, - vk->swapchain[i].backbuffer.framebuffer, NULL); - vkDestroyImageView(vk->context->device, - vk->swapchain[i].backbuffer.view, NULL); + if (vk->swapchain[i].backbuffer.framebuffer) + { + vkDestroyFramebuffer(vk->context->device, + vk->swapchain[i].backbuffer.framebuffer, NULL); + } + + if (vk->swapchain[i].backbuffer.view) + { + vkDestroyImageView(vk->context->device, + vk->swapchain[i].backbuffer.view, NULL); + } } vkDestroyRenderPass(vk->context->device, vk->render_pass, NULL); @@ -747,7 +761,7 @@ static bool vulkan_init_default_filter_chain(vk_t *vk) vk->filter_chain = vulkan_filter_chain_create_default( &info, - vk->video.smooth ? + vk->video.smooth ? VULKAN_FILTER_CHAIN_LINEAR : VULKAN_FILTER_CHAIN_NEAREST); if (!vk->filter_chain) @@ -834,10 +848,10 @@ static void vulkan_init_static_resources(vk_t *vk) { unsigned i; uint32_t blank[4 * 4]; - VkCommandPoolCreateInfo pool_info = { + VkCommandPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; /* Create the pipeline cache. */ - VkPipelineCacheCreateInfo cache = { + VkPipelineCacheCreateInfo cache = { VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; vkCreatePipelineCache(vk->context->device, @@ -1058,8 +1072,8 @@ static void vulkan_init_hw_render(vk_t *vk) static void vulkan_init_readback(vk_t *vk) { /* Only bother with this if we're doing GPU recording. - * Check recording_is_enabled() and not - * driver.recording_data, because recording is + * Check recording_is_enabled() and not + * driver.recording_data, because recording is * not initialized yet. */ settings_t *settings = config_get_ptr(); @@ -1157,7 +1171,7 @@ static void *vulkan_init(const video_info_t *video, vk->fullscreen = video->fullscreen; vk->tex_w = RARCH_SCALE_BASE * video->input_scale; vk->tex_h = RARCH_SCALE_BASE * video->input_scale; - vk->tex_fmt = video->rgb32 + vk->tex_fmt = video->rgb32 ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R5G6B5_UNORM_PACK16; vk->keep_aspect = video->force_aspect; RARCH_LOG("[Vulkan]: Using %s format.\n", video->rgb32 ? "BGRA8888" : "RGB565"); @@ -1181,7 +1195,7 @@ static void *vulkan_init(const video_info_t *video, video_context_driver_input_driver(&inp); if (video->font_enable) - font_driver_init_osd(vk, false, + font_driver_init_osd(vk, false, video->is_threaded, FONT_DRIVER_RENDER_VULKAN_API); @@ -1408,21 +1422,21 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) { - delta = (desired_aspect / device_aspect - 1.0f) + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = (int)roundf(viewport_width * (0.5f - delta)); viewport_width = (unsigned)roundf(2.0f * viewport_width * delta); } else { - delta = (device_aspect / desired_aspect - 1.0f) + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; y = (int)roundf(viewport_height * (0.5f - delta)); viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); @@ -1569,6 +1583,7 @@ static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t *video_info) #endif vkQueueSubmit(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); + vk->context->swapchain_fences_signalled[frame_index] = true; #ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); #endif @@ -1589,13 +1604,13 @@ static bool vulkan_frame(void *data, const void *frame, unsigned height = video_info->height; VkClearValue clear_color; - VkCommandBufferBeginInfo begin_info = { + VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; - VkRenderPassBeginInfo rp_info = { + VkRenderPassBeginInfo rp_info = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; - VkSubmitInfo submit_info = { + VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO }; - unsigned frame_index = + unsigned frame_index = vk->context->current_swapchain_index; /* Bookkeeping on start of frame. */ @@ -1643,12 +1658,12 @@ static bool vulkan_frame(void *data, const void *frame, const uint8_t *src = (const uint8_t*)frame; unsigned bpp = vk->video.rgb32 ? 4 : 2; - if ( chain->texture.width != frame_width + if ( chain->texture.width != frame_width || chain->texture.height != frame_height) { chain->texture = vulkan_create_texture(vk, &chain->texture, frame_width, frame_height, chain->texture.format, NULL, NULL, - chain->texture_optimal.memory + chain->texture_optimal.memory ? VULKAN_TEXTURE_STAGING : VULKAN_TEXTURE_STREAMED); vulkan_map_persistent_texture( @@ -1670,7 +1685,7 @@ static bool vulkan_frame(void *data, const void *frame, if (chain->texture.stride == pitch && pitch == frame_width * bpp) memcpy(dst, src, frame_width * frame_height * bpp); else - for (y = 0; y < frame_height; y++, + for (y = 0; y < frame_height; y++, dst += chain->texture.stride, src += pitch) memcpy(dst, src, frame_width * bpp); } @@ -1747,91 +1762,95 @@ static bool vulkan_frame(void *data, const void *frame, (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, &vk->vk_vp); /* Render to backbuffer. */ - rp_info.renderPass = vk->render_pass; - rp_info.framebuffer = chain->backbuffer.framebuffer; - rp_info.renderArea.extent.width = vk->context->swapchain_width; - rp_info.renderArea.extent.height = vk->context->swapchain_height; - rp_info.clearValueCount = 1; - rp_info.pClearValues = &clear_color; + if (chain->backbuffer.image != VK_NULL_HANDLE) + { + rp_info.renderPass = vk->render_pass; + rp_info.framebuffer = chain->backbuffer.framebuffer; + rp_info.renderArea.extent.width = vk->context->swapchain_width; + rp_info.renderArea.extent.height = vk->context->swapchain_height; + rp_info.clearValueCount = 1; + rp_info.pClearValues = &clear_color; - clear_color.color.float32[0] = 0.0f; - clear_color.color.float32[1] = 0.0f; - clear_color.color.float32[2] = 0.0f; - clear_color.color.float32[3] = 0.0f; + clear_color.color.float32[0] = 0.0f; + clear_color.color.float32[1] = 0.0f; + clear_color.color.float32[2] = 0.0f; + clear_color.color.float32[3] = 0.0f; - /* Prepare backbuffer for rendering. We don't use WSI semaphores here. */ - vulkan_image_layout_transition(vk, vk->cmd, chain->backbuffer.image, - VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, - 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); + /* Prepare backbuffer for rendering. We don't use WSI semaphores here. */ + vulkan_image_layout_transition(vk, vk->cmd, chain->backbuffer.image, + VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT, + VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); - /* Begin render pass and set up viewport */ - vkCmdBeginRenderPass(vk->cmd, &rp_info, VK_SUBPASS_CONTENTS_INLINE); + /* Begin render pass and set up viewport */ + vkCmdBeginRenderPass(vk->cmd, &rp_info, VK_SUBPASS_CONTENTS_INLINE); - vulkan_filter_chain_build_viewport_pass( - (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, - &vk->vk_vp, vk->mvp.data); + vulkan_filter_chain_build_viewport_pass( + (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, + &vk->vk_vp, vk->mvp.data); #if defined(HAVE_MENU) - if (vk->menu.enable) - { - menu_driver_frame(video_info); - - if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE) + if (vk->menu.enable) { - struct vk_draw_quad quad; - struct vk_texture *optimal = &vk->menu.textures_optimal[vk->menu.last_index]; - vulkan_set_viewport(vk, width, height, vk->menu.full_screen, false); + menu_driver_frame(video_info); - quad.pipeline = vk->pipelines.alpha_blend; - quad.texture = &vk->menu.textures[vk->menu.last_index]; - - if (optimal->memory != VK_NULL_HANDLE) + if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE) { - if (vk->menu.dirty[vk->menu.last_index]) + struct vk_draw_quad quad; + struct vk_texture *optimal = &vk->menu.textures_optimal[vk->menu.last_index]; + vulkan_set_viewport(vk, width, height, vk->menu.full_screen, false); + + quad.pipeline = vk->pipelines.alpha_blend; + quad.texture = &vk->menu.textures[vk->menu.last_index]; + + if (optimal->memory != VK_NULL_HANDLE) { - vulkan_copy_staging_to_dynamic(vk, vk->cmd, - optimal, - quad.texture); - vk->menu.dirty[vk->menu.last_index] = false; + if (vk->menu.dirty[vk->menu.last_index]) + { + vulkan_copy_staging_to_dynamic(vk, vk->cmd, + optimal, + quad.texture); + vk->menu.dirty[vk->menu.last_index] = false; + } + quad.texture = optimal; } - quad.texture = optimal; + + quad.sampler = optimal->mipmap ? + vk->samplers.mipmap_linear : vk->samplers.linear; + + quad.mvp = &vk->mvp_no_rot; + quad.color.r = 1.0f; + quad.color.g = 1.0f; + quad.color.b = 1.0f; + quad.color.a = vk->menu.alpha; + vulkan_draw_quad(vk, &quad); } - - quad.sampler = optimal->mipmap ? - vk->samplers.mipmap_linear : vk->samplers.linear; - - quad.mvp = &vk->mvp_no_rot; - quad.color.r = 1.0f; - quad.color.g = 1.0f; - quad.color.b = 1.0f; - quad.color.a = vk->menu.alpha; - vulkan_draw_quad(vk, &quad); } - } #endif - if (msg) - font_driver_render_msg(video_info, NULL, msg, NULL); + if (msg) + font_driver_render_msg(video_info, NULL, msg, NULL); #ifdef HAVE_OVERLAY - if (vk->overlay.enable) - vulkan_render_overlay(vk, video_info); + if (vk->overlay.enable) + vulkan_render_overlay(vk, video_info); #endif - /* End the render pass. We're done rendering to backbuffer now. */ - vkCmdEndRenderPass(vk->cmd); + /* End the render pass. We're done rendering to backbuffer now. */ + vkCmdEndRenderPass(vk->cmd); + } /* End the filter chain frame. * This must happen outside a render pass. */ vulkan_filter_chain_end_frame((vulkan_filter_chain_t*)vk->filter_chain, vk->cmd); - if (vk->readback.pending || vk->readback.streamed) + if (chain->backbuffer.image != VK_NULL_HANDLE && + (vk->readback.pending || vk->readback.streamed)) { - /* We cannot safely read back from an image which - * has already been presented as we need to + /* We cannot safely read back from an image which + * has already been presented as we need to * maintain the PRESENT_SRC_KHR layout. * * If we're reading back, perform the readback before presenting. @@ -1859,7 +1878,7 @@ static bool vulkan_frame(void *data, const void *frame, vk->readback.pending = false; } - else + else if (chain->backbuffer.image != VK_NULL_HANDLE) { /* Prepare backbuffer for presentation. */ vulkan_image_layout_transition(vk, vk->cmd, @@ -1929,12 +1948,12 @@ static bool vulkan_frame(void *data, const void *frame, } submit_info.pSignalSemaphores = submit_info.signalSemaphoreCount ? signal_semaphores : NULL; - #ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); #endif vkQueueSubmit(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); + vk->context->swapchain_fences_signalled[frame_index] = true; #ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); #endif @@ -2049,7 +2068,7 @@ static bool vulkan_get_current_sw_framebuffer(void *data, { struct vk_per_frame *chain = NULL; vk_t *vk = (vk_t*)data; - vk->chain = + vk->chain = &vk->swapchain[vk->context->current_swapchain_index]; chain = vk->chain; @@ -2076,7 +2095,7 @@ static bool vulkan_get_current_sw_framebuffer(void *data, framebuffer->data = chain->texture.mapped; framebuffer->pitch = chain->texture.stride; - framebuffer->format = vk->video.rgb32 + framebuffer->format = vk->video.rgb32 ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; framebuffer->memory_flags = 0; @@ -2350,7 +2369,7 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle) { unsigned x, y; const uint8_t *src = (const uint8_t*)staging->mapped; - buffer += 3 * (vk->vp.height - 1) + buffer += 3 * (vk->vp.height - 1) * vk->vp.width; for (y = 0; y < vk->vp.height; y++, @@ -2513,7 +2532,7 @@ static bool vulkan_overlay_load(void *data, const void *image_data, unsigned num_images) { unsigned i, j; - const struct texture_image *images = + const struct texture_image *images = (const struct texture_image*)image_data; vk_t *vk = (vk_t*)data; static const struct vk_color white = { diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 3832e7c538..9101d047cc 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -284,7 +284,7 @@ static bool xenon360_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void xenon360_gfx_viewport_info(void *data, struct video_viewport *vp) diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 75882f5f21..900a8a61a4 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -40,10 +40,10 @@ typedef struct xshm { Display* display; Window wndw; - + int width; int height; - + XShmSegmentInfo shmInfo; XImage* image; GC gc; @@ -54,11 +54,11 @@ static void *xshm_gfx_init(const video_info_t *video, { xshm_t* xshm = (xshm_t*)malloc(sizeof(xshm_t)); Window parent; - + XInitThreads(); - + xshm->display = XOpenDisplay(NULL); - + #ifdef RARCH_INTERNAL parent = DefaultRootWindow(xshm->display); #else @@ -71,26 +71,26 @@ static void *xshm_gfx_init(const video_info_t *video, 0, 24, CopyFromParent, NULL, CWBorderPixel, &attributes); XSetWindowBackground(xshm->display, xshm->wndw, 0); XMapWindow(xshm->display, xshm->wndw); - + xshm->shmInfo.shmid = shmget(IPC_PRIVATE, sizeof(uint32_t) * video->width * video->height, IPC_CREAT|0600); if (xshm->shmInfo.shmid<0) abort();//seems like an out of memory situation... let's just blow up - + xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0); xshm->shmInfo.readOnly = False; XShmAttach(xshm->display, &xshm->shmInfo); XSync(xshm->display, False);//no idea why this is required, but I get weird errors without it xshm->image = XShmCreateImage(xshm->display, NULL, 24, ZPixmap, xshm->shmInfo.shmaddr, &xshm->shmInfo, video->width, video->height); - + xshm->gc = XCreateGC(xshm->display, xshm->wndw, 0, NULL); - + xshm->width = video->width; xshm->height = video->height; - + if (input) *input = NULL; if (input_data) *input_data = NULL; - + return xshm; } @@ -100,7 +100,7 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, { xshm_t* xshm = (xshm_t*)data; int y; - + for (y=0;yshmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y, @@ -110,17 +110,17 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, #ifdef HAVE_MENU menu_driver_frame(video_info); #endif - + XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image, 0, 0, 0, 0, xshm->width, xshm->height, False); XFlush(xshm->display); - + return true; } static void xshm_gfx_set_nonblock_state(void *data, bool toggle) { - + } static bool xshm_gfx_alive(void *data) @@ -140,17 +140,17 @@ static bool xshm_gfx_suppress_screensaver(void *data, bool enable) static void xshm_gfx_free(void *data) { - + } static void xshm_gfx_set_rotation(void *data, unsigned rotation) { - + } static void xshm_gfx_viewport_info(void *data, struct video_viewport *vp) { - + } static bool xshm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) @@ -160,29 +160,29 @@ static bool xshm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) static void xshm_poke_set_filtering(void *data, unsigned index, bool smooth) { - + } static void xshm_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - + } static void xshm_poke_apply_state_changes(void *data) { - + } #ifdef HAVE_MENU static void xshm_poke_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - + } static void xshm_poke_texture_enable(void *data, bool enable, bool full_screen) { - + } static void xshm_poke_set_osd_msg(void *data, @@ -190,17 +190,17 @@ static void xshm_poke_set_osd_msg(void *data, const char *msg, const struct font_params *params, void *font) { - + } static void xshm_show_mouse(void *data, bool state) { - + } static void xshm_grab_mouse_toggle(void *data) { - + } #endif @@ -247,7 +247,7 @@ static bool xshm_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_xshm = { diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index dc3738c551..8df8f528bb 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -98,11 +98,11 @@ static void xv_set_nonblock_state(void *data, bool state) static INLINE void xv_calculate_yuv(uint8_t *y, uint8_t *u, uint8_t *v, unsigned r, unsigned g, unsigned b) { - int y_ = (int)(+((double)r * 0.257) + ((double)g * 0.504) + int y_ = (int)(+((double)r * 0.257) + ((double)g * 0.504) + ((double)b * 0.098) + 16.0); - int u_ = (int)(-((double)r * 0.148) - ((double)g * 0.291) + int u_ = (int)(-((double)r * 0.148) - ((double)g * 0.291) + ((double)b * 0.439) + 128.0); - int v_ = (int)(+((double)r * 0.439) - ((double)g * 0.368) + int v_ = (int)(+((double)r * 0.439) - ((double)g * 0.368) - ((double)b * 0.071) + 128.0); *y = y_ < 0 ? 0 : (y_ > 255 ? 255 : y_); @@ -139,8 +139,8 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) if (!settings->bools.video_font_enable) return; - if (font_renderer_create_default((const void**)&xv->font_driver, - &xv->font, *settings->paths.path_font + if (font_renderer_create_default((const void**)&xv->font_driver, + &xv->font, *settings->paths.path_font ? settings->paths.path_font : NULL, settings->floats.video_font_size)) { @@ -234,7 +234,7 @@ static void render32_yuy2(xv_t *xv, const void *input_, uint8_t y0, u, v; unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ y0 = xv->ytable[p]; @@ -268,7 +268,7 @@ static void render32_uyvy(xv_t *xv, const void *input_, uint8_t y0, u, v; unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ y0 = xv->ytable[p]; @@ -335,8 +335,8 @@ static bool xv_adaptor_set_format(xv_t *xv, Display *dpy, { for (j = 0; j < ARRAY_SIZE(formats); j++) { - if (format[i].type == XvYUV - && format[i].bits_per_pixel == 16 + if (format[i].type == XvYUV + && format[i].bits_per_pixel == 16 && format[i].format == XvPacked) { if (format[i].component_order[0] == formats[j].components[0] && @@ -345,7 +345,7 @@ static bool xv_adaptor_set_format(xv_t *xv, Display *dpy, format[i].component_order[3] == formats[j].components[3]) { xv->fourcc = format[i].id; - xv->render_func = video->rgb32 + xv->render_func = video->rgb32 ? formats[j].render_32 : formats[j].render_16; xv->luma_index[0] = formats[j].luma_index[0]; @@ -387,7 +387,7 @@ static void xv_calc_out_rect(bool keep_aspect, float desired_aspect = video_driver_get_aspect_ratio(); float device_aspect = (float)vp_width / vp_height; - /* If the aspect ratios of screen and desired aspect ratio + /* If the aspect ratios of screen and desired aspect ratio * are sufficiently equal (floating point stuff), * assume they are actually equal. */ @@ -453,7 +453,7 @@ static void *xv_init(const video_info_t *video, RARCH_ERR("[XVideo]: Check DISPLAY variable and if X is running.\n"); goto error; } - + av_info = video_viewport_get_system_av_info(); if (av_info) @@ -492,7 +492,7 @@ static void *xv_init(const video_info_t *video, for (i = 0; i < adaptor_count; i++) { - /* Find adaptor that supports both input (memory->drawable) + /* Find adaptor that supports both input (memory->drawable) * and image (drawable->screen) masks. */ if (adaptor_info[i].num_formats < 1) @@ -524,7 +524,7 @@ static void *xv_init(const video_info_t *video, visualtemplate.screen = DefaultScreen(g_x11_dpy); visualtemplate.depth = xv->depth; visualtemplate.visual = 0; - visualinfo = XGetVisualInfo(g_x11_dpy, VisualIDMask | + visualinfo = XGetVisualInfo(g_x11_dpy, VisualIDMask | VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches); if (!visualinfo) @@ -541,7 +541,7 @@ static void *xv_init(const video_info_t *video, attributes.colormap = g_x11_cmap; attributes.border_pixel = 0; - attributes.event_mask = StructureNotifyMask | KeyPressMask | + attributes.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonReleaseMask | ButtonPressMask | DestroyNotify | ClientMessage; if (video->fullscreen) @@ -677,7 +677,7 @@ static bool xv_check_resize(xv_t *xv, unsigned width, unsigned height) xv->width = xv->image->width; xv->height = xv->image->height; - xv->shminfo.shmid = + xv->shminfo.shmid = shmget(IPC_PRIVATE, xv->image->data_size, IPC_CREAT | 0777); if (xv->shminfo.shmid < 0) @@ -686,7 +686,7 @@ static bool xv_check_resize(xv_t *xv, unsigned width, unsigned height) return false; } - xv->shminfo.shmaddr = xv->image->data = + xv->shminfo.shmaddr = xv->image->data = (char*)shmat(xv->shminfo.shmid, NULL, 0); xv->shminfo.readOnly = false; @@ -733,21 +733,21 @@ static void xv_render_msg(xv_t *xv, const char *msg, int base_x, base_y, glyph_width, glyph_height, max_width, max_height; const uint8_t *src = NULL; uint8_t *out = NULL; - const struct font_glyph *glyph = + const struct font_glyph *glyph = xv->font_driver->get_glyph(xv->font, (uint8_t)*msg); if (!glyph) continue; - /* Make sure we always start on the correct boundary + /* Make sure we always start on the correct boundary * so the indices are correct. */ - base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1; + base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1; base_y = msg_base_y + glyph->draw_offset_y; glyph_width = glyph->width; glyph_height = glyph->height; - src = atlas->buffer + glyph->atlas_offset_x + + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -793,21 +793,21 @@ static void xv_render_msg(xv_t *xv, const char *msg, alpha[1] = src[x + 1]; /* Blended alpha for the sub-sampled U/V channels. */ - alpha_sub = (alpha[0] + alpha[1]) >> 1; + alpha_sub = (alpha[0] + alpha[1]) >> 1; for (i = 0; i < 2; i++) { - unsigned blended = (xv->font_y * alpha[i] + unsigned blended = (xv->font_y * alpha[i] + ((256 - alpha[i]) * out[out_x + luma_index[i]])) >> 8; out[out_x + luma_index[i]] = blended; } /* Blend chroma channels */ - blended = (xv->font_u * alpha_sub + blended = (xv->font_u * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_u_index])) >> 8; out[out_x + chroma_u_index] = blended; - blended = (xv->font_v * alpha_sub + blended = (xv->font_v * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_v_index])) >> 8; out[out_x + chroma_v_index] = blended; } @@ -938,7 +938,7 @@ static bool xv_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_xvideo = { diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index d2212f94c9..acd73fe27c 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -230,7 +230,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit, break; case GFX_CTX_VULKAN_API: #ifdef HAVE_VULKAN - /* Swapchains are recreated in set_resize as a + /* Swapchains are recreated in set_resize as a * central place, so use that to trigger swapchain reinit. */ *resize = and->vk.need_new_swapchain; new_width = and->width; @@ -281,6 +281,7 @@ static bool android_gfx_ctx_set_resize(void *data, return false; } + vulkan_acquire_next_image(&and->vk); and->vk.context.invalid_swapchain = true; and->vk.need_new_swapchain = false; #endif @@ -369,7 +370,7 @@ static bool android_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { unsigned version; - + switch (api) { case GFX_CTX_OPENGL_API: @@ -581,7 +582,7 @@ static uint32_t android_gfx_ctx_get_flags(void *data) { uint32_t flags = 0; BIT32_SET(flags, GFX_CTX_FLAGS_NONE); - + return flags; } diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 4593b46d8e..53e923da92 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -116,7 +116,7 @@ static bool gfx_ctx_cgl_set_video_mode(void *data, static void gfx_ctx_cgl_destroy(void *data) { gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)data; - + if (cgl->glCtx) { CGLSetCurrentContext(NULL); @@ -230,9 +230,9 @@ static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx, CGSConnectionID cid = CGSMainConnectionID(); printf("cid:%d wid:%d\n", cid, wid); - + /* determine window size */ - /* FIXME/TODO - CGWindowListCopyWindowInfo was introduced on OSX 10.5, + /* FIXME/TODO - CGWindowListCopyWindowInfo was introduced on OSX 10.5, * find alternative for lower versions. */ wins = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, wid); /* expect one result only */ win = (CFDictionaryRef)CFArrayGetValueAtIndex(wins, 0); @@ -242,33 +242,33 @@ static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx, CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(bnd, CFSTR("Height")), kCFNumberFloat64Type, &h); CFRelease(wins); - + /* create a surface. */ if(CGSAddSurface(cid, wid, &sid) != kCGErrorSuccess) { printf("ERR: no surface\n"); } printf("sid:%d\n", sid); - + /* set surface size, and order it frontmost */ if(CGSSetSurfaceBounds(cid, wid, sid, CGRectMake(0, 0, w, h)) != kCGErrorSuccess) printf("ERR: cant set bounds\n"); if(CGSOrderSurface(cid, wid, sid, 1, 0) != kCGErrorSuccess) printf("ERR: cant order front\n"); - + /* attach context to the surface */ if(CGLSetSurface(glCtx, cid, wid, sid) != kCGErrorSuccess) { printf("ERR: cant set surface\n"); } - + /* check drawable */ CGLGetParameter(glCtx, kCGLCPHasDrawable, ¶ms); if(params != 1) { printf("ERR: no drawable\n"); } - + *width = (int)w; *height = (int)h; diff --git a/gfx/drivers_context/d3d_ctx.c b/gfx/drivers_context/d3d_ctx.c index d5e3923be9..4a5e6d667d 100644 --- a/gfx/drivers_context/d3d_ctx.c +++ b/gfx/drivers_context/d3d_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2014 - OV2 - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -341,7 +341,7 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval) { d3d_video_t *d3d = (d3d_video_t*)data; #ifdef _XBOX - unsigned d3d_interval = interval ? + unsigned d3d_interval = interval ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; d3d_set_render_state(d3d->dev, XBOX_PRESENTATIONINTERVAL, d3d_interval); diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index e5eb203075..5c101eb57f 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -85,7 +85,7 @@ typedef struct gfx_ctx_drm_data unsigned fb_width; unsigned fb_height; - bool core_hw_context_enable; + bool core_hw_context_enable; } gfx_ctx_drm_data_t; struct drm_fb @@ -161,7 +161,7 @@ static void drm_flip_handler(int fd, unsigned frame, (void)fd; (void)sec; (void)usec; - + #if 0 static unsigned first_page_flip; static unsigned last_page_flip; @@ -189,7 +189,7 @@ static bool gfx_ctx_drm_wait_flip(bool block) if (!waiting_for_flip) return false; - + if (block) timeout = -1; @@ -207,7 +207,7 @@ static bool gfx_ctx_drm_wait_flip(bool block) /* This buffer is not on-screen anymore. Release it to GBM. */ gbm_surface_release_buffer(g_gbm_surface, g_bo); /* This buffer is being shown now. */ - g_bo = g_next_bo; + g_bo = g_next_bo; return false; } @@ -225,7 +225,7 @@ static bool gfx_ctx_drm_queue_flip(void) if (drmModePageFlip(g_drm_fd, g_crtc_id, fb->fb_id, DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip) == 0) return true; - + /* Failed to queue page flip. */ return false; } @@ -248,7 +248,7 @@ static void gfx_ctx_drm_swap_buffers(void *data, void *data2) break; } - /* I guess we have to wait for flip to have taken + /* I guess we have to wait for flip to have taken * place before another flip can be queued up. * * If true, we are still waiting for a flip @@ -263,7 +263,7 @@ static void gfx_ctx_drm_swap_buffers(void *data, void *data2) gbm_surface_has_free_buffers(g_gbm_surface)) return; - gfx_ctx_drm_wait_flip(true); + gfx_ctx_drm_wait_flip(true); } static void gfx_ctx_drm_get_video_size(void *data, @@ -389,7 +389,7 @@ nextgpu: drm_setup(fd); - /* First mode is assumed to be the "optimal" + /* First mode is assumed to be the "optimal" * one for get_video_size() purposes. */ drm->fb_width = g_drm_connector->modes[0].hdisplay; drm->fb_height = g_drm_connector->modes[0].vdisplay; @@ -454,7 +454,7 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( *attr++ = drm->egl.minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if (version >= 3002) { @@ -476,7 +476,7 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( case GFX_CTX_OPENGL_ES_API: #ifdef HAVE_OPENGLES *attr++ = EGL_CONTEXT_CLIENT_VERSION; - *attr++ = drm->egl.major + *attr++ = drm->egl.major ? (EGLint)drm->egl.major : 2; #ifdef EGL_KHR_create_context if (drm->egl.minor > 0) @@ -581,7 +581,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(gfx_ctx_drm_data_t *drm) attr = gfx_ctx_drm_egl_fill_attribs(drm, egl_attribs); egl_attribs_ptr = &egl_attribs[0]; - if (!egl_create_context(&drm->egl, (attr != egl_attribs_ptr) + if (!egl_create_context(&drm->egl, (attr != egl_attribs_ptr) ? egl_attribs_ptr : NULL)) goto error; @@ -622,14 +622,14 @@ static bool gfx_ctx_drm_set_video_mode(void *data, frontend_driver_install_signal_handler(); - /* If we use black frame insertion, - * we fake a 60 Hz monitor for 120 Hz one, + /* If we use black frame insertion, + * we fake a 60 Hz monitor for 120 Hz one, * etc, so try to match that. */ - refresh_mod = video_info->black_frame_insertion + refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; /* Find desired video mode, and use that. - * If not fullscreen, we get desired windowed size, + * If not fullscreen, we get desired windowed size, * which is not appropriate. */ if ((width == 0 && height == 0) || !fullscreen) g_drm_mode = &g_drm_connector->modes[0]; @@ -637,7 +637,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, { /* Try to match refresh_rate as closely as possible. * - * Lower resolutions tend to have multiple supported + * Lower resolutions tend to have multiple supported * refresh rates as well. */ float minimum_fps_diff = 0.0f; @@ -646,7 +646,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, for (i = 0; i < g_drm_connector->count_modes; i++) { float diff; - if (width != g_drm_connector->modes[i].hdisplay || + if (width != g_drm_connector->modes[i].hdisplay || height != g_drm_connector->modes[i].vdisplay) continue; diff --git a/gfx/drivers_context/gdi_ctx.c b/gfx/drivers_context/gdi_ctx.c index 9d1e5980ae..eee7296ad4 100644 --- a/gfx/drivers_context/gdi_ctx.c +++ b/gfx/drivers_context/gdi_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -136,7 +136,7 @@ static void *gfx_ctx_gdi_init( if (g_inited) return NULL; - + win32_window_reset(); win32_monitor_init(); diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index e6bf37c819..1dd79a9b6f 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -64,7 +64,7 @@ static void gfx_ctx_null_destroy(void *data) (void)data; } -static void gfx_ctx_null_input_driver(void *data, +static void gfx_ctx_null_input_driver(void *data, const char *name, const input_driver_t **input, void **input_data) { diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 745d770055..b0dd26cc64 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -103,6 +103,8 @@ static bool gfx_ctx_khr_display_set_resize(void *data, return false; } + vulkan_acquire_next_image(&khr->vk); + khr->vk.context.invalid_swapchain = true; khr->vk.need_new_swapchain = false; return false; @@ -240,7 +242,7 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = { "khr_display", gfx_ctx_khr_display_get_flags, gfx_ctx_khr_display_set_flags, - NULL, + NULL, gfx_ctx_khr_display_get_context_data, NULL }; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index e9b97dbe78..aa7e7395b4 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -168,7 +168,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, close(fd); fd = -1; - + width = vinfo.xres; height = vinfo.yres; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index b50317e200..9ad56bc662 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2014 2015 - Jean-Andre Santoni - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -79,7 +79,7 @@ static void *gfx_ctx_opendingux_init(video_frame_info_t *video_info, void *video if (!viv) return NULL; - + #ifdef HAVE_EGL frontend_driver_install_signal_handler(); diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index e7c48bfdcd..050e241db9 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -102,7 +102,7 @@ static void gfx_ctx_ps3_get_available_resolutions(void) } global->console.screen.resolutions.count = 0; - global->console.screen.resolutions.list = + global->console.screen.resolutions.list = malloc(resolution_count * sizeof(uint32_t)); for (i = 0; i < num_videomodes; i++) @@ -119,20 +119,21 @@ static void gfx_ctx_ps3_get_available_resolutions(void) if (global->console.screen.resolutions.current.id == videomode[i]) { defaultresolution = false; - global->console.screen.resolutions.current.idx = + global->console.screen.resolutions.current.idx = global->console.screen.resolutions.count-1; } } } - /* In case we didn't specify a resolution - + /* In case we didn't specify a resolution - * make the last resolution - that was added to the list (the highest resolution) + that was added to the list (the highest resolution) the default resolution */ - if (global->console.screen.resolutions.current.id > num_videomodes - || defaultresolution) - global->console.screen.resolutions.current.idx = - global->console.screen.resolutions.count - 1; + if (global->console.screen.resolutions.current.id > num_videomodes || defaultresolution) + { + global->console.screen.resolutions.current.idx = resolution_count - 1; + global->console.screen.resolutions.current.id = global->console.screen.resolutions.list[global->console.screen.resolutions.current.idx]; + } global->console.screen.resolutions.check = true; } @@ -194,7 +195,7 @@ static void gfx_ctx_ps3_get_video_size(void *data, #if defined(HAVE_PSGL) if (ps3) - psglGetDeviceDimensions(ps3->gl_device, width, height); + psglGetDeviceDimensions(ps3->gl_device, width, height); #endif } @@ -223,7 +224,7 @@ static void *gfx_ctx_ps3_init(video_frame_info_t *video_info, void *video_driver sys_spu_initialize(6, 1); psglInit(&options); - params.enable = + params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; @@ -264,7 +265,7 @@ static void *gfx_ctx_ps3_init(video_frame_info_t *video_info, void *video_driver psglResetCurrentContext(); #endif - global->console.screen.pal_enable = + global->console.screen.pal_enable = cellVideoOutGetResolutionAvailability( CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 6c9f70df40..4827c7da84 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -114,7 +114,7 @@ static void sdl_ctx_destroy(void *data) if (!sdl) return; - + sdl_ctx_destroy_resources(sdl); free(sdl); } diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 26e1b695f4..62714cf62c 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -110,23 +110,23 @@ static void gfx_ctx_vc_get_video_size(void *data, vc_ctx_data_t *vc = (vc_ctx_data_t*)data; settings_t *settings = config_get_ptr(); - /* Use dispmanx upscaling if + /* Use dispmanx upscaling if * fullscreen_x and fullscreen_y are set. */ if (settings->uints.video_fullscreen_x != 0 && settings->uints.video_fullscreen_y != 0) { /* Keep input and output aspect ratio equal. - * There are other aspect ratio settings + * There are other aspect ratio settings * which can be used to stretch video output. */ /* Calculate source and destination aspect ratios. */ - float srcAspect = (float)settings->uints.video_fullscreen_x + float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y; float dstAspect = (float)vc->fb_width / (float)vc->fb_height; - /* If source and destination aspect ratios + /* If source and destination aspect ratios * are not equal correct source width. */ if (srcAspect != dstAspect) *width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect); @@ -198,7 +198,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) /* If we set this env variable, Broadcom's EGL implementation will block * on vsync with a double buffer when we call eglSwapBuffers. Less input lag! - * Has to be done before any EGL call. + * Has to be done before any EGL call. * NOTE this is commented out because it should be the right way to do it, but * currently it doesn't work, so we are using an vsync callback based solution.*/ /* if (video_info->max_swapchain_images <= 2) @@ -216,7 +216,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) goto error; } - if (!egl_create_context(&vc->egl, (vc_api == GFX_CTX_OPENGL_ES_API) + if (!egl_create_context(&vc->egl, (vc_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL)) { egl_report_error(); @@ -236,7 +236,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) src_rect.x = 0; src_rect.y = 0; - /* Use dispmanx upscaling if fullscreen_x + /* Use dispmanx upscaling if fullscreen_x * and fullscreen_y are set. */ if (settings->uints.video_fullscreen_x != 0 && settings->uints.video_fullscreen_y != 0) @@ -281,11 +281,11 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) settings->uints.video_fullscreen_y != 0) { /* Keep input and output aspect ratio equal. - * There are other aspect ratio settings which + * There are other aspect ratio settings which * can be used to stretch video output. */ /* Calculate source and destination aspect ratios. */ - float srcAspect = (float)settings->uints.video_fullscreen_x + float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y; float dstAspect = (float)vc->fb_width / (float)vc->fb_height; @@ -313,7 +313,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) vc->vsync_condition_mutex = slock_new(); vc->vsync_callback_set = false; if (video_info->max_swapchain_images <= 2) { - /* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */ + /* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */ vc_dispmanx_vsync_callback(vc->dispman_display, dispmanx_vsync_callback, (void*)vc); vc->vsync_callback_set = true; } @@ -525,7 +525,7 @@ static bool gfx_ctx_vc_image_buffer_init(void *data, peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)egl_get_proc_address("eglCreateImageKHR"); peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)egl_get_proc_address("eglDestroyImageKHR"); - if (!peglCreateImageKHR || !peglDestroyImageKHR + if (!peglCreateImageKHR || !peglDestroyImageKHR || !gfx_ctx_vc_egl_query_extension(vc, "KHR_image")) return false; @@ -644,7 +644,7 @@ static void gfx_ctx_vc_swap_buffers(void *data, void *data2) } slock_lock(vc->vsync_condition_mutex); scond_wait(vc->vsync_condition, vc->vsync_condition_mutex); - slock_unlock(vc->vsync_condition_mutex); + slock_unlock(vc->vsync_condition_mutex); } else if (vc->vsync_callback_set) { /* Stop generating vsync callbacks from now on */ diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 17fdf3e19b..10ea704ee6 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011 2017 - Daniel De Matteis * Copyright (C) 2014 2015 - Jean-Andre Santoni - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 6c7b8be4be..29f45c925b 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -68,7 +68,7 @@ typedef struct gfx_ctx_wayland_data struct wl_seat *seat; struct wl_shm *shm; unsigned swap_interval; - bool core_hw_context_enable; + bool core_hw_context_enable; unsigned buffer_scale; @@ -293,7 +293,7 @@ static void pointer_handle_button(void *data, wl->input.mouse.middle = true; } else - { + { if (button == BTN_LEFT) wl->input.mouse.left = false; else if (button == BTN_RIGHT) @@ -645,7 +645,7 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit, { case GFX_CTX_VULKAN_API: #ifdef HAVE_VULKAN - /* Swapchains are recreated in set_resize as a + /* Swapchains are recreated in set_resize as a * central place, so use that to trigger swapchain reinit. */ *resize = wl->vk.need_new_swapchain; #endif @@ -684,7 +684,10 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) wl->height = height; if (vulkan_create_swapchain(&wl->vk, width, height, wl->swap_interval)) + { wl->vk.context.invalid_swapchain = true; + vulkan_acquire_next_image(&wl->vk); + } else { RARCH_ERR("[Wayland/Vulkan]: Failed to update swapchain.\n"); @@ -1130,7 +1133,7 @@ static bool gfx_ctx_wl_set_video_mode(void *data, #ifdef HAVE_VULKAN if (!vulkan_surface_create(&wl->vk, VULKAN_WSI_WAYLAND, - wl->input.dpy, wl->surface, + wl->input.dpy, wl->surface, wl->width, wl->height, wl->swap_interval)) goto error; #endif diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 64c4be8a09..c6179a088f 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -23,10 +23,6 @@ #define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K #endif -#if !defined(_MSC_VER) || _MSC_VER > 1400 -#define UNICODE -#endif - #include #include @@ -163,9 +159,9 @@ static void create_gl_context(HWND hwnd, bool *quit) else { win32_hrc = wglCreateContext(win32_hdc); - + /* We'll create shared context later if not. */ - if (win32_hrc && !core_context && !debug) + if (win32_hrc && !core_context && !debug) { win32_hw_hrc = wglCreateContext(win32_hdc); if (win32_hw_hrc) @@ -207,7 +203,7 @@ static void create_gl_context(HWND hwnd, bool *quit) *aptr++ = win32_minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if ((win32_major * 1000 + win32_minor) >= 3002) @@ -284,7 +280,7 @@ void create_graphics_context(HWND hwnd, bool *quit) height = rect.bottom - rect.top; if (!vulkan_surface_create(&win32_vk, VULKAN_WSI_WIN32, - &instance, &hwnd, + &instance, &hwnd, width, height, win32_interval)) *quit = true; @@ -399,6 +395,7 @@ static bool gfx_ctx_wgl_set_resize(void *data, return false; } + vulkan_acquire_next_image(&win32_vk); win32_vk.context.invalid_swapchain = true; win32_vk.need_new_swapchain = false; #endif @@ -465,7 +462,7 @@ static void *gfx_ctx_wgl_init(video_frame_info_t *video_info, void *video_driver return NULL; dll_handle = dylib_load("OpenGL32.dll"); - + win32_window_reset(); win32_monitor_init(); diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 08e6b7bcef..ca228881ea 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -169,7 +169,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *pos = strstr(extensionsString, extension); - if ( (pos != NULL) && + if ( (pos != NULL) && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -178,7 +178,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) pos = strstr(client_extensions, extension); if ( - (pos != NULL) && + (pos != NULL) && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -227,7 +227,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x) x->g_hw_ctx = NULL; } } - + if (g_x11_win) { if (x->g_glx_win) @@ -290,7 +290,7 @@ static void gfx_ctx_x_destroy(void *data) gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; if (!x) return; - + gfx_ctx_x_destroy_resources(x); switch (x_api) @@ -448,6 +448,7 @@ static bool gfx_ctx_x_set_resize(void *data, return false; } + vulkan_acquire_next_image(&x->vk); x->vk.context.invalid_swapchain = true; x->vk.need_new_swapchain = false; } @@ -622,7 +623,10 @@ static bool gfx_ctx_x_set_video_mode(void *data, int (*old_handler)(Display*, XErrorEvent*) = NULL; gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False); + Atom net_wm_opacity = XInternAtom(g_x11_dpy, "_NET_WM_WINDOW_OPACITY", False); Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); + settings_t *settings = config_get_ptr(); + unsigned opacity = settings->uints.video_window_opacity * ((unsigned)-1 / 100.0); frontend_driver_install_signal_handler(); @@ -705,13 +709,16 @@ static bool gfx_ctx_x_set_video_mode(void *data, g_x11_win = XCreateWindow(g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), x_off, y_off, width, height, 0, - vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | + vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); XChangeProperty(g_x11_dpy, g_x11_win, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char*)retroarch_icon_data, sizeof(retroarch_icon_data) / sizeof(*retroarch_icon_data)); + if (opacity < (unsigned)-1) + XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, 32, PropModeReplace, (const unsigned char*)&opacity, 1); + switch (x_api) { case GFX_CTX_OPENGL_API: @@ -739,13 +746,13 @@ static bool gfx_ctx_x_set_video_mode(void *data, } else if (fullscreen) { - /* We attempted true fullscreen, but failed. + /* We attempted true fullscreen, but failed. * Attempt using windowed fullscreen. */ XMapRaised(g_x11_dpy, g_x11_win); RARCH_LOG("[GLX]: Using windowed fullscreen.\n"); - /* We have to move the window to the screen we want + /* We have to move the window to the screen we want * to go fullscreen on first. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -755,7 +762,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, else { XMapWindow(g_x11_dpy, g_x11_win); - /* If we want to map the window on a different screen, + /* If we want to map the window on a different screen, * we'll have to do it by force. * Otherwise, we should try to let the window manager sort it out. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -787,7 +794,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, if (x->g_core_es_core) { /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending on + * Version 3.1 is either compat or not depending on * GL_ARB_compatibility. */ *aptr++ = GLX_CONTEXT_PROFILE_MASK_ARB; @@ -863,7 +870,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, /* Use XCB surface since it's the most supported WSI. * We can obtain the XCB connection directly from X11. */ if (!vulkan_surface_create(&x->vk, VULKAN_WSI_XCB, - g_x11_dpy, &g_x11_win, + g_x11_dpy, &g_x11_win, width, height, x->g_interval)) goto error; } @@ -922,7 +929,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, gfx_ctx_x_swap_interval(data, x->g_interval); - /* This can blow up on some drivers. + /* This can blow up on some drivers. * It's not fatal, so override errors for this call. */ old_handler = XSetErrorHandler(x_nul_handler); XSetInputFocus(g_x11_dpy, g_x11_win, RevertToNone, CurrentTime); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 351c021215..59d7d65c62 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis -* +* * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -87,7 +87,7 @@ static void gfx_ctx_xegl_destroy(void *data) free(data); - /* Do not close g_x11_dpy. We'll keep one for the entire application + /* Do not close g_x11_dpy. We'll keep one for the entire application * lifecycle to work-around nVidia EGL limitations. */ } @@ -212,7 +212,7 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) *attr++ = xegl->egl.minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if (version >= 3002) @@ -294,7 +294,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, swa.colormap = g_x11_cmap = XCreateColormap( g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), vi->visual, AllocNone); - swa.event_mask = StructureNotifyMask | KeyPressMask | + swa.event_mask = StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask | KeyReleaseMask; swa.override_redirect = fullscreen ? True : False; @@ -337,8 +337,8 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, g_x11_win = XCreateWindow(g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), x_off, y_off, width, height, 0, - vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | + vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); @@ -362,14 +362,14 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, RARCH_LOG("[X/EGL]: Using true fullscreen.\n"); XMapRaised(g_x11_dpy, g_x11_win); } - else if (fullscreen) + else if (fullscreen) { /* We attempted true fullscreen, but failed. * Attempt using windowed fullscreen. */ XMapRaised(g_x11_dpy, g_x11_win); RARCH_LOG("[X/EGL]: Using windowed fullscreen.\n"); - /* We have to move the window to the screen we + /* We have to move the window to the screen we * want to go fullscreen on first. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -380,7 +380,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, { XMapWindow(g_x11_dpy, g_x11_win); - /* If we want to map the window on a different screen, + /* If we want to map the window on a different screen, * we'll have to do it by force. * * Otherwise, we should try to let the window manager sort it out. @@ -397,7 +397,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, gfx_ctx_xegl_set_swap_interval(&xegl->egl, xegl->egl.interval); #endif - /* This can blow up on some drivers. It's not fatal, + /* This can blow up on some drivers. It's not fatal, * so override errors for this call. */ old_handler = XSetErrorHandler(x_nul_handler); @@ -583,7 +583,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = gfx_ctx_xegl_init, gfx_ctx_xegl_destroy, gfx_ctx_xegl_bind_api, - gfx_ctx_xegl_set_swap_interval, + gfx_ctx_xegl_set_swap_interval, gfx_ctx_xegl_set_video_mode, x11_get_video_size, NULL, /* get_video_output_size */ diff --git a/gfx/drivers_font/caca_font.c b/gfx/drivers_font/caca_font.c index 6d6f37196a..0454aa3844 100644 --- a/gfx/drivers_font/caca_font.c +++ b/gfx/drivers_font/caca_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index e78054768b..08d3080ce5 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -262,7 +262,7 @@ static void ctr_font_render_line( GPU_SetViewport(NULL, VIRT_TO_PHYS(ctr->drawbuffers.top.left), 0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, - ctr->video_mode == CTR_VIDEO_MODE_800x240 + ctr->video_mode == CTR_VIDEO_MODE_800x240 ? CTR_TOP_FRAMEBUFFER_WIDTH * 2 : CTR_TOP_FRAMEBUFFER_WIDTH); GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, v - ctr->vertex_cache.current); diff --git a/gfx/drivers_font/d3d_w32_font.c b/gfx/drivers_font/d3d_w32_font.c index 892197f16b..c0c707689e 100644 --- a/gfx/drivers_font/d3d_w32_font.c +++ b/gfx/drivers_font/d3d_w32_font.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/gdi_font.c b/gfx/drivers_font/gdi_font.c index c89eb99df9..133de8af2f 100644 --- a/gfx/drivers_font/gdi_font.c +++ b/gfx/drivers_font/gdi_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -91,6 +91,9 @@ static void gdi_render_msg( const struct font_params *params = (const struct font_params*)userdata; unsigned width = video_info->width; unsigned height = video_info->height; + unsigned red; + unsigned green; + unsigned blue; if (!font || string_is_empty(msg)) return; @@ -101,6 +104,9 @@ static void gdi_render_msg( y = params->y; scale = params->scale; align = params->text_align; + red = FONT_COLOR_GET_RED(params->color); + green = FONT_COLOR_GET_GREEN(params->color); + blue = FONT_COLOR_GET_BLUE(params->color); } else { @@ -108,6 +114,9 @@ static void gdi_render_msg( y = video_info->font_msg_pos_y; scale = 1.0f; align = TEXT_ALIGN_LEFT; + red = video_info->font_msg_color_r * 255.0f; + green = video_info->font_msg_color_g * 255.0f; + blue = video_info->font_msg_color_b * 255.0f; } if (!font->gdi) @@ -135,7 +144,7 @@ static void gdi_render_msg( font->gdi->bmp_old = (HBITMAP)SelectObject(font->gdi->memDC, font->gdi->bmp); SetBkMode(font->gdi->memDC, TRANSPARENT); - SetTextColor(font->gdi->memDC, RGB(255,255,255)); + SetTextColor(font->gdi->memDC, RGB(red, green, blue)); TextOut(font->gdi->memDC, newX, newY, msg, len); SelectObject(font->gdi->memDC, font->gdi->bmp_old); } diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 16a2bbc55f..72d84a3205 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -303,7 +303,7 @@ static void gl_raster_font_render_line( { i = 0; while ((i < MAX_MSG_LEN_CHUNK) && (msg < msg_end)) - { + { int off_x, off_y, tex_x, tex_y, width, height; unsigned code = utf8_walk(&msg); const struct font_glyph *glyph = font->font_driver->get_glyph( @@ -374,7 +374,7 @@ static void gl_raster_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim + unsigned msg_len = delim ? (unsigned)(delim - msg) : (unsigned)strlen(msg); /* Draw the line */ diff --git a/gfx/drivers_font/ps_libdbgfont.c b/gfx/drivers_font/ps_libdbgfont.c index 25268c031e..d98f1d8cd3 100644 --- a/gfx/drivers_font/ps_libdbgfont.c +++ b/gfx/drivers_font/ps_libdbgfont.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -96,7 +96,7 @@ static void libdbg_font_render_msg( DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); #ifdef SN_TARGET_PSP2 - /* FIXME - if we ever get around to this port, + /* FIXME - if we ever get around to this port, * move this out to some better place */ sceDbgFontFlush(); #endif diff --git a/gfx/drivers_font/vga_font.c b/gfx/drivers_font/vga_font.c index 229186e3c7..a217494edc 100644 --- a/gfx/drivers_font/vga_font.c +++ b/gfx/drivers_font/vga_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2016 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c index 7a4777a3eb..f6cdcace8a 100644 --- a/gfx/drivers_font/vita2d_font.c +++ b/gfx/drivers_font/vita2d_font.c @@ -38,14 +38,14 @@ static void *vita2d_font_init_font(void *data, bool is_threaded) { unsigned int stride, pitch, j, k; - const uint8_t *frame32 = NULL; + const uint8_t *frame32 = NULL; uint8_t *tex32 = NULL; const struct font_atlas *atlas = NULL; vita_font_t *font = (vita_font_t*)calloc(1, sizeof(*font)); if (!font) return NULL; - + font->vita = (vita_video_t*)data; if (!font_renderer_create_default((const void**)&font->font_driver, @@ -78,7 +78,7 @@ static void *vita2d_font_init_font(void *data, for (j = 0; j < atlas->height; j++) for (k = 0; k < atlas->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + font->atlas->dirty = false; return font; @@ -169,7 +169,7 @@ static void vita2d_font_render_line( int off_x, off_y, tex_x, tex_y, width, height; unsigned int stride, pitch, j, k; const struct font_glyph *glyph = NULL; - const uint8_t *frame32 = NULL; + const uint8_t *frame32 = NULL; uint8_t *tex32 = NULL; const char *msg_tmp = &msg[i]; unsigned code = utf8_walk(&msg_tmp); @@ -192,7 +192,7 @@ static void vita2d_font_render_line( tex_y = glyph->atlas_offset_y; width = glyph->width; height = glyph->height; - + if (font->atlas->dirty) { stride = vita2d_texture_get_stride(font->texture); @@ -203,7 +203,7 @@ static void vita2d_font_render_line( for (j = 0; j < font->atlas->height; j++) for (k = 0; k < font->atlas->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + font->atlas->dirty = false; } diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index 5897637f12..a562aa33b0 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -1,6 +1,6 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ static void *vulkan_raster_font_init_font(void *data, const char *font_path, float font_size, bool is_threaded) { - vulkan_raster_t *font = + vulkan_raster_t *font = (vulkan_raster_t*)calloc(1, sizeof(*font)); #if 0 @@ -95,7 +95,7 @@ static void vulkan_raster_font_free_font(void *data, bool is_threaded) font->font_driver->free(font->font_data); vkQueueWaitIdle(font->vk->context->queue); - vulkan_destroy_texture( + vulkan_destroy_texture( font->vk->context->device, &font->texture); vulkan_destroy_texture( font->vk->context->device, &font->texture_optimal); @@ -107,11 +107,11 @@ static INLINE void vulkan_raster_font_update_glyph(vulkan_raster_t *font, const { if(font->atlas->dirty) { - int row; - for(row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++) + unsigned row; + for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++) { - uint8_t* src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x; - uint8_t* dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x; + uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x; + uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x; memcpy(dst, src, glyph->width); } @@ -124,7 +124,7 @@ static int vulkan_get_message_width(void *data, const char *msg, unsigned msg_len, float scale) { vulkan_raster_t *font = (vulkan_raster_t*)data; - + unsigned i; int delta_x = 0; @@ -133,7 +133,7 @@ static int vulkan_get_message_width(void *data, const char *msg, for (i = 0; i < msg_len; i++) { - const struct font_glyph *glyph = + const struct font_glyph *glyph = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); if (!glyph) /* Do something smarter here ... */ glyph = font->font_driver->get_glyph(font->font_data, '?'); @@ -272,7 +272,7 @@ static void vulkan_raster_font_render_message( static void vulkan_raster_font_flush(vulkan_raster_t *font) { struct vk_draw_triangles call; - + call.pipeline = font->vk->pipelines.font; call.texture = &font->texture_optimal; call.sampler = font->vk->samplers.mipmap_linear; @@ -407,7 +407,7 @@ static void vulkan_raster_font_render_msg( color_dark[3] = color[3] * drop_alpha; vulkan_raster_font_render_message(font, msg, scale, color_dark, - x + scale * drop_x / vk->vp.width, y + + x + scale * drop_x / vk->vp.width, y + scale * drop_y / vk->vp.height, text_align); } diff --git a/gfx/drivers_font/xdk1_xfonts.c b/gfx/drivers_font/xdk1_xfonts.c index 4e0c808d64..f76883f683 100644 --- a/gfx/drivers_font/xdk1_xfonts.c +++ b/gfx/drivers_font/xdk1_xfonts.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -60,7 +60,7 @@ static void xfonts_free_font(void *data, bool is_threaded) if (font) free(font); - + font = NULL; } diff --git a/gfx/drivers_font_renderer/bitmap.h b/gfx/drivers_font_renderer/bitmap.h index 5a5a4ba82b..8483021532 100644 --- a/gfx/drivers_font_renderer/bitmap.h +++ b/gfx/drivers_font_renderer/bitmap.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font_renderer/bitmapfont.c b/gfx/drivers_font_renderer/bitmapfont.c index b6d289ec03..71a0996420 100644 --- a/gfx/drivers_font_renderer/bitmapfont.c +++ b/gfx/drivers_font_renderer/bitmapfont.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -56,7 +56,7 @@ static void char_to_texture(bm_renderer_t *handle, uint8_t letter, unsigned atlas_x, unsigned atlas_y) { unsigned y, x; - uint8_t *target = handle->atlas.buffer + atlas_x + + uint8_t *target = handle->atlas.buffer + atlas_x + atlas_y * handle->atlas.width; for (y = 0; y < FONT_HEIGHT; y++) @@ -101,9 +101,9 @@ static void *font_renderer_bmp_init(const char *font_path, float font_size) for (i = 0; i < BMP_ATLAS_SIZE; i++) { - unsigned x = (i % BMP_ATLAS_COLS) * + unsigned x = (i % BMP_ATLAS_COLS) * handle->scale_factor * FONT_WIDTH; - unsigned y = (i / BMP_ATLAS_COLS) * + unsigned y = (i / BMP_ATLAS_COLS) * handle->scale_factor * FONT_HEIGHT; char_to_texture(handle, i, x, y); @@ -138,10 +138,10 @@ static const char *font_renderer_bmp_get_default_font(void) static int font_renderer_bmp_get_line_height(void* data) { bm_renderer_t *handle = (bm_renderer_t*)data; - + if (!handle) return FONT_HEIGHT; - + return FONT_HEIGHT * handle->scale_factor; } diff --git a/gfx/drivers_font_renderer/coretext.c b/gfx/drivers_font_renderer/coretext.c index 9205e00f22..33a321b97e 100644 --- a/gfx/drivers_font_renderer/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -124,7 +124,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 kCTFontOrientationDefault, #else - kCTFontDefaultOrientation, + kCTFontDefaultOrientation, #endif glyphs, advances, CT_ATLAS_SIZE); @@ -177,8 +177,8 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer CGContextSetTextMatrix(offscreen, CGAffineTransformIdentity); - attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, - sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, + attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, + sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); for (i = 0; i < CT_ATLAS_SIZE; i++) @@ -208,7 +208,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer glyph_cstr[1] = 0; glyph_cfstr = CFStringCreateWithCString( NULL, glyph_cstr, kCFStringEncodingASCII ); - attrString = + attrString = CFAttributedStringCreate(NULL, glyph_cfstr, attr); CFRelease(glyph_cfstr); glyph_cfstr = NULL; @@ -232,7 +232,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer for (c = 0; c < max_width; c++) { unsigned src_idx = (unsigned)(r * bytesPerRow + c); - unsigned dest_idx = + unsigned dest_idx = (r + offset_y) * (CT_ATLAS_COLS * max_width) + (c + offset_x); uint8_t v = src[src_idx]; diff --git a/gfx/drivers_font_renderer/freetype.c b/gfx/drivers_font_renderer/freetype.c index 966ab74548..d690281e7c 100644 --- a/gfx/drivers_font_renderer/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -22,6 +22,7 @@ #include #include +#include #include #ifdef WIIU @@ -263,7 +264,7 @@ error: return NULL; } -/* Not the cleanest way to do things for sure, +/* Not the cleanest way to do things for sure, * but should hopefully work ... */ static const char *font_paths[] = { @@ -297,7 +298,7 @@ static const char *font_renderer_ft_get_default_font(void) for (i = 0; i < ARRAY_SIZE(font_paths); i++) { - if (path_file_exists(font_paths[i])) + if (filestream_exists(font_paths[i])) return font_paths[i]; } diff --git a/gfx/drivers_font_renderer/stb.c b/gfx/drivers_font_renderer/stb.c index 424e195859..7b7a59163f 100644 --- a/gfx/drivers_font_renderer/stb.c +++ b/gfx/drivers_font_renderer/stb.c @@ -220,7 +220,7 @@ static const char *font_renderer_stb_get_default_font(void) const char **p; for (p = paths; *p; ++p) - if (path_file_exists(*p)) + if (filestream_exists(*p)) return *p; return NULL; diff --git a/gfx/drivers_font_renderer/stb_unicode.c b/gfx/drivers_font_renderer/stb_unicode.c index d22a461f61..5e163e3560 100644 --- a/gfx/drivers_font_renderer/stb_unicode.c +++ b/gfx/drivers_font_renderer/stb_unicode.c @@ -211,7 +211,7 @@ static bool font_renderer_stb_unicode_create_atlas( static void *font_renderer_stb_unicode_init(const char *font_path, float font_size) { int ascent, descent, line_gap; - stb_unicode_font_renderer_t *self = + stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)calloc(1, sizeof(*self)); if (!self || font_size < 1.0) @@ -298,7 +298,7 @@ static const char *font_renderer_stb_unicode_get_default_font(void) const char **p; for (p = paths; *p; ++p) - if (path_file_exists(*p)) + if (filestream_exists(*p)) return *p; return NULL; diff --git a/gfx/drivers_renderchain/d3d8_renderchain.c b/gfx/drivers_renderchain/d3d8_renderchain.c index faef44aee7..3427ce988e 100644 --- a/gfx/drivers_renderchain/d3d8_renderchain.c +++ b/gfx/drivers_renderchain/d3d8_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -78,17 +78,17 @@ static bool d3d8_renderchain_create_first_pass(void *data, LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data; - chain->vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, + chain->vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL); if (!chain->vertex_buf) return false; - chain->tex = d3d_texture_new(d3dr, NULL, + chain->tex = d3d_texture_new(d3dr, NULL, chain->tex_w, chain->tex_h, 1, 0, - info->rgb32 - ? + info->rgb32 + ? #ifdef _XBOX D3DFMT_LIN_X8R8G8B8 : D3DFMT_LIN_R5G6B5, #else @@ -193,7 +193,7 @@ static void d3d8_renderchain_blit_to_texture(void *data, const void *frame, } /* Set the texture to NULL so D3D doesn't complain about it being in use... */ - d3d_set_texture(d3dr, 0, NULL); + d3d_set_texture(d3dr, 0, NULL); d3d_texture_blit(chain->pixel_size, chain->tex, &d3dlr, frame, width, height, pitch); } @@ -249,7 +249,7 @@ static bool d3d8_renderchain_init(void *data, unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; struct video_viewport *custom_vp = video_viewport_get_custom(); (void)final_viewport_data; - + video_driver_get_size(&width, &height); chain->dev = (LPDIRECT3DDEVICE)dev_data; @@ -346,7 +346,7 @@ static void d3d8_renderchain_convert_geometry( (void)width; (void)height; (void)final_viewport_data; - + /* stub */ } @@ -361,7 +361,7 @@ static bool d3d8_renderchain_reinit(void *data, return false; chain->pixel_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); - chain->tex_w = chain->tex_h = RARCH_SCALE_BASE * video->input_scale; + chain->tex_w = chain->tex_h = RARCH_SCALE_BASE * video->input_scale; RARCH_LOG( "Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n", chain->tex_w, chain->tex_h, chain->pixel_size * CHAR_BIT); diff --git a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c index 8d96721d86..b40c011604 100644 --- a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -99,14 +99,14 @@ static bool hlsl_d3d9_renderchain_create_first_pass(void *data, d3d->renderchain_data; chain->vertex_buf = d3d_vertex_buffer_new( - d3dr, 4 * sizeof(Vertex), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, + d3dr, 4 * sizeof(Vertex), + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL); if (!chain->vertex_buf) return false; - chain->tex = d3d_texture_new(d3dr, NULL, + chain->tex = d3d_texture_new(d3dr, NULL, chain->tex_w, chain->tex_h, 1, 0, #ifdef _XBOX info->rgb32 ? D3DFMT_LIN_X8R8G8B8 : D3DFMT_LIN_R5G6B5, @@ -137,7 +137,7 @@ static void hlsl_d3d9_renderchain_set_vertices( video_shader_ctx_info_t shader_info; unsigned width, height; d3d_video_t *d3d = (d3d_video_t*)data; - hlsl_d3d9_renderchain_t *chain = d3d ? + hlsl_d3d9_renderchain_t *chain = d3d ? (hlsl_d3d9_renderchain_t*)d3d->renderchain_data : NULL; video_driver_get_size(&width, &height); @@ -191,7 +191,7 @@ static void hlsl_d3d9_renderchain_set_vertices( d3d_vertex_buffer_unlock(chain->vertex_buf); } - hlsl_d3d9_renderchain_set_mvp(chain, + hlsl_d3d9_renderchain_set_mvp(chain, d3d, width, height, d3d->dev_rotation); shader_info.data = d3d; @@ -236,7 +236,7 @@ static void hlsl_d3d9_renderchain_blit_to_texture( } /* Set the texture to NULL so D3D doesn't complain about it being in use... */ - d3d_set_texture(d3dr, 0, NULL); + d3d_set_texture(d3dr, 0, NULL); d3d_texture_blit(chain->pixel_size, chain->tex, &d3dlr, frame, width, height, pitch); } @@ -269,7 +269,7 @@ static void hlsl_d3d9_renderchain_free(void *data) void *hlsl_d3d9_renderchain_new(void) { - hlsl_d3d9_renderchain_t *renderchain = + hlsl_d3d9_renderchain_t *renderchain = (hlsl_d3d9_renderchain_t*)calloc(1, sizeof(*renderchain)); if (!renderchain) return NULL; @@ -277,7 +277,7 @@ void *hlsl_d3d9_renderchain_new(void) return renderchain; } -static bool hlsl_d3d9_renderchain_init_shader(void *data, +static bool hlsl_d3d9_renderchain_init_shader(void *data, void *renderchain_data) { video_shader_ctx_init_t init; @@ -316,12 +316,12 @@ static bool hlsl_d3d9_renderchain_init(void *data, const LinkInfo *link_info = (const LinkInfo*)info_data; hlsl_d3d9_renderchain_t *chain = (hlsl_d3d9_renderchain_t*) d3d->renderchain_data; - unsigned fmt = (rgb32) + unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; struct video_viewport *custom_vp = video_viewport_get_custom(); (void)final_viewport_data; - + if (!hlsl_d3d9_renderchain_init_shader(d3d, NULL)) return false; @@ -426,7 +426,7 @@ static void hlsl_d3d9_renderchain_convert_geometry( (void)width; (void)height; (void)final_viewport_data; - + /* stub */ } @@ -442,7 +442,7 @@ static bool hlsl_d3d9_renderchain_reinit(void *data, chain->pixel_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); chain->tex_w = RARCH_SCALE_BASE * video->input_scale; - chain->tex_h = RARCH_SCALE_BASE * video->input_scale; + chain->tex_h = RARCH_SCALE_BASE * video->input_scale; RARCH_LOG( "Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n", diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index 04e8fa6199..3eb1f887c7 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -57,14 +57,15 @@ typedef struct gl1_renderchain GLenum min_filter_to_mag(GLenum type); -void gl1_renderchain_free(void *data) +void gl1_renderchain_free(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; - (void)gl; + (void)chain_data; + (void)data; } static void gl1_renderchain_bind_prev_texture( void *data, + void *chain_data, const struct video_tex_info *tex_info) { gl_t *gl = (gl_t*)data; @@ -76,7 +77,8 @@ static void gl1_renderchain_bind_prev_texture( } static void gl1_renderchain_viewport_info( - void *data, struct video_viewport *vp) + void *data, void *chain_data, + struct video_viewport *vp) { unsigned width, height; unsigned top_y, top_dist; @@ -95,7 +97,8 @@ static void gl1_renderchain_viewport_info( } static bool gl1_renderchain_read_viewport( - void *data, uint8_t *buffer, bool is_idle) + void *data, void *chain_data, + uint8_t *buffer, bool is_idle) { unsigned num_pixels = 0; gl_t *gl = (gl_t*)data; @@ -108,14 +111,12 @@ static bool gl1_renderchain_read_viewport( /* Use slow synchronous readbacks. Use this with plain screenshots as we don't really care about performance in this case. */ - /* GLES2 only guarantees GL_RGBA/GL_UNSIGNED_BYTE + /* GL1 only guarantees GL_RGBA/GL_UNSIGNED_BYTE * readbacks so do just that. - * GLES2 also doesn't support reading back data + * GL1 also doesn't support reading back data * from front buffer, so render a cached frame * and have gl_frame() do the readback while it's * in the back buffer. - * - * Keep codepath similar for GLES and desktop GL. */ gl->readback_buffer_screenshot = malloc(num_pixels * sizeof(uint32_t)); @@ -136,9 +137,9 @@ static bool gl1_renderchain_read_viewport( return true; } -void gl1_renderchain_free_internal(void *data) +void gl1_renderchain_free_internal(void *data, void *chain_data) { - gl1_renderchain_t *cg_data = (gl1_renderchain_t*)data; + gl1_renderchain_t *cg_data = (gl1_renderchain_t*)chain_data; if (!cg_data) return; @@ -185,7 +186,8 @@ static void gl1_renderchain_ff_matrix(const void *data) glLoadMatrixf(ident.data); } -static void gl1_renderchain_disable_client_arrays(void) +static void gl1_renderchain_disable_client_arrays(void *data, + void *chain_data) { if (gl_query_core_context_in_use()) return; @@ -198,7 +200,8 @@ static void gl1_renderchain_disable_client_arrays(void) glDisableClientState(GL_TEXTURE_COORD_ARRAY); } -static void gl1_renderchain_restore_default_state(void *data) +static void gl1_renderchain_restore_default_state(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -210,7 +213,8 @@ static void gl1_renderchain_restore_default_state(void *data) } static void gl1_renderchain_copy_frame( - void *data, + void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch) @@ -246,6 +250,7 @@ static void gl1_renderchain_copy_frame( } static void gl1_renderchain_readback(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src) @@ -262,6 +267,7 @@ static void gl1_renderchain_readback(void *data, } static void gl1_renderchain_set_mvp(void *data, + void *chain_data, void *shader_data, const void *mat_data) { math_matrix_4x4 ident; @@ -276,6 +282,7 @@ static void gl1_renderchain_set_mvp(void *data, } static void gl1_renderchain_set_coords(void *handle_data, + void *chain_data, void *shader_data, const struct video_coords *coords) { /* Fall back to fixed function-style if needed and possible. */ @@ -320,10 +327,11 @@ gl_renderchain_driver_t gl2_renderchain = { NULL, /* renderchain_init */ NULL, /* init_hw_render */ gl1_renderchain_free, - NULL, /* deinit_hw_render */ - NULL, /* start_render */ + NULL, /* deinit_hw_render */ + NULL, /* start_render */ NULL, /* check_fbo_dimensions */ NULL, /* recompute_pass_sizes */ - NULL, /* renderchain_render */ + NULL, /* renderchain_render */ + NULL, /* resolve_extensions */ "gl1", }; diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 0c9733e35f..95168fb8aa 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -41,6 +41,7 @@ #include #include +#include #include "../video_driver.h" #include "../video_shader_parse.h" @@ -50,9 +51,44 @@ #include "../../configuration.h" #include "../../verbosity.h" +#define MAX_FENCES 4 + +#if !defined(HAVE_PSGL) + +#ifndef HAVE_GL_SYNC +#define HAVE_GL_SYNC +#endif + +#endif + +#ifdef HAVE_GL_SYNC +#if defined(HAVE_OPENGLES2) +typedef struct __GLsync *GLsync; +#endif +#endif + typedef struct gl2_renderchain { - void *empty; + bool egl_images; + bool has_fp_fbo; + bool has_srgb_fbo_gles3; + bool has_srgb_fbo; + bool hw_render_depth_init; + + int fbo_pass; + + GLuint vao; + GLuint fbo[GFX_MAX_SHADERS]; + GLuint fbo_texture[GFX_MAX_SHADERS]; + GLuint hw_render_depth[GFX_MAX_TEXTURES]; + + unsigned fence_count; + +#ifdef HAVE_GL_SYNC + GLsync fences[MAX_FENCES]; +#endif + + struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; } gl2_renderchain_t; #if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3)) @@ -67,7 +103,45 @@ typedef struct gl2_renderchain coords[5] = yamt; \ coords[7] = yamt -#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) +#if defined(HAVE_PSGL) +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DOES(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatusOES(target) +#define gl2_gen_fb(n, ids) glGenFramebuffersOES(n, ids) +#define gl2_delete_fb(n, fb) glDeleteFramebuffersOES(n, fb) +#define gl2_bind_fb(id) glBindFramebufferOES(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffersOES +#define gl2_bind_rb glBindRenderbufferOES +#define gl2_fb_rb glFramebufferRenderbufferOES +#define gl2_rb_storage glRenderbufferStorageOES +#define gl2_delete_rb glDeleteRenderbuffersOES + +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target) +#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids) +#define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb) +#define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffersEXT +#define gl2_bind_rb glBindRenderbufferEXT +#define gl2_fb_rb glFramebufferRenderbufferEXT +#define gl2_rb_storage glRenderbufferStorageEXT +#define gl2_delete_rb glDeleteRenderbuffersEXT + +#else + +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2D(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatus(target) +#define gl2_gen_fb(n, ids) glGenFramebuffers(n, ids) +#define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb) +#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffers +#define gl2_bind_rb glBindRenderbuffer +#define gl2_fb_rb glFramebufferRenderbuffer +#define gl2_rb_storage glRenderbufferStorage +#define gl2_delete_rb glDeleteRenderbuffers + +#endif + #ifndef GL_SYNC_GPU_COMMANDS_COMPLETE #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 @@ -78,7 +152,8 @@ typedef struct gl2_renderchain #endif /* Prototypes */ -static void gl2_renderchain_bind_backbuffer(void) +static void gl2_renderchain_bind_backbuffer(void *data, + void *chain_data) { #ifdef IOS /* There is no default frame buffer on iOS. */ @@ -102,7 +177,7 @@ void gl_load_texture_data( const void *frame, unsigned base_size); void gl_set_viewport( - void *data, video_frame_info_t *video_info, + void *data, video_frame_info_t *video_info, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate); @@ -123,12 +198,12 @@ static void gl2_renderchain_convert_geometry( break; case RARCH_SCALE_ABSOLUTE: - fbo_rect->img_width = fbo_rect->max_img_width = + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->abs_x; break; case RARCH_SCALE_VIEWPORT: - fbo_rect->img_width = fbo_rect->max_img_width = + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->scale_x * vp_width; break; } @@ -146,7 +221,7 @@ static void gl2_renderchain_convert_geometry( break; case RARCH_SCALE_VIEWPORT: - fbo_rect->img_height = fbo_rect->max_img_height = + fbo_rect->img_height = fbo_rect->max_img_height = fbo_scale->scale_y * vp_height; break; } @@ -169,11 +244,11 @@ static bool gl_recreate_fbo( 0, RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *texture, 0); - if (glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER) + if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) == RARCH_GL_FRAMEBUFFER_COMPLETE) return true; @@ -181,12 +256,15 @@ static bool gl_recreate_fbo( return false; } -static void gl_check_fbo_dimension(gl_t *gl, unsigned i, +static void gl_check_fbo_dimension(gl_t *gl, + void *chain_data, + unsigned i, bool update_feedback) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - /* Check proactively since we might suddently + /* Check proactively since we might suddently * get sizes of tex_w width or tex_h height. */ + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; unsigned img_width = fbo_rect->max_img_width; unsigned img_height = fbo_rect->max_img_height; unsigned max = img_width > img_height ? img_width : img_height; @@ -195,16 +273,16 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, fbo_rect->width = pow2_size; fbo_rect->height = pow2_size; - gl_recreate_fbo(fbo_rect, gl->fbo[i], &gl->fbo_texture[i]); + gl_recreate_fbo(fbo_rect, chain->fbo[i], &chain->fbo_texture[i]); - /* Update feedback texture in-place so we avoid having to + /* Update feedback texture in-place so we avoid having to * juggle two different fbo_rect structs since they get updated here. */ if (update_feedback) { if (gl_recreate_fbo(fbo_rect, gl->fbo_feedback, &gl->fbo_feedback_texture)) { - /* Make sure the feedback textures are cleared + /* Make sure the feedback textures are cleared * so we don't feedback noise. */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -215,32 +293,35 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, i, fbo_rect->width, fbo_rect->height); } -/* On resize, we might have to recreate our FBOs +/* On resize, we might have to recreate our FBOs * due to "Viewport" scale, and set a new viewport. */ -static void gl2_renderchain_check_fbo_dimensions(void *data) +static void gl2_renderchain_check_fbo_dimensions(void *data, + void *chain_data) { int i; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; /* Check if we have to recreate our FBO textures. */ - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; if (fbo_rect) { - bool update_feedback = gl->fbo_feedback_enable + bool update_feedback = gl->fbo_feedback_enable && (unsigned)i == gl->fbo_feedback_pass; if ((fbo_rect->max_img_width > fbo_rect->width) || (fbo_rect->max_img_height > fbo_rect->height)) - gl_check_fbo_dimension(gl, i, update_feedback); + gl_check_fbo_dimension(gl, chain_data, i, update_feedback); } } } static void gl2_renderchain_render( void *data, + void *chain_data, video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, @@ -251,6 +332,7 @@ static void gl2_renderchain_render( video_shader_ctx_params_t params; video_shader_ctx_info_t shader_info; gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; static GLfloat fbo_tex_coords[8] = {0.0f}; struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS]; struct video_tex_info *fbo_info = NULL; @@ -267,7 +349,7 @@ static void gl2_renderchain_render( /* Calculate viewports, texture coordinates etc, * and render all passes from FBOs, to another FBO. */ - for (i = 1; i < gl->fbo_pass; i++) + for (i = 1; i < chain->fbo_pass; i++) { video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; @@ -281,7 +363,7 @@ static void gl2_renderchain_render( set_texture_coords(fbo_tex_coords, xamt, yamt); - fbo_info->tex = gl->fbo_texture[i - 1]; + fbo_info->tex = chain->fbo_texture[i - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; fbo_info->tex_size[0] = prev_rect->width; @@ -289,14 +371,14 @@ static void gl2_renderchain_render( memcpy(fbo_info->coord, fbo_tex_coords, sizeof(fbo_tex_coords)); fbo_tex_info_cnt++; - gl2_bind_fb(gl->fbo[i]); + gl2_bind_fb(chain->fbo[i]); shader_info.data = gl; shader_info.idx = i + 1; shader_info.set_active = true; video_shader_driver_use(shader_info); - glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]); + glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[i - 1]); mip_level = i + 1; @@ -340,21 +422,21 @@ static void gl2_renderchain_render( } #if defined(GL_FRAMEBUFFER_SRGB) && !defined(HAVE_OPENGLES) - if (gl->has_srgb_fbo) + if (chain->has_srgb_fbo) glDisable(GL_FRAMEBUFFER_SRGB); #endif /* Render our last FBO texture directly to screen. */ - prev_rect = &gl->fbo_rect[gl->fbo_pass - 1]; + prev_rect = &gl->fbo_rect[chain->fbo_pass - 1]; xamt = (GLfloat)prev_rect->img_width / prev_rect->width; yamt = (GLfloat)prev_rect->img_height / prev_rect->height; set_texture_coords(fbo_tex_coords, xamt, yamt); /* Push final FBO to list. */ - fbo_info = &fbo_tex_info[gl->fbo_pass - 1]; + fbo_info = &fbo_tex_info[chain->fbo_pass - 1]; - fbo_info->tex = gl->fbo_texture[gl->fbo_pass - 1]; + fbo_info->tex = chain->fbo_texture[chain->fbo_pass - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; fbo_info->tex_size[0] = prev_rect->width; @@ -363,17 +445,17 @@ static void gl2_renderchain_render( fbo_tex_info_cnt++; /* Render our FBO texture to back buffer. */ - gl2_renderchain_bind_backbuffer(); + gl2_renderchain_bind_backbuffer(gl, chain_data); shader_info.data = gl; - shader_info.idx = gl->fbo_pass + 1; + shader_info.idx = chain->fbo_pass + 1; shader_info.set_active = true; video_shader_driver_use(shader_info); - glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]); + glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[chain->fbo_pass - 1]); - mip_level = gl->fbo_pass + 1; + mip_level = chain->fbo_pass + 1; if (video_shader_driver_mipmap_input(&mip_level) && gl->have_mipmap) @@ -416,69 +498,80 @@ static void gl2_renderchain_render( gl->coords.tex_coord = gl->tex_info.coord; } -static void gl2_renderchain_deinit_fbo(void *data) +static void gl2_renderchain_deinit_fbo(void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - glDeleteTextures(gl->fbo_pass, gl->fbo_texture); - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); - memset(gl->fbo_texture, 0, sizeof(gl->fbo_texture)); - memset(gl->fbo, 0, sizeof(gl->fbo)); - gl->fbo_inited = false; - gl->fbo_pass = 0; + if (!gl) + return; + + glDeleteTextures(chain->fbo_pass, chain->fbo_texture); + gl2_delete_fb(chain->fbo_pass, chain->fbo); + + memset(chain->fbo_texture, 0, sizeof(chain->fbo_texture)); + memset(chain->fbo, 0, sizeof(chain->fbo)); if (gl->fbo_feedback) - glDeleteFramebuffers(1, &gl->fbo_feedback); + gl2_delete_fb(1, &gl->fbo_feedback); if (gl->fbo_feedback_texture) glDeleteTextures(1, &gl->fbo_feedback_texture); + chain->fbo_pass = 0; + + gl->fbo_inited = false; gl->fbo_feedback_enable = false; gl->fbo_feedback_pass = 0; gl->fbo_feedback_texture = 0; gl->fbo_feedback = 0; } -static void gl2_renderchain_deinit_hw_render(void *data) +static void gl2_renderchain_deinit_hw_render( + void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (!gl) return; context_bind_hw_render(true); if (gl->hw_render_fbo_init) - glDeleteFramebuffers(gl->textures, gl->hw_render_fbo); - if (gl->hw_render_depth_init) - glDeleteRenderbuffers(gl->textures, gl->hw_render_depth); + gl2_delete_fb(gl->textures, gl->hw_render_fbo); + if (chain->hw_render_depth_init) + gl2_delete_rb(gl->textures, chain->hw_render_depth); gl->hw_render_fbo_init = false; context_bind_hw_render(false); } -void gl2_renderchain_free(void *data) +static void gl2_renderchain_free(void *data, void *chain_data) { gl_t *gl = (gl_t*)data; - gl2_renderchain_deinit_fbo(gl); - gl2_renderchain_deinit_hw_render(gl); + gl2_renderchain_deinit_fbo(gl, chain_data); + gl2_renderchain_deinit_hw_render(gl, chain_data); } -static bool gl_create_fbo_targets(gl_t *gl) +static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) { int i; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, 0); - glGenFramebuffers(gl->fbo_pass, gl->fbo); + gl2_gen_fb(chain->fbo_pass, chain->fbo); - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { GLenum status; - gl2_bind_fb(gl->fbo[i]); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, - RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_texture[i], 0); + gl2_bind_fb(chain->fbo[i]); + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, + RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, chain->fbo_texture[i], 0); - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) goto error; } @@ -487,17 +580,17 @@ static bool gl_create_fbo_targets(gl_t *gl) { GLenum status; - glGenFramebuffers(1, &gl->fbo_feedback); + gl2_gen_fb(1, &gl->fbo_feedback); gl2_bind_fb(gl->fbo_feedback); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_feedback_texture, 0); - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) goto error; - /* Make sure the feedback textures are cleared + /* Make sure the feedback textures are cleared * so we don't feedback noise. */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -506,23 +599,25 @@ static bool gl_create_fbo_targets(gl_t *gl) return true; error: - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + gl2_delete_fb(chain->fbo_pass, chain->fbo); if (gl->fbo_feedback) - glDeleteFramebuffers(1, &gl->fbo_feedback); + gl2_delete_fb(1, &gl->fbo_feedback); RARCH_ERR("[GL]: Failed to set up frame buffer objects. Multi-pass shading will not work.\n"); return false; } -static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) +static void gl_create_fbo_texture(gl_t *gl, + void *chain_data, unsigned i, GLuint texture) { GLenum mag_filter, wrap_enum; video_shader_ctx_filter_t filter_type; video_shader_ctx_wrap_t wrap = {0}; bool fp_fbo = false; bool smooth = false; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; settings_t *settings = config_get_ptr(); GLuint base_filt = settings->bools.video_smooth ? GL_LINEAR : GL_NEAREST; - GLuint base_mip_filt = settings->bools.video_smooth ? + GLuint base_mip_filt = settings->bools.video_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; unsigned mip_level = i + 2; bool mipmapped = video_shader_driver_mipmap_input(&mip_level); @@ -533,7 +628,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) if (video_shader_driver_filter_type(&filter_type)) { - min_filter = mipmapped ? (smooth ? + min_filter = mipmapped ? (smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) : (smooth ? GL_LINEAR : GL_NEAREST); } @@ -547,16 +642,16 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) gl_bind_texture(texture, wrap_enum, mag_filter, min_filter); - fp_fbo = gl->fbo_scale[i].fp_fbo; + fp_fbo = chain->fbo_scale[i].fp_fbo; if (fp_fbo) { - if (!gl->has_fp_fbo) + if (!chain->has_fp_fbo) RARCH_ERR("[GL]: Floating-point FBO was requested, but is not supported. Falling back to UNORM. Result may band/clip/etc.!\n"); } #if !defined(HAVE_OPENGLES2) - if (fp_fbo && gl->has_fp_fbo) + if (fp_fbo && chain->has_fp_fbo) { RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i); gl_load_texture_image(GL_TEXTURE_2D, 0, GL_RGBA32F, @@ -567,27 +662,27 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) #endif { #ifndef HAVE_OPENGLES - bool srgb_fbo = gl->fbo_scale[i].srgb_fbo; - + bool srgb_fbo = chain->fbo_scale[i].srgb_fbo; + if (!fp_fbo && srgb_fbo) { - if (!gl->has_srgb_fbo) + if (!chain->has_srgb_fbo) RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result may have banding!\n"); } - + if (settings->bools.video_force_srgb_disable) srgb_fbo = false; - - if (srgb_fbo && gl->has_srgb_fbo) + + if (srgb_fbo && chain->has_srgb_fbo) { RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i); #ifdef HAVE_OPENGLES2 - /* EXT defines are same as core GLES3 defines, + /* EXT defines are same as core GLES3 defines, * but GLES3 variant requires different arguments. */ glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA_EXT, gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, - gl->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT, + chain->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, NULL); #else gl_load_texture_image(GL_TEXTURE_2D, @@ -605,7 +700,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); #else - /* Avoid potential performance + /* Avoid potential performance * reductions on particular platforms. */ gl_load_texture_image(GL_TEXTURE_2D, 0, RARCH_GL_INTERNAL_FORMAT32, @@ -616,18 +711,22 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) } } -static void gl_create_fbo_textures(gl_t *gl) +static void gl_create_fbo_textures(gl_t *gl, void *chain_data) { int i; - glGenTextures(gl->fbo_pass, gl->fbo_texture); + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - for (i = 0; i < gl->fbo_pass; i++) - gl_create_fbo_texture(gl, i, gl->fbo_texture[i]); + glGenTextures(chain->fbo_pass, chain->fbo_texture); + + for (i = 0; i < chain->fbo_pass; i++) + gl_create_fbo_texture(gl, gl->renderchain_data, + i, chain->fbo_texture[i]); if (gl->fbo_feedback_enable) { glGenTextures(1, &gl->fbo_feedback_texture); gl_create_fbo_texture(gl, + gl->renderchain_data, gl->fbo_feedback_pass, gl->fbo_feedback_texture); } @@ -635,16 +734,18 @@ static void gl_create_fbo_textures(gl_t *gl) } /* Compute FBO geometry. - * When width/height changes or window sizes change, + * When width/height changes or window sizes change, * we have to recalculate geometry of our FBO. */ static void gl2_renderchain_recompute_pass_sizes( void *data, + void *chain_data, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height) { int i; gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; bool size_modified = false; GLint max_size = 0; unsigned last_width = width; @@ -655,10 +756,10 @@ static void gl2_renderchain_recompute_pass_sizes( glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); /* Calculate viewports for FBOs. */ - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; + struct gfx_fbo_scale *fbo_scale = &chain->fbo_scale[i]; gl2_renderchain_convert_geometry( gl, fbo_rect, fbo_scale, @@ -702,10 +803,11 @@ static void gl2_renderchain_recompute_pass_sizes( } static void gl2_renderchain_start_render(void *data, + void *chain_data, video_frame_info_t *video_info) { /* Used when rendering to an FBO. - * Texture coords have to be aligned + * Texture coords have to be aligned * with vertex coordinates. */ static const GLfloat fbo_vertexes[] = { 0, 0, @@ -713,37 +815,40 @@ static void gl2_renderchain_start_render(void *data, 0, 1, 1, 1 }; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); - gl2_bind_fb(gl->fbo[0]); + gl2_bind_fb(chain->fbo[0]); gl_set_viewport(gl, video_info, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true, false); - /* Need to preserve the "flipped" state when in FBO + /* Need to preserve the "flipped" state when in FBO * as well to have consistent texture coordinates. * * We will "flip" it in place on last pass. */ gl->coords.vertex = fbo_vertexes; #if defined(GL_FRAMEBUFFER_SRGB) && !defined(HAVE_OPENGLES) - if (gl->has_srgb_fbo) + if (chain->has_srgb_fbo) glEnable(GL_FRAMEBUFFER_SRGB); #endif } /* Set up render to texture. */ void gl2_renderchain_init( - void *data, unsigned fbo_width, unsigned fbo_height) + void *data, void *chain_data, + unsigned fbo_width, unsigned fbo_height) { int i; unsigned width, height; video_shader_ctx_scale_t scaler; video_shader_ctx_info_t shader_info; struct gfx_fbo_scale scale, scale_last; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (!video_shader_driver_info(&shader_info)) return; @@ -773,40 +878,41 @@ void gl2_renderchain_init( return; } - gl->fbo_pass = shader_info.num - 1; + chain->fbo_pass = shader_info.num - 1; if (scale_last.valid) - gl->fbo_pass++; + chain->fbo_pass++; if (!scale.valid) { scale.scale_x = 1.0f; - scale.scale_y = 1.0f; + scale.scale_y = 1.0f; scale.type_x = scale.type_y = RARCH_SCALE_INPUT; scale.valid = true; } - gl->fbo_scale[0] = scale; + chain->fbo_scale[0] = scale; - for (i = 1; i < gl->fbo_pass; i++) + for (i = 1; i < chain->fbo_pass; i++) { scaler.idx = i + 1; - scaler.scale = &gl->fbo_scale[i]; + scaler.scale = &chain->fbo_scale[i]; video_shader_driver_scale(&scaler); - if (!gl->fbo_scale[i].valid) + if (!chain->fbo_scale[i].valid) { - gl->fbo_scale[i].scale_x = gl->fbo_scale[i].scale_y = 1.0f; - gl->fbo_scale[i].type_x = gl->fbo_scale[i].type_y = + chain->fbo_scale[i].scale_x = chain->fbo_scale[i].scale_y = 1.0f; + chain->fbo_scale[i].type_x = chain->fbo_scale[i].type_y = RARCH_SCALE_INPUT; - gl->fbo_scale[i].valid = true; + chain->fbo_scale[i].valid = true; } } gl2_renderchain_recompute_pass_sizes(gl, + chain_data, fbo_width, fbo_height, width, height); - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { gl->fbo_rect[i].width = next_pow2(gl->fbo_rect[i].img_width); gl->fbo_rect[i].height = next_pow2(gl->fbo_rect[i].img_height); @@ -817,8 +923,8 @@ void gl2_renderchain_init( gl->fbo_feedback_enable = video_shader_driver_get_feedback_pass( &gl->fbo_feedback_pass); - if (gl->fbo_feedback_enable && gl->fbo_feedback_pass - < (unsigned)gl->fbo_pass) + if (gl->fbo_feedback_enable && gl->fbo_feedback_pass + < (unsigned)chain->fbo_pass) { RARCH_LOG("[GL]: Creating feedback FBO %d @ %ux%u\n", i, gl->fbo_rect[gl->fbo_feedback_pass].width, @@ -827,14 +933,14 @@ void gl2_renderchain_init( else if (gl->fbo_feedback_enable) { RARCH_WARN("[GL]: Tried to create feedback FBO of pass #%u, but there are only %d FBO passes. Will use input texture as feedback texture.\n", - gl->fbo_feedback_pass, gl->fbo_pass); + gl->fbo_feedback_pass, chain->fbo_pass); gl->fbo_feedback_enable = false; } - gl_create_fbo_textures(gl); - if (!gl || !gl_create_fbo_targets(gl)) + gl_create_fbo_textures(gl, chain); + if (!gl || !gl_create_fbo_targets(gl, chain)) { - glDeleteTextures(gl->fbo_pass, gl->fbo_texture); + glDeleteTextures(chain->fbo_pass, chain->fbo_texture); RARCH_ERR("[GL]: Failed to create FBO targets. Will continue without FBO.\n"); return; } @@ -844,6 +950,7 @@ void gl2_renderchain_init( static bool gl2_renderchain_init_hw_render( void *data, + void *chain_data, unsigned width, unsigned height) { GLenum status; @@ -855,6 +962,7 @@ static bool gl2_renderchain_init_hw_render( struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; /* We can only share texture objects through contexts. * FBOs are "abstract" objects and are not shared. */ @@ -872,58 +980,62 @@ static bool gl2_renderchain_init_hw_render( RARCH_LOG("[GL]: Supports FBO (render-to-texture).\n"); glBindTexture(GL_TEXTURE_2D, 0); - glGenFramebuffers(gl->textures, gl->hw_render_fbo); + gl2_gen_fb(gl->textures, gl->hw_render_fbo); depth = hwr->depth; stencil = hwr->stencil; if (depth) { - glGenRenderbuffers(gl->textures, gl->hw_render_depth); - gl->hw_render_depth_init = true; + gl2_gen_rb(gl->textures, chain->hw_render_depth); + chain->hw_render_depth_init = true; } for (i = 0; i < gl->textures; i++) { gl2_bind_fb(gl->hw_render_fbo[i]); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->texture[i], 0); if (depth) { - glBindRenderbuffer(RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); - glRenderbufferStorage(RARCH_GL_RENDERBUFFER, + gl2_bind_rb(RARCH_GL_RENDERBUFFER, chain->hw_render_depth[i]); + gl2_rb_storage(RARCH_GL_RENDERBUFFER, stencil ? RARCH_GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16, width, height); - glBindRenderbuffer(RARCH_GL_RENDERBUFFER, 0); + gl2_bind_rb(RARCH_GL_RENDERBUFFER, 0); if (stencil) { #if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES1) || ((defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))) /* GLES2 is a bit weird, as always. * There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */ - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_STENCIL_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); #else /* We use ARB FBO extensions, no need to check. */ - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); #endif } else { - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); } } - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) { RARCH_ERR("[GL]: Failed to create HW render FBO #%u, error: 0x%u.\n", @@ -932,7 +1044,7 @@ static bool gl2_renderchain_init_hw_render( } } - gl2_renderchain_bind_backbuffer(); + gl2_renderchain_bind_backbuffer(gl, chain_data); gl->hw_render_fbo_init = true; context_bind_hw_render(false); @@ -941,30 +1053,33 @@ static bool gl2_renderchain_init_hw_render( static void gl2_renderchain_bind_prev_texture( void *data, + void *chain_data, const struct video_tex_info *tex_info) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; memmove(gl->prev_info + 1, gl->prev_info, sizeof(*tex_info) * (gl->textures - 1)); memcpy(&gl->prev_info[0], tex_info, sizeof(*tex_info)); - /* Implement feedback by swapping out FBO/textures + /* Implement feedback by swapping out FBO/textures * for FBO pass #N and feedbacks. */ if (gl->fbo_feedback_enable) { GLuint tmp_fbo = gl->fbo_feedback; GLuint tmp_tex = gl->fbo_feedback_texture; - gl->fbo_feedback = gl->fbo[gl->fbo_feedback_pass]; - gl->fbo_feedback_texture = gl->fbo_texture[gl->fbo_feedback_pass]; - gl->fbo[gl->fbo_feedback_pass] = tmp_fbo; - gl->fbo_texture[gl->fbo_feedback_pass] = tmp_tex; + gl->fbo_feedback = chain->fbo[gl->fbo_feedback_pass]; + gl->fbo_feedback_texture = chain->fbo_texture[gl->fbo_feedback_pass]; + chain->fbo[gl->fbo_feedback_pass] = tmp_fbo; + chain->fbo_texture[gl->fbo_feedback_pass] = tmp_tex; } } static void gl2_renderchain_viewport_info( - void *data, struct video_viewport *vp) + void *data, void *chain_data, + struct video_viewport *vp) { unsigned width, height; unsigned top_y, top_dist; @@ -983,7 +1098,9 @@ static void gl2_renderchain_viewport_info( } static bool gl2_renderchain_read_viewport( - void *data, uint8_t *buffer, bool is_idle) + void *data, + void *chain_data, + uint8_t *buffer, bool is_idle) { unsigned num_pixels = 0; gl_t *gl = (gl_t*)data; @@ -1043,7 +1160,7 @@ static bool gl2_renderchain_read_viewport( glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } - else + else #endif { /* Use slow synchronous readbacks. Use this with plain screenshots @@ -1084,14 +1201,14 @@ error: return false; } -void gl2_renderchain_free_internal(void *data) +void gl2_renderchain_free_internal(void *data, void *chain_data) { - gl2_renderchain_t *cg_data = (gl2_renderchain_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - if (!cg_data) + if (!chain) return; - free(cg_data); + free(chain); } static void *gl2_renderchain_new(void) @@ -1104,40 +1221,43 @@ static void *gl2_renderchain_new(void) } #ifndef HAVE_OPENGLES -static void gl2_renderchain_bind_vao(void *data) +static void gl2_renderchain_bind_vao(void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glBindVertexArray(gl->vao); + glBindVertexArray(chain->vao); } -static void gl2_renderchain_unbind_vao(void *data) +static void gl2_renderchain_unbind_vao(void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) - return; glBindVertexArray(0); } -static void gl2_renderchain_new_vao(void *data) +static void gl2_renderchain_new_vao(void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glGenVertexArrays(1, &gl->vao); + glGenVertexArrays(1, &chain->vao); } -static void gl2_renderchain_free_vao(void *data) +static void gl2_renderchain_free_vao(void *data, + void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glDeleteVertexArrays(1, &gl->vao); + glDeleteVertexArrays(1, &chain->vao); } #endif -static void gl2_renderchain_restore_default_state(void *data) +static void gl2_renderchain_restore_default_state( + void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1152,12 +1272,17 @@ static void gl2_renderchain_restore_default_state(void *data) } static void gl2_renderchain_copy_frame( - void *data, + void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + + (void)chain; + #if defined(HAVE_PSGL) { unsigned h; @@ -1176,7 +1301,7 @@ static void gl2_renderchain_copy_frame( } #elif defined(HAVE_OPENGLES) #if defined(HAVE_EGL) - if (gl->egl_images) + if (chain->egl_images) { gfx_ctx_image_t img_info; bool new_egl = false; @@ -1190,7 +1315,7 @@ static void gl2_renderchain_copy_frame( img_info.rgb32 = (gl->base_size == 4); img_info.handle = &img; - new_egl = + new_egl = video_context_driver_write_to_image_buffer(&img_info); if (img == EGL_NO_IMAGE_KHR) @@ -1295,7 +1420,8 @@ static void gl2_renderchain_bind_pbo(unsigned idx) glBindBuffer(GL_PIXEL_PACK_BUFFER, (GLuint)idx); } -static void gl2_renderchain_unbind_pbo(void) +static void gl2_renderchain_unbind_pbo(void *data, + void *chain_data) { glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } @@ -1309,6 +1435,7 @@ static void gl2_renderchain_init_pbo(unsigned size, #endif static void gl2_renderchain_readback(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src) @@ -1327,47 +1454,58 @@ static void gl2_renderchain_readback(void *data, } #ifndef HAVE_OPENGLES -static void gl2_renderchain_fence_iterate(void *data, unsigned - hard_sync_frames) +static void gl2_renderchain_fence_iterate( + void *data, + void *chain_data, + unsigned hard_sync_frames) { - gl_t *gl = (gl_t*)data; +#ifdef HAVE_GL_SYNC + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - gl->fences[gl->fence_count++] = + chain->fences[chain->fence_count++] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - while (gl->fence_count > hard_sync_frames) + while (chain->fence_count > hard_sync_frames) { - glClientWaitSync(gl->fences[0], + glClientWaitSync(chain->fences[0], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); - glDeleteSync(gl->fences[0]); + glDeleteSync(chain->fences[0]); - gl->fence_count--; - memmove(gl->fences, gl->fences + 1, - gl->fence_count * sizeof(GLsync)); + chain->fence_count--; + memmove(chain->fences, chain->fences + 1, + chain->fence_count * sizeof(void*)); } +#endif } -static void gl2_renderchain_fence_free(void *data) +static void gl2_renderchain_fence_free(void *data, + void *chain_data) { +#ifdef HAVE_GL_SYNC unsigned i; - gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - for (i = 0; i < gl->fence_count; i++) + for (i = 0; i < chain->fence_count; i++) { - glClientWaitSync(gl->fences[i], + glClientWaitSync(chain->fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); - glDeleteSync(gl->fences[i]); + glDeleteSync(chain->fences[i]); } - gl->fence_count = 0; + chain->fence_count = 0; +#endif } #endif static void gl2_renderchain_init_textures_reference( - void *data, unsigned i, + void *data, void *chain_data, unsigned i, unsigned internal_fmt, unsigned texture_fmt, unsigned texture_type) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + + (void)chain; + #ifdef HAVE_PSGL glTextureReferenceSCE(GL_TEXTURE_2D, 1, gl->tex_w, gl->tex_h, 0, @@ -1375,7 +1513,7 @@ static void gl2_renderchain_init_textures_reference( gl->tex_w * gl->base_size, gl->tex_w * gl->tex_h * i * gl->base_size); #else - if (gl->egl_images) + if (chain->egl_images) return; gl_load_texture_image(GL_TEXTURE_2D, @@ -1388,6 +1526,30 @@ static void gl2_renderchain_init_textures_reference( #endif } +static void gl2_renderchain_resolve_extensions(void *data, + void *chain_data, const char *context_ident, + const video_info_t *video) +{ + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + settings_t *settings = config_get_ptr(); + + if (!chain) + return; + + chain->has_srgb_fbo = false; + chain->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO); + /* GLES3 has unpack_subimage and sRGB in core. */ + chain->has_srgb_fbo_gles3 = gl_check_capability(GL_CAPS_SRGB_FBO_ES3); + + if (!settings->bools.video_force_srgb_disable) + chain->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); + + /* Use regular textures if we use HW render. */ + chain->egl_images = !gl->hw_render_use && gl_check_capability(GL_CAPS_EGLIMAGE) && + video_context_driver_init_image_buffer(video); +} + gl_renderchain_driver_t gl2_renderchain = { NULL, /* set_coords */ NULL, /* set_mvp */ @@ -1440,5 +1602,6 @@ gl_renderchain_driver_t gl2_renderchain = { gl2_renderchain_check_fbo_dimensions, gl2_renderchain_recompute_pass_sizes, gl2_renderchain_render, + gl2_renderchain_resolve_extensions, "gl2", }; diff --git a/gfx/drivers_renderchain/null_renderchain.c b/gfx/drivers_renderchain/null_renderchain.c index a3ed173615..c017cb9876 100644 --- a/gfx/drivers_renderchain/null_renderchain.c +++ b/gfx/drivers_renderchain/null_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index e37b40352c..34bb362d9c 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -294,7 +294,7 @@ static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct } static void gl_cg_set_texture_info( - cg_shader_data_t *cg, + cg_shader_data_t *cg, const struct cg_fbo_params *params, const struct video_tex_info *info) { @@ -316,7 +316,7 @@ static void gl_cg_set_texture_info( } static void gl_cg_set_params(void *data, void *shader_data, - unsigned width, unsigned height, + unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, @@ -717,7 +717,7 @@ static bool gl_cg_load_imports(void *data) core_get_memory(&mem_info); - if ((memtype != -1u) && + if ((memtype != -1u) && (cg->shader->variable[i].addr >= mem_info.size)) { RARCH_ERR("Address out of bounds.\n"); @@ -744,7 +744,7 @@ static bool gl_cg_load_imports(void *data) tracker_info.script_is_file = true; } - tracker_info.script_class = + tracker_info.script_class = *cg->shader->script_class ? cg->shader->script_class : NULL; #endif @@ -1019,7 +1019,7 @@ static void gl_cg_set_program_attributes(void *data, unsigned i) attr_buf_tex[0] = attr_buf_vid_size[0] = attr_buf_tex_size[0] = attr_buf_coord[0] = '\0'; - snprintf(attr_buf_tex, sizeof(attr_buf_tex), + snprintf(attr_buf_tex, sizeof(attr_buf_tex), "%s.texture", prev_names[j]); snprintf(attr_buf_vid_size, sizeof(attr_buf_vid_size), "%s.video_size", prev_names[j]); @@ -1031,14 +1031,14 @@ static void gl_cg_set_program_attributes(void *data, unsigned i) cg->prg[i].prev[j].tex = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_tex); - cg->prg[i].prev[j].vid_size_v = + cg->prg[i].prev[j].vid_size_v = cgGetNamedParameter(cg->prg[i].vprg, attr_buf_vid_size); - cg->prg[i].prev[j].vid_size_f = + cg->prg[i].prev[j].vid_size_f = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_vid_size); - cg->prg[i].prev[j].tex_size_v = + cg->prg[i].prev[j].tex_size_v = cgGetNamedParameter(cg->prg[i].vprg, attr_buf_tex_size); - cg->prg[i].prev[j].tex_size_f = + cg->prg[i].prev[j].tex_size_f = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_tex_size); cg->prg[i].prev[j].coord = cgGetNamedParameter(cg->prg[i].vprg, @@ -1109,7 +1109,7 @@ static void *gl_cg_init(void *data, const char *path) memset(cg->alias_define, 0, sizeof(cg->alias_define)); - if ( !string_is_empty(path) + if ( !string_is_empty(path) && string_is_equal_fast(path_get_extension(path), "cgp", 3)) { if (!gl_cg_load_preset(cg, path)) @@ -1126,12 +1126,12 @@ static void *gl_cg_init(void *data, const char *path) for (i = 1; i <= cg->shader->passes; i++) gl_cg_set_program_attributes(cg, i); - /* If we aren't using last pass non-FBO shader, + /* If we aren't using last pass non-FBO shader, * this shader will be assumed to be "fixed-function". * * Just use prg[0] for that pass, which will be * pass-through. */ - cg->prg[cg->shader->passes + 1] = cg->prg[0]; + cg->prg[cg->shader->passes + 1] = cg->prg[0]; /* No need to apply Android hack in Cg. */ cg->prg[VIDEO_SHADER_STOCK_BLEND] = cg->prg[0]; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index f2e0d9feb7..dc5b96528d 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -129,6 +129,7 @@ static const char *glsl_prefixes[] = { #include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h" #include "../drivers/gl_shaders/pipeline_bokeh.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_snowflake.glsl.frag.h" #endif typedef struct glsl_shader_data @@ -524,7 +525,7 @@ static bool gl_glsl_compile_programs( * load the file here, and pretend * we were really using XML all along. */ - if ( !string_is_empty(pass->source.path) + if ( !string_is_empty(pass->source.path) && !gl_glsl_load_source_path(pass, pass->source.path)) { RARCH_ERR("Failed to load GLSL shader: %s.\n", @@ -736,7 +737,7 @@ static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl) return; glsl->current_idx = 0; - + glUseProgram(0); for (i = 0; i < GFX_MAX_SHADERS; i++) @@ -1095,6 +1096,21 @@ static void *gl_glsl_init(void *data, const char *path) &shader_prog_info); gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_5].id, &glsl->uniforms[VIDEO_SHADER_MENU_5]); + +#if defined(HAVE_OPENGLES) + shader_prog_info.vertex = stock_vertex_xmb_snow_modern; +#else + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; +#endif + shader_prog_info.fragment = stock_fragment_xmb_snowflake; + + gl_glsl_compile_program( + glsl, + VIDEO_SHADER_MENU_6, + &glsl->prg[VIDEO_SHADER_MENU_6], + &shader_prog_info); + gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_6].id, + &glsl->uniforms[VIDEO_SHADER_MENU_6]); #endif gl_glsl_reset_attrib(glsl); @@ -1449,8 +1465,8 @@ static bool gl_glsl_set_mvp(void *data, void *shader_data, const void *mat_data) { const math_matrix_4x4 *mat = (const math_matrix_4x4*)mat_data; - if ( (glsl->current_idx != glsl->active_idx) || - (mat->data != glsl->current_mat_data_pointer[glsl->active_idx]) || + if ( (glsl->current_idx != glsl->active_idx) || + (mat->data != glsl->current_mat_data_pointer[glsl->active_idx]) || (*mat->data != glsl->current_mat_data[glsl->active_idx])) { glUniformMatrix4fv(loc, 1, GL_FALSE, mat->data); @@ -1481,7 +1497,7 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, size_t size = 0; GLfloat *buffer = short_buffer; glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data; - const struct shader_uniforms *uni = glsl + const struct shader_uniforms *uni = glsl ? &glsl->uniforms[glsl->active_idx] : NULL; if (!glsl || !glsl->shader->modern || !coords) diff --git a/gfx/drivers_shader/shader_glsl.h b/gfx/drivers_shader/shader_glsl.h index 7f77693a59..311bccdc95 100644 --- a/gfx/drivers_shader/shader_glsl.h +++ b/gfx/drivers_shader/shader_glsl.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index 9ffedf5ef1..afc79cf913 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -35,7 +35,7 @@ #include "../drivers/d3d_shaders/opaque.hlsl.d3d9.h" #include "shader_hlsl.h" -struct shader_program_hlsl_data +struct shader_program_hlsl_data { LPDIRECT3DVERTEXSHADER vprg; LPDIRECT3DPIXELSHADER fprg; @@ -188,9 +188,9 @@ static bool hlsl_compile_program( if (program_info->is_file) { ret_fp = D3DXCompileShaderFromFile(program_info->combined, NULL, NULL, - "main_fragment", "ps_3_0", 0, &code_f, &listing_f, &program->f_ctable); + "main_fragment", "ps_3_0", 0, &code_f, &listing_f, &program->f_ctable); ret_vp = D3DXCompileShaderFromFile(program_info->combined, NULL, NULL, - "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &program->v_ctable); + "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &program->v_ctable); } else { diff --git a/gfx/drivers_shader/shader_hlsl.h b/gfx/drivers_shader/shader_hlsl.h index 77bbe3c599..b5be3eb16f 100644 --- a/gfx/drivers_shader/shader_hlsl.h +++ b/gfx/drivers_shader/shader_hlsl.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_null.c b/gfx/drivers_shader/shader_null.c index 8ee92bff40..d85cfd1b97 100644 --- a/gfx/drivers_shader/shader_null.c +++ b/gfx/drivers_shader/shader_null.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_vulkan.h b/gfx/drivers_shader/shader_vulkan.h index 26c373023e..79ac7f2d8f 100644 --- a/gfx/drivers_shader/shader_vulkan.h +++ b/gfx/drivers_shader/shader_vulkan.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2016 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -65,7 +65,7 @@ enum vulkan_filter_chain_scale struct vulkan_filter_chain_pass_info { - /* For the last pass, make sure VIEWPORT scale + /* For the last pass, make sure VIEWPORT scale * with scale factors of 1 are used. */ enum vulkan_filter_chain_scale scale_type_x; enum vulkan_filter_chain_scale scale_type_y; diff --git a/gfx/drivers_shader/slang_preprocess.h b/gfx/drivers_shader/slang_preprocess.h index e889f31947..d2c94de12d 100644 --- a/gfx/drivers_shader/slang_preprocess.h +++ b/gfx/drivers_shader/slang_preprocess.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2017 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_tracker/video_state_python.h b/gfx/drivers_tracker/video_state_python.h index 4abdb929f2..3addbc790c 100644 --- a/gfx/drivers_tracker/video_state_python.h +++ b/gfx/drivers_tracker/video_state_python.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -30,7 +30,7 @@ py_state_t *py_state_new(const char *program, void py_state_free(py_state_t *handle); -float py_state_get(py_state_t *handle, +float py_state_get(py_state_t *handle, const char *id, unsigned frame_count); #endif diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 1390412f68..61969afe56 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -51,7 +51,7 @@ int font_renderer_create_default(const void **data, void **handle, { unsigned i; - const font_renderer_driver_t **drv = + const font_renderer_driver_t **drv = (const font_renderer_driver_t**)data; for (i = 0; font_backends[i]; i++) @@ -502,8 +502,8 @@ font_data_t *font_driver_init_first( bool ok = false; #ifdef HAVE_THREADS - if ( threading_hint - && is_threaded + if ( threading_hint + && is_threaded && !video_driver_is_hw_context()) ok = video_thread_font_init(&font_driver, &font_handle, video_data, font_path, font_size, api, font_init_first, @@ -528,7 +528,7 @@ font_data_t *font_driver_init_first( void font_driver_init_osd( void *video_data, - bool threading_hint, + bool threading_hint, bool is_threaded, enum font_driver_render_api api) { diff --git a/gfx/font_driver.h b/gfx/font_driver.h index eaa3ef6a85..2656d358c6 100644 --- a/gfx/font_driver.h +++ b/gfx/font_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -49,10 +49,10 @@ enum text_alignment /* All coordinates and offsets are top-left oriented. * - * This is a texture-atlas approach which allows text to + * This is a texture-atlas approach which allows text to * be drawn in a single draw call. * - * It is up to the code using this interface to actually + * It is up to the code using this interface to actually * generate proper vertex buffers and upload the atlas texture to GPU. */ struct font_glyph @@ -64,7 +64,7 @@ struct font_glyph unsigned atlas_offset_x; unsigned atlas_offset_y; - /* When drawing this glyph, apply an offset to + /* When drawing this glyph, apply an offset to * current X/Y draw coordinate. */ int draw_offset_x; int draw_offset_y; @@ -115,7 +115,7 @@ typedef struct font_renderer void (*bind_block)(void *data, void *block); void (*flush)(unsigned width, unsigned height, void *data, video_frame_info_t *video_info); - + int (*get_message_width)(void *data, const char *msg, unsigned msg_len_full, float scale); } font_renderer_t; @@ -133,7 +133,7 @@ typedef struct font_renderer_driver const char *(*get_default_font)(void); const char *ident; - + int (*get_line_height)(void* data); } font_renderer_driver_t; @@ -147,7 +147,7 @@ typedef struct /* font_path can be NULL for default font. */ int font_renderer_create_default(const void **driver, void **handle, const char *font_path, unsigned font_size); - + void font_driver_render_msg(video_frame_info_t *video_info, void *font_data, const char *msg, const void *params); diff --git a/gfx/include/GL/glext.h b/gfx/include/GL/glext.h index 44ab7c62e1..a0d2948292 100644 --- a/gfx/include/GL/glext.h +++ b/gfx/include/GL/glext.h @@ -7,7 +7,7 @@ extern "C" { /* ** Copyright (c) 2007-2012 The Khronos Group Inc. -** +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -15,10 +15,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -6220,8 +6220,8 @@ typedef uint64_t GLuint64EXT; #ifndef GL_ARB_sync typedef int64_t GLint64; typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; #endif +typedef struct __GLsync *GLsync; #ifndef GL_ARB_cl_event /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ diff --git a/gfx/include/d3d8/d3d8.h b/gfx/include/d3d8/d3d8.h index 2600282c16..adf91ebf0b 100644 --- a/gfx/include/d3d8/d3d8.h +++ b/gfx/include/d3d8/d3d8.h @@ -1,1279 +1,1279 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d8.h - * Content: Direct3D include file - * - ****************************************************************************/ - -#ifndef _D3D8_H_ -#define _D3D8_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0800 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX8 interfaces -#if(DIRECT3D_VERSION >= 0x0800) - - -/* This identifier is passed to Direct3DCreate8 in order to ensure that an - * application was built against the correct header files. This number is - * incremented whenever a header (or other) change would require applications - * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. - * (The number itself has no meaning.)*/ - -#define D3D_SDK_VERSION 220 - - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); -#endif - -#define D3DAPI WINAPI - -/* - * Interface IID's - */ -#if defined( _WIN32 ) && !defined( _NO_COM) - -/* IID_IDirect3D8 */ -/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ -DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); - -/* IID_IDirect3DDevice8 */ -/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ -DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); - -/* IID_IDirect3DResource8 */ -/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ -DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); - -/* IID_IDirect3DBaseTexture8 */ -/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ -DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); - -/* IID_IDirect3DTexture8 */ -/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ -DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); - -/* IID_IDirect3DCubeTexture8 */ -/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ -DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); - -/* IID_IDirect3DVolumeTexture8 */ -/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ -DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); - -/* IID_IDirect3DVertexBuffer8 */ -/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ -DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); - -/* IID_IDirect3DIndexBuffer8 */ -/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ -DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); - -/* IID_IDirect3DSurface8 */ -/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ -DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); - -/* IID_IDirect3DVolume8 */ -/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ -DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); - -/* IID_IDirect3DSwapChain8 */ -/* {928C088B-76B9-4C6B-A536-A590853876CD} */ -DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); - -#endif - -#ifdef __cplusplus - -interface IDirect3D8; -interface IDirect3DDevice8; - -interface IDirect3DResource8; -interface IDirect3DBaseTexture8; -interface IDirect3DTexture8; -interface IDirect3DVolumeTexture8; -interface IDirect3DCubeTexture8; - -interface IDirect3DVertexBuffer8; -interface IDirect3DIndexBuffer8; - -interface IDirect3DSurface8; -interface IDirect3DVolume8; - -interface IDirect3DSwapChain8; - -#endif - - -typedef interface IDirect3D8 IDirect3D8; -typedef interface IDirect3DDevice8 IDirect3DDevice8; -typedef interface IDirect3DResource8 IDirect3DResource8; -typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; -typedef interface IDirect3DTexture8 IDirect3DTexture8; -typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; -typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; -typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; -typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; -typedef interface IDirect3DSurface8 IDirect3DSurface8; -typedef interface IDirect3DVolume8 IDirect3DVolume8; -typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; - -#include "d3d8types.h" -#include "d3d8caps.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * DLL Function for creating a Direct3D8 object. This object supports - * enumeration and allows the creation of Direct3DDevice8 objects. - * Pass the value of the constant D3D_SDK_VERSION to this function, so - * that the run-time can validate that your application was compiled - * against the right headers. - */ - -IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); - - -/* - * Direct3D interfaces - */ - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3D8 - -DECLARE_INTERFACE_(IDirect3D8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D8 methods ***/ - STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; - STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; - STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; - STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; - STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; - STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; - STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; - STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; - STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; - STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; -}; - -typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) -#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) -#else -#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D8_AddRef(p) (p)->AddRef() -#define IDirect3D8_Release(p) (p)->Release() -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) -#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) -#endif - - - - - - - - - - - - - - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DDevice8 - -DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice8 methods ***/ - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; - STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; - STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; - STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; - STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; - STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; - STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; - STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; - STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; - STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; - STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; - STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; - STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; - STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; - STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; - STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; - STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; - STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; - STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; - STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; - STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; - STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; - STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; - STDMETHOD(BeginStateBlock)(THIS) PURE; - STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; - STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; - STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; - STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; - STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; - STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; - STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; - STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; - STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; - STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; - STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; -}; - -typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) -#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) -#else -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice8_AddRef(p) (p)->AddRef() -#define IDirect3DDevice8_Release(p) (p)->Release() -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) -#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice8_EndScene(p) (p)->EndScene() -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DSwapChain8 - -DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSwapChain8 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; -}; - -typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#else -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() -#define IDirect3DSwapChain8_Release(p) (p)->Release() -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DResource8 - -DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; -}; - -typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) -#else -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DResource8_AddRef(p) (p)->AddRef() -#define IDirect3DResource8_Release(p) (p)->Release() -#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() -#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() -#define IDirect3DResource8_GetType(p) (p)->GetType() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DBaseTexture8 - -DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; -}; - -typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#else -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DBaseTexture8_Release(p) (p)->Release() -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DTexture8 - -DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) -#else -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DTexture8_Release(p) (p)->Release() -#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DTexture8_GetType(p) (p)->GetType() -#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolumeTexture8 - -DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; -}; - -typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) -#else -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DVolumeTexture8_Release(p) (p)->Release() -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DCubeTexture8 - -DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) -#else -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DCubeTexture8_Release(p) (p)->Release() -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer8 - -DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer8_Release(p) (p)->Release() -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DIndexBuffer8 - -DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DIndexBuffer8_Release(p) (p)->Release() -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DSurface8 - -DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSurface8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS) PURE; -}; - -typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) -#else -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSurface8_AddRef(p) (p)->AddRef() -#define IDirect3DSurface8_Release(p) (p)->Release() -#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolume8 - -DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVolume8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS) PURE; -}; - -typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) -#else -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolume8_AddRef(p) (p)->AddRef() -#define IDirect3DVolume8_Release(p) (p)->Release() -#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() -#endif - -/**************************************************************************** - * Flags for SetPrivateData method on all D3D8 interfaces - * - * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData - * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this - * pointer and Release when the private data is destroyed. The data will be - * destroyed when another SetPrivateData with the same GUID is set, when - * FreePrivateData is called, or when the D3D8 object is freed. - ****************************************************************************/ -#define D3DSPD_IUNKNOWN 0x00000001L - -/**************************************************************************** - * - * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for - * the current mode only. - * - ****************************************************************************/ - -#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL - -/**************************************************************************** - * - * Flags for IDirect3D8::CreateDevice's BehaviorFlags - * - ****************************************************************************/ - -#define D3DCREATE_FPU_PRESERVE 0x00000002L -#define D3DCREATE_MULTITHREADED 0x00000004L - -#define D3DCREATE_PUREDEVICE 0x00000010L -#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L -#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L -#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L - -#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L - - -/**************************************************************************** - * - * Parameter for IDirect3D8::CreateDevice's iAdapter - * - ****************************************************************************/ - -#define D3DADAPTER_DEFAULT 0 - -/**************************************************************************** - * - * Flags for IDirect3D8::EnumAdapters - * - ****************************************************************************/ - -#define D3DENUM_NO_WHQL_LEVEL 0x00000002L - -/**************************************************************************** - * - * Maximum number of back-buffers supported in DX8 - * - ****************************************************************************/ - -#define D3DPRESENT_BACK_BUFFERS_MAX 3L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetGammaRamp - * - ****************************************************************************/ - -#define D3DSGR_NO_CALIBRATION 0x00000000L -#define D3DSGR_CALIBRATE 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetCursorPosition - * - ****************************************************************************/ - -#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L - -/**************************************************************************** - * - * Flags for DrawPrimitive/DrawIndexedPrimitive - * Also valid for Begin/BeginIndexed - * Also valid for VertexBuffer::CreateVertexBuffer - ****************************************************************************/ - - -/* - * DirectDraw error codes - */ -#define _FACD3D 0x876 -#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) - -/* - * Direct3D Errors - */ -#define D3D_OK S_OK - -#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) -#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) -#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) -#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) -#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) -#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) -#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) -#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) -#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) -#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) -#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) -#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) - -#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) -#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) -#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) -#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) -#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) -#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) -#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) -#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) -#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) - -#ifdef __cplusplus -}; -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0800) */ -#endif /* _D3D_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D8_H_ +#define _D3D8_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + + +/* This identifier is passed to Direct3DCreate8 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. + * (The number itself has no meaning.)*/ + +#define D3D_SDK_VERSION 220 + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D8 */ +/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ +DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); + +/* IID_IDirect3DDevice8 */ +/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ +DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); + +/* IID_IDirect3DResource8 */ +/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ +DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); + +/* IID_IDirect3DBaseTexture8 */ +/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ +DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); + +/* IID_IDirect3DTexture8 */ +/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ +DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); + +/* IID_IDirect3DCubeTexture8 */ +/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ +DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); + +/* IID_IDirect3DVolumeTexture8 */ +/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); + +/* IID_IDirect3DVertexBuffer8 */ +/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); + +/* IID_IDirect3DIndexBuffer8 */ +/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); + +/* IID_IDirect3DSurface8 */ +/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ +DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); + +/* IID_IDirect3DVolume8 */ +/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ +DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); + +/* IID_IDirect3DSwapChain8 */ +/* {928C088B-76B9-4C6B-A536-A590853876CD} */ +DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); + +#endif + +#ifdef __cplusplus + +interface IDirect3D8; +interface IDirect3DDevice8; + +interface IDirect3DResource8; +interface IDirect3DBaseTexture8; +interface IDirect3DTexture8; +interface IDirect3DVolumeTexture8; +interface IDirect3DCubeTexture8; + +interface IDirect3DVertexBuffer8; +interface IDirect3DIndexBuffer8; + +interface IDirect3DSurface8; +interface IDirect3DVolume8; + +interface IDirect3DSwapChain8; + +#endif + + +typedef interface IDirect3D8 IDirect3D8; +typedef interface IDirect3DDevice8 IDirect3DDevice8; +typedef interface IDirect3DResource8 IDirect3DResource8; +typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; +typedef interface IDirect3DTexture8 IDirect3DTexture8; +typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; +typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; +typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; +typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; +typedef interface IDirect3DSurface8 IDirect3DSurface8; +typedef interface IDirect3DVolume8 IDirect3DVolume8; +typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; + +#include "d3d8types.h" +#include "d3d8caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D8 object. This object supports + * enumeration and allows the creation of Direct3DDevice8 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); + + +/* + * Direct3D interfaces + */ + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D8 + +DECLARE_INTERFACE_(IDirect3D8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D8 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; +}; + +typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D8_AddRef(p) (p)->AddRef() +#define IDirect3D8_Release(p) (p)->Release() +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice8 + +DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice8 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; + STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; + STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; + STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; + STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; + STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; +}; + +typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#else +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice8_AddRef(p) (p)->AddRef() +#define IDirect3DDevice8_Release(p) (p)->Release() +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice8_EndScene(p) (p)->EndScene() +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain8 + +DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain8 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; +}; + +typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#else +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain8_Release(p) (p)->Release() +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource8 + +DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource8_AddRef(p) (p)->AddRef() +#define IDirect3DResource8_Release(p) (p)->Release() +#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource8_GetType(p) (p)->GetType() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture8 + +DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#else +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture8_Release(p) (p)->Release() +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture8 + +DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DTexture8_Release(p) (p)->Release() +#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture8_GetType(p) (p)->GetType() +#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture8 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; +}; + +typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture8_Release(p) (p)->Release() +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture8 + +DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture8_Release(p) (p)->Release() +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer8 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer8_Release(p) (p)->Release() +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer8 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer8_Release(p) (p)->Release() +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface8 + +DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSurface8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; +}; + +typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#else +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface8_AddRef(p) (p)->AddRef() +#define IDirect3DSurface8_Release(p) (p)->Release() +#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume8 + +DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; +}; + +typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume8_AddRef(p) (p)->AddRef() +#define IDirect3DVolume8_Release(p) (p)->Release() +#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() +#endif + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D8 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D8 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for + * the current mode only. + * + ****************************************************************************/ + +#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL + +/**************************************************************************** + * + * Flags for IDirect3D8::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L + + +/**************************************************************************** + * + * Parameter for IDirect3D8::CreateDevice's iAdapter + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D8::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_NO_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX8 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D_H_ */ + diff --git a/gfx/include/d3d8/d3dx8.h b/gfx/include/d3d8/d3dx8.h index a7d30d74eb..fc2688c43a 100644 --- a/gfx/include/d3d8/d3dx8.h +++ b/gfx/include/d3d8/d3dx8.h @@ -1,44 +1,44 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8.h -// Content: D3DX utility library -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX8_H__ -#define __D3DX8_H__ - -#include "d3d8.h" -#include - -#ifndef D3DXINLINE -#ifdef _MSC_VER - #if (_MSC_VER >= 1200) - #define D3DXINLINE __forceinline - #else - #define D3DXINLINE __inline - #endif -#else - #ifdef __cplusplus - #define D3DXINLINE inline - #else - #define D3DXINLINE - #endif -#endif -#endif - - -#define D3DX_DEFAULT ULONG_MAX -#define D3DX_DEFAULT_FLOAT FLT_MAX - -#include "d3dx8math.h" -#include "d3dx8core.h" -#include "d3dx8tex.h" -#include "d3dx8mesh.h" -#include "d3dx8shape.h" -#include "d3dx8effect.h" - - -#endif //__D3DX8_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8.h +// Content: D3DX utility library +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8_H__ +#define __D3DX8_H__ + +#include "d3d8.h" +#include + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + +#define D3DX_DEFAULT ULONG_MAX +#define D3DX_DEFAULT_FLOAT FLT_MAX + +#include "d3dx8math.h" +#include "d3dx8core.h" +#include "d3dx8tex.h" +#include "d3dx8mesh.h" +#include "d3dx8shape.h" +#include "d3dx8effect.h" + + +#endif //__D3DX8_H__ diff --git a/gfx/include/d3d8/d3dx8core.h b/gfx/include/d3d8/d3dx8core.h index 7db338f9b4..2d70af640c 100644 --- a/gfx/include/d3d8/d3dx8core.h +++ b/gfx/include/d3d8/d3dx8core.h @@ -1,563 +1,563 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8core.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8CORE_H__ -#define __D3DX8CORE_H__ - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXBuffer ID3DXBuffer; -typedef interface ID3DXBuffer *LPD3DXBUFFER; - -// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} -DEFINE_GUID(IID_ID3DXBuffer, -0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); - -#undef INTERFACE -#define INTERFACE ID3DXBuffer - -DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBuffer - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; -}; - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXFont: -// ---------- -// Font objects contain the textures and resources needed to render -// a specific font on a specific device. -// -// Begin - -// Prepartes device for drawing text. This is optional.. if DrawText -// is called outside of Begin/End, it will call Begin and End for you. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -// -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXFont ID3DXFont; -typedef interface ID3DXFont *LPD3DXFONT; - - -// {89FAD6A5-024D-49af-8FE7-F51123B85E25} -DEFINE_GUID( IID_ID3DXFont, -0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); - - -#undef INTERFACE -#define INTERFACE ID3DXFont - -DECLARE_INTERFACE_(ID3DXFont, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXFont - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; - - STDMETHOD(Begin)(THIS) PURE; - STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - -#ifndef DrawText -#ifdef UNICODE -#define DrawText DrawTextW -#else -#define DrawText DrawTextA -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateFont( - LPDIRECT3DDEVICE8 pDevice, - HFONT hFont, - LPD3DXFONT* ppFont); - - -HRESULT WINAPI - D3DXCreateFontIndirect( - LPDIRECT3DDEVICE8 pDevice, - CONST LOGFONT* pLogFont, - LPD3DXFONT* ppFont); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXSprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites -// -// Draw, DrawAffine, DrawTransform - -// Draws a sprite in screen-space. Before transformation, the sprite is -// the size of SrcRect, with its top-left corner at the origin (0,0). -// The color and alpha channels are modulated by Color. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXSprite ID3DXSprite; -typedef interface ID3DXSprite *LPD3DXSPRITE; - - -// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} -DEFINE_GUID( IID_ID3DXSprite, -0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); - - -#undef INTERFACE -#define INTERFACE ID3DXSprite - -DECLARE_INTERFACE_(ID3DXSprite, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSprite - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - - STDMETHOD(Begin)(THIS) PURE; - - STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, - CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; - - STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, - D3DCOLOR Color) PURE; - - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXSPRITE* ppSprite); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToSurface: -// --------------------- -// This object abstracts rendering to surfaces. These surfaces do not -// necessarily need to be render targets. If they are not, a compatible -// render target is used, and the result copied into surface at end scene. -// -// BeginScene, EndScene - -// Call BeginScene() and EndScene() at the beginning and ending of your -// scene. These calls will setup and restore render targets, viewports, -// etc.. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTS_DESC -{ - UINT Width; - UINT Height; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; - -} D3DXRTS_DESC; - - -typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; -typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; - - -// {82DF5B90-E34E-496e-AC1C-62117A6A5913} -DEFINE_GUID( IID_ID3DXRenderToSurface, -0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToSurface - -DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToSurface - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; - - STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(EndScene)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToSurface( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRENDERTOSURFACE* ppRenderToSurface); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToEnvMap: -// -------------------- -// This object abstracts rendering to environment maps. These surfaces -// do not necessarily need to be render targets. If they are not, a -// compatible render target is used, and the result copied into the -// environment map at end scene. -// -// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - -// This function initiates the rendering of the environment map. As -// parameters, you pass the textures in which will get filled in with -// the resulting environment map. -// -// Face - -// Call this function to initiate the drawing of each face. For each -// environment map, you will call this six times.. once for each face -// in D3DCUBEMAP_FACES. -// -// End - -// This will restore all render targets, and if needed compose all the -// rendered faces into the environment map surfaces. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTE_DESC -{ - UINT Size; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; -} D3DXRTE_DESC; - - -typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; -typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; - -// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} -DEFINE_GUID( IID_ID3DXRenderToEnvMap, -0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToEnvMap - -DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToEnvMap - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - - STDMETHOD(BeginCube)(THIS_ - LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; - - STDMETHOD(BeginSphere)(THIS_ - LPDIRECT3DTEXTURE8 pTex) PURE; - - STDMETHOD(BeginHemisphere)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(BeginParabolic)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToEnvMap( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRenderToEnvMap* ppRenderToEnvMap); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Shader assemblers: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// D3DXASM flags: -// -------------- -// -// D3DXASM_DEBUG -// Generate debug info. -// -// D3DXASM_SKIPVALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when assembling shaders -// you KNOW will work. (ie. have assembled before without this option.) -//------------------------------------------------------------------------- - -#define D3DXASM_DEBUG (1 << 0) -#define D3DXASM_SKIPVALIDATION (1 << 1) - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXAssembleShader: -// ------------------- -// Assembles an ascii description of a vertex or pixel shader into -// binary form. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// Flags -// D3DXASM_xxx flags -// ppConstants -// Returns an ID3DXBuffer object containing constant declarations. -// ppCompiledShader -// Returns an ID3DXBuffer object containing the object code. -// ppCompilationErrors -// Returns an ID3DXBuffer object containing ascii error messages -//------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXAssembleShaderFromFileA( - LPCSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromFileW( - LPCWSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW -#else -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA -#endif - -HRESULT WINAPI - D3DXAssembleShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW -#else -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA -#endif - -HRESULT WINAPI - D3DXAssembleShader( - LPCVOID pSrcData, - UINT SrcDataLen, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Misc APIs: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXGetErrorString: -// ------------------ -// Returns the error string for given an hresult. Interprets all D3DX and -// D3D hresults. -// -// Parameters: -// hr -// The error code to be deciphered. -// pBuffer -// Pointer to the buffer to be filled in. -// BufferLen -// Count of characters in buffer. Any error message longer than this -// length will be truncated to fit. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXGetErrorStringA( - HRESULT hr, - LPSTR pBuffer, - UINT BufferLen); - -HRESULT WINAPI - D3DXGetErrorStringW( - HRESULT hr, - LPWSTR pBuffer, - UINT BufferLen); - -#ifdef UNICODE -#define D3DXGetErrorString D3DXGetErrorStringW -#else -#define D3DXGetErrorString D3DXGetErrorStringA -#endif - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8CORE_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8core.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8CORE_H__ +#define __D3DX8CORE_H__ + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXBuffer: +// ------------ +// The buffer object is used by D3DX to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBuffer ID3DXBuffer; +typedef interface ID3DXBuffer *LPD3DXBUFFER; + +// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} +DEFINE_GUID(IID_ID3DXBuffer, +0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); + +#undef INTERFACE +#define INTERFACE ID3DXBuffer + +DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBuffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; +}; + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXFont: +// ---------- +// Font objects contain the textures and resources needed to render +// a specific font on a specific device. +// +// Begin - +// Prepartes device for drawing text. This is optional.. if DrawText +// is called outside of Begin/End, it will call Begin and End for you. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +// +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXFont ID3DXFont; +typedef interface ID3DXFont *LPD3DXFONT; + + +// {89FAD6A5-024D-49af-8FE7-F51123B85E25} +DEFINE_GUID( IID_ID3DXFont, +0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); + + +#undef INTERFACE +#define INTERFACE ID3DXFont + +DECLARE_INTERFACE_(ID3DXFont, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFont + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; + + STDMETHOD(Begin)(THIS) PURE; + STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateFont( + LPDIRECT3DDEVICE8 pDevice, + HFONT hFont, + LPD3DXFONT* ppFont); + + +HRESULT WINAPI + D3DXCreateFontIndirect( + LPDIRECT3DDEVICE8 pDevice, + CONST LOGFONT* pLogFont, + LPD3DXFONT* ppFont); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXSprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites +// +// Draw, DrawAffine, DrawTransform - +// Draws a sprite in screen-space. Before transformation, the sprite is +// the size of SrcRect, with its top-left corner at the origin (0,0). +// The color and alpha channels are modulated by Color. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXSprite ID3DXSprite; +typedef interface ID3DXSprite *LPD3DXSPRITE; + + +// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} +DEFINE_GUID( IID_ID3DXSprite, +0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); + + +#undef INTERFACE +#define INTERFACE ID3DXSprite + +DECLARE_INTERFACE_(ID3DXSprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSprite + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + + STDMETHOD(Begin)(THIS) PURE; + + STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; + + STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, + D3DCOLOR Color) PURE; + + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXSPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToSurface: +// --------------------- +// This object abstracts rendering to surfaces. These surfaces do not +// necessarily need to be render targets. If they are not, a compatible +// render target is used, and the result copied into surface at end scene. +// +// BeginScene, EndScene - +// Call BeginScene() and EndScene() at the beginning and ending of your +// scene. These calls will setup and restore render targets, viewports, +// etc.. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTS_DESC +{ + UINT Width; + UINT Height; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTS_DESC; + + +typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; +typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; + + +// {82DF5B90-E34E-496e-AC1C-62117A6A5913} +DEFINE_GUID( IID_ID3DXRenderToSurface, +0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToSurface + +DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToSurface + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; + + STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(EndScene)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToSurface( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRENDERTOSURFACE* ppRenderToSurface); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToEnvMap: +// -------------------- +// This object abstracts rendering to environment maps. These surfaces +// do not necessarily need to be render targets. If they are not, a +// compatible render target is used, and the result copied into the +// environment map at end scene. +// +// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - +// This function initiates the rendering of the environment map. As +// parameters, you pass the textures in which will get filled in with +// the resulting environment map. +// +// Face - +// Call this function to initiate the drawing of each face. For each +// environment map, you will call this six times.. once for each face +// in D3DCUBEMAP_FACES. +// +// End - +// This will restore all render targets, and if needed compose all the +// rendered faces into the environment map surfaces. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTE_DESC +{ + UINT Size; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; +} D3DXRTE_DESC; + + +typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; +typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; + +// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} +DEFINE_GUID( IID_ID3DXRenderToEnvMap, +0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToEnvMap + +DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToEnvMap + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; + + STDMETHOD(BeginCube)(THIS_ + LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; + + STDMETHOD(BeginSphere)(THIS_ + LPDIRECT3DTEXTURE8 pTex) PURE; + + STDMETHOD(BeginHemisphere)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(BeginParabolic)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToEnvMap( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRenderToEnvMap* ppRenderToEnvMap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Shader assemblers: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DXASM flags: +// -------------- +// +// D3DXASM_DEBUG +// Generate debug info. +// +// D3DXASM_SKIPVALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when assembling shaders +// you KNOW will work. (ie. have assembled before without this option.) +//------------------------------------------------------------------------- + +#define D3DXASM_DEBUG (1 << 0) +#define D3DXASM_SKIPVALIDATION (1 << 1) + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXAssembleShader: +// ------------------- +// Assembles an ascii description of a vertex or pixel shader into +// binary form. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// Flags +// D3DXASM_xxx flags +// ppConstants +// Returns an ID3DXBuffer object containing constant declarations. +// ppCompiledShader +// Returns an ID3DXBuffer object containing the object code. +// ppCompilationErrors +// Returns an ID3DXBuffer object containing ascii error messages +//------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXAssembleShaderFromFileA( + LPCSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromFileW( + LPCWSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW +#else +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA +#endif + +HRESULT WINAPI + D3DXAssembleShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW +#else +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA +#endif + +HRESULT WINAPI + D3DXAssembleShader( + LPCVOID pSrcData, + UINT SrcDataLen, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Misc APIs: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXGetErrorString: +// ------------------ +// Returns the error string for given an hresult. Interprets all D3DX and +// D3D hresults. +// +// Parameters: +// hr +// The error code to be deciphered. +// pBuffer +// Pointer to the buffer to be filled in. +// BufferLen +// Count of characters in buffer. Any error message longer than this +// length will be truncated to fit. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetErrorStringA( + HRESULT hr, + LPSTR pBuffer, + UINT BufferLen); + +HRESULT WINAPI + D3DXGetErrorStringW( + HRESULT hr, + LPWSTR pBuffer, + UINT BufferLen); + +#ifdef UNICODE +#define D3DXGetErrorString D3DXGetErrorStringW +#else +#define D3DXGetErrorString D3DXGetErrorStringA +#endif + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8CORE_H__ diff --git a/gfx/include/d3d8/d3dx8effect.h b/gfx/include/d3d8/d3dx8effect.h index 96fc382815..8444935877 100644 --- a/gfx/include/d3d8/d3dx8effect.h +++ b/gfx/include/d3d8/d3dx8effect.h @@ -1,226 +1,226 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8effect.h -// Content: D3DX effect types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8EFFECT_H__ -#define __D3DX8EFFECT_H__ - - -#define D3DXFX_DONOTSAVESTATE (1 << 0) - - -typedef enum _D3DXPARAMETERTYPE -{ - D3DXPT_DWORD = 0, - D3DXPT_FLOAT = 1, - D3DXPT_VECTOR = 2, - D3DXPT_MATRIX = 3, - D3DXPT_TEXTURE = 4, - D3DXPT_VERTEXSHADER = 5, - D3DXPT_PIXELSHADER = 6, - D3DXPT_CONSTANT = 7, - D3DXPT_STRING = 8, - D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ - -} D3DXPARAMETERTYPE; - - -typedef struct _D3DXEFFECT_DESC -{ - UINT Parameters; - UINT Techniques; - -} D3DXEFFECT_DESC; - - -typedef struct _D3DXPARAMETER_DESC -{ - LPCSTR Name; - LPCSTR Index; - D3DXPARAMETERTYPE Type; - -} D3DXPARAMETER_DESC; - - -typedef struct _D3DXTECHNIQUE_DESC -{ - LPCSTR Name; - LPCSTR Index; - UINT Passes; - -} D3DXTECHNIQUE_DESC; - - -typedef struct _D3DXPASS_DESC -{ - LPCSTR Name; - LPCSTR Index; - -} D3DXPASS_DESC; - - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffect ID3DXEffect; -typedef interface ID3DXEffect *LPD3DXEFFECT; - -// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} -DEFINE_GUID( IID_ID3DXEffect, -0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); - - -#undef INTERFACE -#define INTERFACE ID3DXEffect - -DECLARE_INTERFACE_(ID3DXEffect, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXEffect - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; - STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; - - STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; - STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; - - STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; - STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; - STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; - STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; - STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; - STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; - - STDMETHOD(Validate)(THIS) PURE; - STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; - STDMETHOD(Pass)(THIS_ UINT Pass) PURE; - STDMETHOD(End)(THIS) PURE; - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DXCreateEffect: -// ----------------- -// Creates an effect from an ascii or binaray effect description. -// -// Parameters: -// pDevice -// Pointer of the device on which to create the effect -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// ppEffect -// Returns a buffer containing created effect. -// ppCompilationErrors -// Returns a buffer containing any error messages which occurred during -// compile. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW -#else -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateEffectFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW -#else -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateEffect( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8EFFECT_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8effect.h +// Content: D3DX effect types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8EFFECT_H__ +#define __D3DX8EFFECT_H__ + + +#define D3DXFX_DONOTSAVESTATE (1 << 0) + + +typedef enum _D3DXPARAMETERTYPE +{ + D3DXPT_DWORD = 0, + D3DXPT_FLOAT = 1, + D3DXPT_VECTOR = 2, + D3DXPT_MATRIX = 3, + D3DXPT_TEXTURE = 4, + D3DXPT_VERTEXSHADER = 5, + D3DXPT_PIXELSHADER = 6, + D3DXPT_CONSTANT = 7, + D3DXPT_STRING = 8, + D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ + +} D3DXPARAMETERTYPE; + + +typedef struct _D3DXEFFECT_DESC +{ + UINT Parameters; + UINT Techniques; + +} D3DXEFFECT_DESC; + + +typedef struct _D3DXPARAMETER_DESC +{ + LPCSTR Name; + LPCSTR Index; + D3DXPARAMETERTYPE Type; + +} D3DXPARAMETER_DESC; + + +typedef struct _D3DXTECHNIQUE_DESC +{ + LPCSTR Name; + LPCSTR Index; + UINT Passes; + +} D3DXTECHNIQUE_DESC; + + +typedef struct _D3DXPASS_DESC +{ + LPCSTR Name; + LPCSTR Index; + +} D3DXPASS_DESC; + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffect /////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffect ID3DXEffect; +typedef interface ID3DXEffect *LPD3DXEFFECT; + +// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} +DEFINE_GUID( IID_ID3DXEffect, +0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); + + +#undef INTERFACE +#define INTERFACE ID3DXEffect + +DECLARE_INTERFACE_(ID3DXEffect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXEffect + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; + STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; + + STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; + STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; + + STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; + STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; + STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; + STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; + STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; + STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; + + STDMETHOD(Validate)(THIS) PURE; + STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; + STDMETHOD(Pass)(THIS_ UINT Pass) PURE; + STDMETHOD(End)(THIS) PURE; + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXCreateEffect: +// ----------------- +// Creates an effect from an ascii or binaray effect description. +// +// Parameters: +// pDevice +// Pointer of the device on which to create the effect +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// ppEffect +// Returns a buffer containing created effect. +// ppCompilationErrors +// Returns a buffer containing any error messages which occurred during +// compile. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW +#else +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW +#else +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffect( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8EFFECT_H__ diff --git a/gfx/include/d3d8/d3dx8math.h b/gfx/include/d3d8/d3dx8math.h index fa15ff778a..a1a68fd6b6 100644 --- a/gfx/include/d3d8/d3dx8math.h +++ b/gfx/include/d3d8/d3dx8math.h @@ -1,1213 +1,1213 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MATH_H__ -#define __D3DX8MATH_H__ - -#include -#pragma warning(disable:4201) /* anonymous unions warning */ - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((FLOAT) 3.141592654f) -#define D3DX_1BYPI ((FLOAT) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( CONST FLOAT * ); - D3DXVECTOR2( FLOAT x, FLOAT y ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( FLOAT ); - D3DXVECTOR2& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( FLOAT ) const; - D3DXVECTOR2 operator / ( FLOAT ) const; - - friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); - - BOOL operator == ( CONST D3DXVECTOR2& ) const; - BOOL operator != ( CONST D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - FLOAT x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - -//-------------------------- -// 3D Vector -//-------------------------- -#ifdef __cplusplus -typedef struct D3DXVECTOR3 : public D3DVECTOR -{ -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( CONST FLOAT * ); - D3DXVECTOR3( CONST D3DVECTOR& ); - D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( FLOAT ); - D3DXVECTOR3& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( FLOAT ) const; - D3DXVECTOR3 operator / ( FLOAT ) const; - - friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); - - BOOL operator == ( CONST D3DXVECTOR3& ) const; - BOOL operator != ( CONST D3DXVECTOR3& ) const; - -} D3DXVECTOR3, *LPD3DXVECTOR3; - -#else //!__cplusplus -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( CONST FLOAT* ); - D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( FLOAT ); - D3DXVECTOR4& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( FLOAT ) const; - D3DXVECTOR4 operator / ( FLOAT ) const; - - friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); - - BOOL operator == ( CONST D3DXVECTOR4& ) const; - BOOL operator != ( CONST D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -#ifdef __cplusplus -typedef struct D3DXMATRIX : public D3DMATRIX -{ -public: - D3DXMATRIX() {}; - D3DXMATRIX( CONST FLOAT * ); - D3DXMATRIX( CONST D3DMATRIX& ); - D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - - // access grants - FLOAT& operator () ( UINT Row, UINT Col ); - FLOAT operator () ( UINT Row, UINT Col ) const; - - // casting operators - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator *= ( FLOAT ); - D3DXMATRIX& operator /= ( FLOAT ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator * ( FLOAT ) const; - D3DXMATRIX operator / ( FLOAT ) const; - - friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); - - BOOL operator == ( CONST D3DXMATRIX& ) const; - BOOL operator != ( CONST D3DXMATRIX& ) const; - -} D3DXMATRIX, *LPD3DXMATRIX; - -#else //!__cplusplus -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus - -//=========================================================================== -// -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -// -//=========================================================================== -#ifdef __cplusplus -typedef struct _D3DXMATRIXA16 : public D3DXMATRIX -{ - _D3DXMATRIXA16() {} - _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} - _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} - _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : - D3DXMATRIX(_11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44) {} - void* operator new(size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - void* operator new[](size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete(void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete[](void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) - { - memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); - return *this; - }; -} _D3DXMATRIXA16; - -#else //!__cplusplus -typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus - -#if _MSC_VER >= 1300 // VC7 -#define _ALIGN_16 __declspec(align(16)) -#else -#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. -#endif - -#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 - -typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {} - D3DXQUATERNION( CONST FLOAT * ); - D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( FLOAT ); - D3DXQUATERNION& operator /= ( FLOAT ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( FLOAT ) const; - D3DXQUATERNION operator / ( FLOAT ) const; - - friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); - - BOOL operator == ( CONST D3DXQUATERNION& ) const; - BOOL operator != ( CONST D3DXQUATERNION& ) const; - -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {} - D3DXPLANE( CONST FLOAT* ); - D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - BOOL operator == ( CONST D3DXPLANE& ) const; - BOOL operator != ( CONST D3DXPLANE& ) const; - -#endif //__cplusplus - FLOAT a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {} - D3DXCOLOR( DWORD argb ); - D3DXCOLOR( CONST FLOAT * ); - D3DXCOLOR( CONST D3DCOLORVALUE& ); - D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - - // casting - operator DWORD () const; - - operator FLOAT* (); - operator CONST FLOAT* () const; - - operator D3DCOLORVALUE* (); - operator CONST D3DCOLORVALUE* () const; - - operator D3DCOLORVALUE& (); - operator CONST D3DCOLORVALUE& () const; - - // assignment operators - D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator *= ( FLOAT ); - D3DXCOLOR& operator /= ( FLOAT ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator * ( FLOAT ) const; - D3DXCOLOR operator / ( FLOAT ) const; - - friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); - - BOOL operator == ( CONST D3DXCOLOR& ) const; - BOOL operator != ( CONST D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR2* WINAPI D3DXVec2CatmullRom - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR3* WINAPI D3DXVec3CatmullRom - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Project vector from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3Project - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3Unproject - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR4* WINAPI D3DXVec4CatmullRom - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -FLOAT WINAPI D3DXMatrixfDeterminant - ( CONST D3DXMATRIX *pM ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) -D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, - CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, - CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, - CONST D3DXVECTOR3 *pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, - CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtRH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, - CONST D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ); - -FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, FLOAT t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, - CONST D3DXQUATERNION *pC, FLOAT t ); - -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. -void WINAPI D3DXQuaternionSquadSetup - ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); - -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, - FLOAT f, FLOAT g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); - -// ax + by + cz + d -FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// ax + by + cz -FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3); - -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -D3DXPLANE* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); - -#ifdef __cplusplus -} -#endif - - - - -//-------------------------- -// Misc -//-------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. -FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); - -#ifdef __cplusplus -} -#endif - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -typedef interface ID3DXMatrixStack ID3DXMatrixStack; -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {E3357330-CC5E-11d2-A434-00A0C90629A8} -DEFINE_GUID( IID_ID3DXMatrixStack, -0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); - - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) - STDMETHOD(RotateAxisLocal) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - /* Obtain the current matrix at the top of the stack */ - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, - LPD3DXMATRIXSTACK* ppStack); - -#ifdef __cplusplus -} -#endif - -#include "d3dx8math.inl" - -#pragma warning(default:4201) - -#endif /* __D3DX8MATH_H__ */ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MATH_H__ +#define __D3DX8MATH_H__ + +#include +#pragma warning(disable:4201) /* anonymous unions warning */ + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + +//=========================================================================== +// +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +// +//=========================================================================== +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {} + _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} + _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) {} + void* operator new(size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + void* operator new[](size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete(void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete[](void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) + { + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; + }; +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + +#if _MSC_VER >= 1300 // VC7 +#define _ALIGN_16 __declspec(align(16)) +#else +#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. +#endif + +#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 + +typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DCOLORVALUE& ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator DWORD () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + operator D3DCOLORVALUE* (); + operator CONST D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator CONST D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixfDeterminant + ( CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {E3357330-CC5E-11d2-A434-00A0C90629A8} +DEFINE_GUID( IID_ID3DXMatrixStack, +0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + /* Obtain the current matrix at the top of the stack */ + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +#include "d3dx8math.inl" + +#pragma warning(default:4201) + +#endif /* __D3DX8MATH_H__ */ diff --git a/gfx/include/d3d8/d3dx8mesh.h b/gfx/include/d3d8/d3dx8mesh.h index d4cadd95b9..f17d92c8bd 100644 --- a/gfx/include/d3d8/d3dx8mesh.h +++ b/gfx/include/d3d8/d3dx8mesh.h @@ -1,760 +1,760 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8mesh.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MESH_H__ -#define __D3DX8MESH_H__ - -#include "dxfile.h" // defines LPDIRECTXFILEDATA - -// {2A835771-BF4D-43f4-8E14-82A809F17D8A} -DEFINE_GUID(IID_ID3DXBaseMesh, -0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); - -// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} -DEFINE_GUID(IID_ID3DXMesh, -0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); - -// {19FBE386-C282-4659-97BD-CB869B084A6C} -DEFINE_GUID(IID_ID3DXPMesh, -0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); - -// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} -DEFINE_GUID(IID_ID3DXSPMesh, -0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); - -// {8DB06ECC-EBFC-408a-9404-3074B4773515} -DEFINE_GUID(IID_ID3DXSkinMesh, -0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); - -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags -enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. - - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer - - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh - - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING - -}; - -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh -enum _D3DXMESHSIMP -{ - D3DXMESHSIMP_VERTEX = 0x1, - D3DXMESHSIMP_FACE = 0x2, - -}; - -enum _MAX_FVF_DECL_SIZE -{ - MAX_FVF_DECL_SIZE = 20 -}; - -typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; -typedef struct ID3DXMesh *LPD3DXMESH; -typedef struct ID3DXPMesh *LPD3DXPMESH; -typedef struct ID3DXSPMesh *LPD3DXSPMESH; -typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; - -typedef struct _D3DXATTRIBUTERANGE -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; -} D3DXATTRIBUTERANGE; - -typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus -struct D3DXMATERIAL -{ - D3DMATERIAL8 MatD3D; - LPSTR pTextureFilename; -}; -typedef struct D3DXMATERIAL *LPD3DXMATERIAL; -#ifdef __cplusplus -} -#endif //__cplusplus - -typedef struct _D3DXATTRIBUTEWEIGHTS -{ - FLOAT Position; - FLOAT Boundary; - FLOAT Normal; - FLOAT Diffuse; - FLOAT Specular; - FLOAT Tex[8]; -} D3DXATTRIBUTEWEIGHTS; - -typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; - -enum _D3DXWELDEPSILONSFLAGS -{ - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed -}; - -typedef struct _D3DXWELDEPSILONS -{ - FLOAT SkinWeights; - FLOAT Normal; - FLOAT Tex[8]; - DWORD Flags; -} D3DXWELDEPSILONS; - -typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; - - -#undef INTERFACE -#define INTERFACE ID3DXBaseMesh - -DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXMesh - -DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXMesh - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; - -}; - - -#undef INTERFACE -#define INTERFACE ID3DXPMesh - -DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; - STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; - - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - - STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; - STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - - STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXSPMesh - -DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSPMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; - STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; -}; - -#define UNUSED16 (0xffff) -#define UNUSED32 (0xffffffff) - -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags -enum _D3DXMESHOPT { - D3DXMESHOPT_COMPACT = 0x01000000, - D3DXMESHOPT_ATTRSORT = 0x02000000, - D3DXMESHOPT_VERTEXCACHE = 0x04000000, - D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE -}; - -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call -typedef struct _D3DXBONECOMBINATION -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; - DWORD* BoneId; -} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; - - -#undef INTERFACE -#define INTERFACE ID3DXSkinMesh - -DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - // ID3DXSkinMesh - STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; - STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; - STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; - STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; - STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; - STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; - STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; - - STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - DWORD paletteSize, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, - FLOAT minWeight, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - LPD3DXSPMESH* ppSMesh); - -// clean a mesh up for simplification, try to make manifold -HRESULT WINAPI - D3DXCleanMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - LPD3DXMESH* ppMeshOut, - DWORD* pAdjacencyOut, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXValidMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacency, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXPMESH* ppPMesh); - -HRESULT WINAPI - D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXComputeBoundingSphere( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pCenter, - FLOAT *pRadius); - -HRESULT WINAPI - D3DXComputeBoundingBox( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pMin, - D3DXVECTOR3 *pMax); - -HRESULT WINAPI - D3DXComputeNormals( - LPD3DXBASEMESH pMesh, - CONST DWORD *pAdjacency); - -HRESULT WINAPI - D3DXCreateBuffer( - DWORD NumBytes, - LPD3DXBUFFER *ppBuffer); - - -HRESULT WINAPI - D3DXLoadMeshFromX( - LPSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXInMemory( - PBYTE Memory, - DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXResource( - HMODULE Module, - LPCTSTR Name, - LPCTSTR Type, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXSaveMeshToX( - LPSTR pFilename, - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXMATERIAL pMaterials, - DWORD NumMaterials, - DWORD Format - ); - -HRESULT WINAPI - D3DXCreatePMeshFromStream( - IStream *pStream, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppMaterials, - DWORD* pNumMaterials, - LPD3DXPMESH *ppPMesh); - -HRESULT WINAPI - D3DXCreateSkinMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFromMesh( - LPD3DXMESH pMesh, - DWORD numBones, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXof( - LPDIRECTXFILEDATA pXofObjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadSkinMeshFromXof( - LPDIRECTXFILEDATA pxofobjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER* ppAdjacency, - LPD3DXBUFFER* ppMaterials, - DWORD *pMatOut, - LPD3DXBUFFER* ppBoneNames, - LPD3DXBUFFER* ppBoneTransforms, - LPD3DXSKINMESH* ppMesh); - -HRESULT WINAPI - D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppAdjacencyOut); - -UINT WINAPI - D3DXGetFVFVertexSize(DWORD FVF); - -HRESULT WINAPI - D3DXDeclaratorFromFVF( - DWORD FVF, - DWORD Declaration[MAX_FVF_DECL_SIZE]); - -HRESULT WINAPI - D3DXFVFFromDeclarator( - CONST DWORD *pDeclarator, - DWORD *pFVF); - -HRESULT WINAPI - D3DXWeldVertices( - CONST LPD3DXMESH pMesh, - LPD3DXWELDEPSILONS pEpsilons, - CONST DWORD *pAdjacencyIn, - DWORD *pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap); - -typedef struct _D3DXINTERSECTINFO -{ - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance -} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; - - -HRESULT WINAPI - D3DXIntersect( - LPD3DXBASEMESH pMesh, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - -HRESULT WINAPI - D3DXIntersectSubset( - LPD3DXBASEMESH pMesh, - DWORD AttribId, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - - -HRESULT WINAPI D3DXSplitMesh - ( - CONST LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, - CONST DWORD MaxSize, - CONST DWORD Options, - DWORD *pMeshesOut, - LPD3DXBUFFER *ppMeshArrayOut, - LPD3DXBUFFER *ppAdjacencyArrayOut, - LPD3DXBUFFER *ppFaceRemapArrayOut, - LPD3DXBUFFER *ppVertRemapArrayOut - ); - -BOOL D3DXIntersectTri -( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance - -BOOL WINAPI - D3DXSphereBoundProbe( - CONST D3DXVECTOR3 *pCenter, - FLOAT Radius, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -BOOL WINAPI - D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, - CONST D3DXVECTOR3 *pMax, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -enum _D3DXERR { - D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), - D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), - D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), - D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), - D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), - D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), - D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), -}; - - -#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF - -HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, - DWORD TexStage, - LPD3DXMESH OutMesh, - DWORD TexStageUVec, - DWORD TexStageVVec, - DWORD Wrap, - DWORD *Adjacency); - -HRESULT WINAPI -D3DXConvertMeshSubsetToSingleStrip -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices -); - -HRESULT WINAPI -D3DXConvertMeshSubsetToStrips -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices, - LPD3DXBUFFER *ppStripLengths, - DWORD *pNumStrips -); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8MESH_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8mesh.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MESH_H__ +#define __D3DX8MESH_H__ + +#include "dxfile.h" // defines LPDIRECTXFILEDATA + +// {2A835771-BF4D-43f4-8E14-82A809F17D8A} +DEFINE_GUID(IID_ID3DXBaseMesh, +0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); + +// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} +DEFINE_GUID(IID_ID3DXMesh, +0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); + +// {19FBE386-C282-4659-97BD-CB869B084A6C} +DEFINE_GUID(IID_ID3DXPMesh, +0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); + +// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} +DEFINE_GUID(IID_ID3DXSPMesh, +0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); + +// {8DB06ECC-EBFC-408a-9404-3074B4773515} +DEFINE_GUID(IID_ID3DXSkinMesh, +0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); + +// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +enum _D3DXMESH { + D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. + D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. + D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER + D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. + D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. + D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + + D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + + D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh + + // Helper options + D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM + D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED + D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY + D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC + D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + +}; + +// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +enum _D3DXMESHSIMP +{ + D3DXMESHSIMP_VERTEX = 0x1, + D3DXMESHSIMP_FACE = 0x2, + +}; + +enum _MAX_FVF_DECL_SIZE +{ + MAX_FVF_DECL_SIZE = 20 +}; + +typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; +typedef struct ID3DXMesh *LPD3DXMESH; +typedef struct ID3DXPMesh *LPD3DXPMESH; +typedef struct ID3DXSPMesh *LPD3DXSPMESH; +typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; + +typedef struct _D3DXATTRIBUTERANGE +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; +} D3DXATTRIBUTERANGE; + +typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus +struct D3DXMATERIAL +{ + D3DMATERIAL8 MatD3D; + LPSTR pTextureFilename; +}; +typedef struct D3DXMATERIAL *LPD3DXMATERIAL; +#ifdef __cplusplus +} +#endif //__cplusplus + +typedef struct _D3DXATTRIBUTEWEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Tex[8]; +} D3DXATTRIBUTEWEIGHTS; + +typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; + +enum _D3DXWELDEPSILONSFLAGS +{ + D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + // vertices so that both components identical AND if all components "equal" + // remove one of the vertices + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal + // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + // useful to modify vertices to be equal, but not allow vertices to be removed +}; + +typedef struct _D3DXWELDEPSILONS +{ + FLOAT SkinWeights; + FLOAT Normal; + FLOAT Tex[8]; + DWORD Flags; +} D3DXWELDEPSILONS; + +typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; + + +#undef INTERFACE +#define INTERFACE ID3DXBaseMesh + +DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXMesh + +DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXMesh + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; + +}; + + +#undef INTERFACE +#define INTERFACE ID3DXPMesh + +DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXPMesh + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; + STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; + + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + + STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; + STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + + STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXSPMesh + +DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSPMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; + STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; +}; + +#define UNUSED16 (0xffff) +#define UNUSED32 (0xffffffff) + +// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +enum _D3DXMESHOPT { + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE +}; + +// Subset of the mesh that has the same attribute and bone combination. +// This subset can be rendered in a single draw call +typedef struct _D3DXBONECOMBINATION +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; + DWORD* BoneId; +} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; + + +#undef INTERFACE +#define INTERFACE ID3DXSkinMesh + +DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + // ID3DXSkinMesh + STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; + STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; + STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; + STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; + STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; + STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; + + STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + DWORD paletteSize, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, + FLOAT minWeight, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateSPMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + LPD3DXSPMESH* ppSMesh); + +// clean a mesh up for simplification, try to make manifold +HRESULT WINAPI + D3DXCleanMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + LPD3DXMESH* ppMeshOut, + DWORD* pAdjacencyOut, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXValidMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacency, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXGeneratePMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXPMESH* ppPMesh); + +HRESULT WINAPI + D3DXSimplifyMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + +HRESULT WINAPI + D3DXComputeNormals( + LPD3DXBASEMESH pMesh, + CONST DWORD *pAdjacency); + +HRESULT WINAPI + D3DXCreateBuffer( + DWORD NumBytes, + LPD3DXBUFFER *ppBuffer); + + +HRESULT WINAPI + D3DXLoadMeshFromX( + LPSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXInMemory( + PBYTE Memory, + DWORD SizeOfMemory, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXResource( + HMODULE Module, + LPCTSTR Name, + LPCTSTR Type, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXSaveMeshToX( + LPSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXMATERIAL pMaterials, + DWORD NumMaterials, + DWORD Format + ); + +HRESULT WINAPI + D3DXCreatePMeshFromStream( + IStream *pStream, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + DWORD* pNumMaterials, + LPD3DXPMESH *ppPMesh); + +HRESULT WINAPI + D3DXCreateSkinMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFromMesh( + LPD3DXMESH pMesh, + DWORD numBones, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXof( + LPDIRECTXFILEDATA pXofObjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadSkinMeshFromXof( + LPDIRECTXFILEDATA pxofobjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER* ppAdjacency, + LPD3DXBUFFER* ppMaterials, + DWORD *pMatOut, + LPD3DXBUFFER* ppBoneNames, + LPD3DXBUFFER* ppBoneTransforms, + LPD3DXSKINMESH* ppMesh); + +HRESULT WINAPI + D3DXTessellateNPatches( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, + BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppAdjacencyOut); + +UINT WINAPI + D3DXGetFVFVertexSize(DWORD FVF); + +HRESULT WINAPI + D3DXDeclaratorFromFVF( + DWORD FVF, + DWORD Declaration[MAX_FVF_DECL_SIZE]); + +HRESULT WINAPI + D3DXFVFFromDeclarator( + CONST DWORD *pDeclarator, + DWORD *pFVF); + +HRESULT WINAPI + D3DXWeldVertices( + CONST LPD3DXMESH pMesh, + LPD3DXWELDEPSILONS pEpsilons, + CONST DWORD *pAdjacencyIn, + DWORD *pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap); + +typedef struct _D3DXINTERSECTINFO +{ + DWORD FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; + + +HRESULT WINAPI + D3DXIntersect( + LPD3DXBASEMESH pMesh, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + +HRESULT WINAPI + D3DXIntersectSubset( + LPD3DXBASEMESH pMesh, + DWORD AttribId, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + + +HRESULT WINAPI D3DXSplitMesh + ( + CONST LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, + CONST DWORD MaxSize, + CONST DWORD Options, + DWORD *pMeshesOut, + LPD3DXBUFFER *ppMeshArrayOut, + LPD3DXBUFFER *ppAdjacencyArrayOut, + LPD3DXBUFFER *ppFaceRemapArrayOut, + LPD3DXBUFFER *ppVertRemapArrayOut + ); + +BOOL D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), +}; + + +#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF + +HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, + DWORD TexStage, + LPD3DXMESH OutMesh, + DWORD TexStageUVec, + DWORD TexStageVVec, + DWORD Wrap, + DWORD *Adjacency); + +HRESULT WINAPI +D3DXConvertMeshSubsetToSingleStrip +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices +); + +HRESULT WINAPI +D3DXConvertMeshSubsetToStrips +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices, + LPD3DXBUFFER *ppStripLengths, + DWORD *pNumStrips +); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8MESH_H__ + + diff --git a/gfx/include/d3d8/d3dx8shape.h b/gfx/include/d3d8/d3dx8shape.h index c4d3630983..e874d6479f 100644 --- a/gfx/include/d3d8/d3dx8shape.h +++ b/gfx/include/d3d8/d3dx8shape.h @@ -1,220 +1,220 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8shapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8SHAPES_H__ -#define __D3DX8SHAPES_H__ - -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: -// ------------------ -// Creates a mesh containing an n-sided polygon. The polygon is centered -// at the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Length Length of each side. -// Sides Number of sides the polygon has. (Must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreatePolygon( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Length, - UINT Sides, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateBox: -// -------------- -// Creates a mesh containing an axis-aligned box. The box is centered at -// the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Width Width of box (along X-axis) -// Height Height of box (along Y-axis) -// Depth Depth of box (along Z-axis) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateBox( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Width, - FLOAT Height, - FLOAT Depth, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateCylinder: -// ------------------- -// Creates a mesh containing a cylinder. The generated cylinder is -// centered at the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius1 Radius at -Z end (should be >= 0.0f) -// Radius2 Radius at +Z end (should be >= 0.0f) -// Length Length of cylinder (along Z-axis) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCylinder( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateSphere: -// ----------------- -// Creates a mesh containing a sphere. The sphere is centered at the -// origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius Radius of the sphere (should be >= 0.0f) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateSphere( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTorus: -// ---------------- -// Creates a mesh containing a torus. The generated torus is centered at -// the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// InnerRadius Inner radius of the torus (should be >= 0.0f) -// OuterRadius Outer radius of the torue (should be >= 0.0f) -// Sides Number of sides in a cross-section (must be >= 3) -// Rings Number of rings making up the torus (must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTorus( - LPDIRECT3DDEVICE8 pDevice, - FLOAT InnerRadius, - FLOAT OuterRadius, - UINT Sides, - UINT Rings, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTeapot: -// ----------------- -// Creates a mesh containing a teapot. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTeapot( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateText: -// --------------- -// Creates a mesh containing the specified text using the font associated -// with the device context. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// hDC Device context, with desired font selected -// pText Text to generate -// Deviation Maximum chordal deviation from true font outlines -// Extrusion Amount to extrude text in -Z direction -// ppMesh The mesh object which will be created -// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTextA( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -HRESULT WINAPI - D3DXCreateTextW( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCWSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -#ifdef UNICODE -#define D3DXCreateText D3DXCreateTextW -#else -#define D3DXCreateText D3DXCreateTextA -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8SHAPES_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8shapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8SHAPES_H__ +#define __D3DX8SHAPES_H__ + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: +// ------------------ +// Creates a mesh containing an n-sided polygon. The polygon is centered +// at the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Length Length of each side. +// Sides Number of sides the polygon has. (Must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Length, + UINT Sides, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateBox: +// -------------- +// Creates a mesh containing an axis-aligned box. The box is centered at +// the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Width Width of box (along X-axis) +// Height Height of box (along Y-axis) +// Depth Depth of box (along Z-axis) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Width, + FLOAT Height, + FLOAT Depth, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: +// ------------------- +// Creates a mesh containing a cylinder. The generated cylinder is +// centered at the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius1 Radius at -Z end (should be >= 0.0f) +// Radius2 Radius at +Z end (should be >= 0.0f) +// Length Length of cylinder (along Z-axis) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateSphere: +// ----------------- +// Creates a mesh containing a sphere. The sphere is centered at the +// origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius Radius of the sphere (should be >= 0.0f) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: +// ---------------- +// Creates a mesh containing a torus. The generated torus is centered at +// the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// InnerRadius Inner radius of the torus (should be >= 0.0f) +// OuterRadius Outer radius of the torue (should be >= 0.0f) +// Sides Number of sides in a cross-section (must be >= 3) +// Rings Number of rings making up the torus (must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus( + LPDIRECT3DDEVICE8 pDevice, + FLOAT InnerRadius, + FLOAT OuterRadius, + UINT Sides, + UINT Rings, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: +// ----------------- +// Creates a mesh containing a teapot. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateText: +// --------------- +// Creates a mesh containing the specified text using the font associated +// with the device context. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// hDC Device context, with desired font selected +// pText Text to generate +// Deviation Maximum chordal deviation from true font outlines +// Extrusion Amount to extrude text in -Z direction +// ppMesh The mesh object which will be created +// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextA( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +HRESULT WINAPI + D3DXCreateTextW( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCWSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +#ifdef UNICODE +#define D3DXCreateText D3DXCreateTextW +#else +#define D3DXCreateText D3DXCreateTextA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8SHAPES_H__ diff --git a/gfx/include/d3d8/d3dx8tex.h b/gfx/include/d3d8/d3dx8tex.h index 2bdfce8b82..cb30a7cf37 100644 --- a/gfx/include/d3d8/d3dx8tex.h +++ b/gfx/include/d3d8/d3dx8tex.h @@ -1,1592 +1,1592 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8tex.h -// Content: D3DX texturing APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8TEX_H__ -#define __D3DX8TEX_H__ - - -//---------------------------------------------------------------------------- -// D3DX_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR -// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | -// D3DX_FILTER_MIRROR_V -// D3DX_FILTER_DITHER -// Dithers the resulting image. -// -//---------------------------------------------------------------------------- - -#define D3DX_FILTER_NONE (1 << 0) -#define D3DX_FILTER_POINT (2 << 0) -#define D3DX_FILTER_LINEAR (3 << 0) -#define D3DX_FILTER_TRIANGLE (4 << 0) -#define D3DX_FILTER_BOX (5 << 0) - -#define D3DX_FILTER_MIRROR_U (1 << 16) -#define D3DX_FILTER_MIRROR_V (2 << 16) -#define D3DX_FILTER_MIRROR_W (4 << 16) -#define D3DX_FILTER_MIRROR (7 << 16) -#define D3DX_FILTER_DITHER (8 << 16) - - -//---------------------------------------------------------------------------- -// D3DX_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DXComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR -// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V -// D3DX_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -#define D3DX_NORMALMAP_MIRROR_U (1 << 16) -#define D3DX_NORMALMAP_MIRROR_V (2 << 16) -#define D3DX_NORMALMAP_MIRROR (3 << 16) -#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) -#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) - - - - -//---------------------------------------------------------------------------- -// D3DX_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX_CHANNEL_RED -// Indicates the red channel should be used -// D3DX_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- - -#define D3DX_CHANNEL_RED (1 << 0) -#define D3DX_CHANNEL_BLUE (1 << 1) -#define D3DX_CHANNEL_GREEN (1 << 2) -#define D3DX_CHANNEL_ALPHA (1 << 3) -#define D3DX_CHANNEL_LUMINANCE (1 << 4) - - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_FILEFORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- - -typedef enum _D3DXIMAGE_FILEFORMAT -{ - D3DXIFF_BMP = 0, - D3DXIFF_JPG = 1, - D3DXIFF_TGA = 2, - D3DXIFF_PNG = 3, - D3DXIFF_DDS = 4, - D3DXIFF_PPM = 5, - D3DXIFF_DIB = 6, - D3DXIFF_FORCE_DWORD = 0x7fffffff - -} D3DXIMAGE_FILEFORMAT; - - -//---------------------------------------------------------------------------- -// LPD3DXFILL2D and LPD3DXFILL3D: -// ------------------------------ -// Function types used by the texture fill functions. -// -// Parameters: -// pOut -// Pointer to a vector which the function uses to return its result. -// X,Y,Z,W will be mapped to R,G,B,A respectivly. -// pTexCoord -// Pointer to a vector containing the coordinates of the texel currently -// being evaluated. Textures and VolumeTexture texcoord components -// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. -// pTexelSize -// Pointer to a vector containing the dimensions of the current texel. -// pData -// Pointer to user data. -// -//---------------------------------------------------------------------------- - -typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); -typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DXIMAGE_FILEFORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- - -typedef struct _D3DXIMAGE_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT MipLevels; - D3DFORMAT Format; - D3DRESOURCETYPE ResourceType; - D3DXIMAGE_FILEFORMAT ImageFileFormat; - -} D3DXIMAGE_INFO; - - - - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -; -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource: -// ------------------------------ -// Fills in a D3DXIMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetImageInfoFromFileA( - LPCSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromFileW( - LPCWSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW -#else -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW -#else -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromFileInMemory( - LPCVOID pSrcData, - UINT SrcDataSize, - D3DXIMAGE_INFO* pSrcInfo); - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Surface APIs //////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromFile/Resource: -// --------------------------------- -// Load surface from a file or resource -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcRect -// Source rectangle, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromFileA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromFileW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCWSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW -#else -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - -#ifdef UNICODE -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW -#else -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromFileInMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromSurface: -// --------------------------- -// Load surface from another surface (with color conversion) -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcSurface -// Source surface -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for entire surface -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromSurface( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromMemory: -// -------------------------- -// Load surface from memory. -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcMemory -// Pointer to the top-left corner of the source image in memory -// SrcFormat -// Pixel format of the source image. -// SrcPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the width of one row of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcPitch, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFile: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveSurfaceToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -HRESULT WINAPI - D3DXSaveSurfaceToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -#ifdef UNICODE -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW -#else -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Volume APIs ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromFile/Resource: -// -------------------------------- -// Load volume from a file or resource -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcBox -// Source box, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromFileA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromFileW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCWSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW -#else -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA -#endif - - -HRESULT WINAPI - D3DXLoadVolumeFromResourceA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromResourceW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW -#else -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadVolumeFromFileInMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromVolume: -// ------------------------- -// Load volume from another volume (with color conversion) -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcVolume -// Source volume -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for entire volume -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromVolume( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromMemory: -// ------------------------- -// Load volume from memory. -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcMemory -// Pointer to the top-left corner of the source volume in memory -// SrcFormat -// Pixel format of the source volume. -// SrcRowPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one row of cells, in bytes. -// SrcSlicePitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one slice of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcRowPitch, - UINT SrcSlicePitch, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFile: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveVolumeToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -HRESULT WINAPI - D3DXSaveVolumeToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -#ifdef UNICODE -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW -#else -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: -// ----------------------------- -// Checks texture creation parameters. If parameters are invalid, this -// function returns corrected parameters. -// -// Parameters: -// -// pDevice -// The D3D device to be used -// pWidth, pHeight, pDepth, pSize -// Desired size in pixels, or NULL. Returns corrected size. -// pNumMipLevels -// Number of desired mipmap levels, or NULL. Returns corrected number. -// Usage -// Texture usage flags -// pFormat -// Desired pixel format, or NULL. Returns corrected format. -// Pool -// Memory pool to be used to create texture -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCheckTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckCubeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pSize, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckVolumeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pDepth, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - - -//---------------------------------------------------------------------------- -// D3DXCreateTexture: -// ------------------ -// Create an empty texture -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// Width, Height, Depth, Size -// size in pixels; these must be non-zero -// MipLevels -// number of mip levels desired; if zero or D3DX_DEFAULT, a complete -// mipmap chain will be created. -// Usage -// Texture usage flags -// Format -// Pixel format. -// Pool -// Memory pool to be used to create texture -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXCreateTextureFromFile/Resource: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// Width, Height, Depth, Size -// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken -// from the file. -// MipLevels -// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap -// chain will be created. -// Usage -// Texture usage flags -// Format -// Desired pixel format. If D3DFMT_UNKNOWN, the format will be -// taken from the file. -// Pool -// Memory pool to be used to create texture -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// MipFilter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// pPalette -// 256 color palette to be filled in, or NULL -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - - -// FromFile - -HRESULT WINAPI - D3DXCreateTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW -#else -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW -#else -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW -#else -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA -#endif - - -// FromResource - -HRESULT WINAPI - D3DXCreateTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW -#else -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW -#else -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW -#else -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA -#endif - - -// FromFileEx - -HRESULT WINAPI - D3DXCreateTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW -#else -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW -#else -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW -#else -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA -#endif - - -// FromResourceEx - -HRESULT WINAPI - D3DXCreateTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW -#else -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW -#else -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW -#else -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA -#endif - - -// FromFileInMemory - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - -// FromFileInMemoryEx - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DXSaveTextureToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -HRESULT WINAPI - D3DXSaveTextureToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -#ifdef UNICODE -#define D3DXSaveTextureToFile D3DXSaveTextureToFileW -#else -#define D3DXSaveTextureToFile D3DXSaveTextureToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Misc Texture APIs ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXFilterTexture: -// ------------------ -// Filters mipmaps levels of a texture. -// -// Parameters: -// pBaseTexture -// The texture object to be filtered -// pPalette -// 256 color palette to be used, or NULL for non-palettized formats -// SrcLevel -// The level whose image is used to generate the subsequent levels. -// Filter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFilterTexture( - LPDIRECT3DBASETEXTURE8 pBaseTexture, - CONST PALETTEENTRY* pPalette, - UINT SrcLevel, - DWORD Filter); - -#define D3DXFilterCubeTexture D3DXFilterTexture -#define D3DXFilterVolumeTexture D3DXFilterTexture - - - -//---------------------------------------------------------------------------- -// D3DXFillTexture: -// ---------------- -// Uses a user provided function to fill each texel of each mip level of a -// given texture. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pFunction -// Pointer to user provided evalutor function which will be used to -// compute the value of each texel. -// pData -// Pointer to an arbitrary block of user defined data. This pointer -// will be passed to the function provided in pFunction -//----------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFillTexture( - LPDIRECT3DTEXTURE8 pTexture, - LPD3DXFILL2D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillCubeTexture( - LPDIRECT3DCUBETEXTURE8 pCubeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillVolumeTexture( - LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pTexture -// Pointer to the destination texture -// pSrcTexture -// Pointer to the source heightmap texture -// pSrcPalette -// Source palette of 256 colors, or NULL -// Flags -// D3DX_NORMALMAP flags -// Channel -// D3DX_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -//--------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXComputeNormalMap( - LPDIRECT3DTEXTURE8 pTexture, - LPDIRECT3DTEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette, - DWORD Flags, - DWORD Channel, - FLOAT Amplitude); - - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8TEX_H__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8tex.h +// Content: D3DX texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8TEX_H__ +#define __D3DX8TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR +// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | +// D3DX_FILTER_MIRROR_V +// D3DX_FILTER_DITHER +// Dithers the resulting image. +// +//---------------------------------------------------------------------------- + +#define D3DX_FILTER_NONE (1 << 0) +#define D3DX_FILTER_POINT (2 << 0) +#define D3DX_FILTER_LINEAR (3 << 0) +#define D3DX_FILTER_TRIANGLE (4 << 0) +#define D3DX_FILTER_BOX (5 << 0) + +#define D3DX_FILTER_MIRROR_U (1 << 16) +#define D3DX_FILTER_MIRROR_V (2 << 16) +#define D3DX_FILTER_MIRROR_W (4 << 16) +#define D3DX_FILTER_MIRROR (7 << 16) +#define D3DX_FILTER_DITHER (8 << 16) + + +//---------------------------------------------------------------------------- +// D3DX_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DXComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR +// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V +// D3DX_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +#define D3DX_NORMALMAP_MIRROR_U (1 << 16) +#define D3DX_NORMALMAP_MIRROR_V (2 << 16) +#define D3DX_NORMALMAP_MIRROR (3 << 16) +#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) +#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) + + + + +//---------------------------------------------------------------------------- +// D3DX_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX_CHANNEL_RED +// Indicates the red channel should be used +// D3DX_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +#define D3DX_CHANNEL_RED (1 << 0) +#define D3DX_CHANNEL_BLUE (1 << 1) +#define D3DX_CHANNEL_GREEN (1 << 2) +#define D3DX_CHANNEL_ALPHA (1 << 3) +#define D3DX_CHANNEL_LUMINANCE (1 << 4) + + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_FILEFORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DXIMAGE_FILEFORMAT +{ + D3DXIFF_BMP = 0, + D3DXIFF_JPG = 1, + D3DXIFF_TGA = 2, + D3DXIFF_PNG = 3, + D3DXIFF_DDS = 4, + D3DXIFF_PPM = 5, + D3DXIFF_DIB = 6, + D3DXIFF_FORCE_DWORD = 0x7fffffff + +} D3DXIMAGE_FILEFORMAT; + + +//---------------------------------------------------------------------------- +// LPD3DXFILL2D and LPD3DXFILL3D: +// ------------------------------ +// Function types used by the texture fill functions. +// +// Parameters: +// pOut +// Pointer to a vector which the function uses to return its result. +// X,Y,Z,W will be mapped to R,G,B,A respectivly. +// pTexCoord +// Pointer to a vector containing the coordinates of the texel currently +// being evaluated. Textures and VolumeTexture texcoord components +// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. +// pTexelSize +// Pointer to a vector containing the dimensions of the current texel. +// pData +// Pointer to user data. +// +//---------------------------------------------------------------------------- + +typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); +typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DXIMAGE_FILEFORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DXIMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + D3DFORMAT Format; + D3DRESOURCETYPE ResourceType; + D3DXIMAGE_FILEFORMAT ImageFileFormat; + +} D3DXIMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +; +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource: +// ------------------------------ +// Fills in a D3DXIMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetImageInfoFromFileA( + LPCSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromFileW( + LPCWSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW +#else +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW +#else +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO* pSrcInfo); + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Surface APIs //////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromFile/Resource: +// --------------------------------- +// Load surface from a file or resource +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcRect +// Source rectangle, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromFileA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromFileW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCWSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW +#else +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + +#ifdef UNICODE +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW +#else +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromFileInMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromSurface: +// --------------------------- +// Load surface from another surface (with color conversion) +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcSurface +// Source surface +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for entire surface +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromSurface( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromMemory: +// -------------------------- +// Load surface from memory. +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcMemory +// Pointer to the top-left corner of the source image in memory +// SrcFormat +// Pixel format of the source image. +// SrcPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the width of one row of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcPitch, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFile: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +HRESULT WINAPI + D3DXSaveSurfaceToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +#ifdef UNICODE +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW +#else +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Volume APIs ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromFile/Resource: +// -------------------------------- +// Load volume from a file or resource +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcBox +// Source box, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromFileA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromFileW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCWSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW +#else +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA +#endif + + +HRESULT WINAPI + D3DXLoadVolumeFromResourceA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromResourceW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW +#else +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadVolumeFromFileInMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromVolume: +// ------------------------- +// Load volume from another volume (with color conversion) +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcVolume +// Source volume +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for entire volume +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromVolume( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromMemory: +// ------------------------- +// Load volume from memory. +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcMemory +// Pointer to the top-left corner of the source volume in memory +// SrcFormat +// Pixel format of the source volume. +// SrcRowPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one row of cells, in bytes. +// SrcSlicePitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one slice of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcRowPitch, + UINT SrcSlicePitch, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFile: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +HRESULT WINAPI + D3DXSaveVolumeToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +#ifdef UNICODE +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW +#else +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: +// ----------------------------- +// Checks texture creation parameters. If parameters are invalid, this +// function returns corrected parameters. +// +// Parameters: +// +// pDevice +// The D3D device to be used +// pWidth, pHeight, pDepth, pSize +// Desired size in pixels, or NULL. Returns corrected size. +// pNumMipLevels +// Number of desired mipmap levels, or NULL. Returns corrected number. +// Usage +// Texture usage flags +// pFormat +// Desired pixel format, or NULL. Returns corrected format. +// Pool +// Memory pool to be used to create texture +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCheckTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckCubeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pSize, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckVolumeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pDepth, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + + +//---------------------------------------------------------------------------- +// D3DXCreateTexture: +// ------------------ +// Create an empty texture +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// Width, Height, Depth, Size +// size in pixels; these must be non-zero +// MipLevels +// number of mip levels desired; if zero or D3DX_DEFAULT, a complete +// mipmap chain will be created. +// Usage +// Texture usage flags +// Format +// Pixel format. +// Pool +// Memory pool to be used to create texture +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureFromFile/Resource: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// Width, Height, Depth, Size +// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken +// from the file. +// MipLevels +// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap +// chain will be created. +// Usage +// Texture usage flags +// Format +// Desired pixel format. If D3DFMT_UNKNOWN, the format will be +// taken from the file. +// Pool +// Memory pool to be used to create texture +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// MipFilter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// pPalette +// 256 color palette to be filled in, or NULL +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + + +// FromFile + +HRESULT WINAPI + D3DXCreateTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW +#else +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW +#else +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW +#else +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA +#endif + + +// FromResource + +HRESULT WINAPI + D3DXCreateTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW +#else +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW +#else +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW +#else +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA +#endif + + +// FromFileEx + +HRESULT WINAPI + D3DXCreateTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW +#else +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW +#else +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW +#else +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA +#endif + + +// FromResourceEx + +HRESULT WINAPI + D3DXCreateTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW +#else +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW +#else +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW +#else +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + +// FromFileInMemoryEx + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXSaveTextureToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +HRESULT WINAPI + D3DXSaveTextureToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +#ifdef UNICODE +#define D3DXSaveTextureToFile D3DXSaveTextureToFileW +#else +#define D3DXSaveTextureToFile D3DXSaveTextureToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Misc Texture APIs ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXFilterTexture: +// ------------------ +// Filters mipmaps levels of a texture. +// +// Parameters: +// pBaseTexture +// The texture object to be filtered +// pPalette +// 256 color palette to be used, or NULL for non-palettized formats +// SrcLevel +// The level whose image is used to generate the subsequent levels. +// Filter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFilterTexture( + LPDIRECT3DBASETEXTURE8 pBaseTexture, + CONST PALETTEENTRY* pPalette, + UINT SrcLevel, + DWORD Filter); + +#define D3DXFilterCubeTexture D3DXFilterTexture +#define D3DXFilterVolumeTexture D3DXFilterTexture + + + +//---------------------------------------------------------------------------- +// D3DXFillTexture: +// ---------------- +// Uses a user provided function to fill each texel of each mip level of a +// given texture. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pFunction +// Pointer to user provided evalutor function which will be used to +// compute the value of each texel. +// pData +// Pointer to an arbitrary block of user defined data. This pointer +// will be passed to the function provided in pFunction +//----------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTexture( + LPDIRECT3DTEXTURE8 pTexture, + LPD3DXFILL2D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillCubeTexture( + LPDIRECT3DCUBETEXTURE8 pCubeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillVolumeTexture( + LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pTexture +// Pointer to the destination texture +// pSrcTexture +// Pointer to the source heightmap texture +// pSrcPalette +// Source palette of 256 colors, or NULL +// Flags +// D3DX_NORMALMAP flags +// Channel +// D3DX_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXComputeNormalMap( + LPDIRECT3DTEXTURE8 pTexture, + LPDIRECT3DTEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8TEX_H__ diff --git a/gfx/include/d3d9/d3dx9anim.h b/gfx/include/d3d9/d3dx9anim.h index ecdabdc52c..0d0a945344 100644 --- a/gfx/include/d3d9/d3dx9anim.h +++ b/gfx/include/d3d9/d3dx9anim.h @@ -10,19 +10,19 @@ #define __D3DX9ANIM_H__ /* {698CFB3F-9289-4d95-9A57-33A94B5A65F9} */ -DEFINE_GUID(IID_ID3DXAnimationSet, +DEFINE_GUID(IID_ID3DXAnimationSet, 0x698cfb3f, 0x9289, 0x4d95, 0x9a, 0x57, 0x33, 0xa9, 0x4b, 0x5a, 0x65, 0xf9); /* {FA4E8E3A-9786-407d-8B4C-5995893764AF} */ -DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, +DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, 0xfa4e8e3a, 0x9786, 0x407d, 0x8b, 0x4c, 0x59, 0x95, 0x89, 0x37, 0x64, 0xaf); /* {6CC2480D-3808-4739-9F88-DE49FACD8D4C} */ -DEFINE_GUID(IID_ID3DXCompressedAnimationSet, +DEFINE_GUID(IID_ID3DXCompressedAnimationSet, 0x6cc2480d, 0x3808, 0x4739, 0x9f, 0x88, 0xde, 0x49, 0xfa, 0xcd, 0x8d, 0x4c); /* {AC8948EC-F86D-43e2-96DE-31FC35F96D9E} */ -DEFINE_GUID(IID_ID3DXAnimationController, +DEFINE_GUID(IID_ID3DXAnimationController, 0xac8948ec, 0xf86d, 0x43e2, 0x96, 0xde, 0x31, 0xfc, 0x35, 0xf9, 0x6d, 0x9e); typedef enum _D3DXMESHDATATYPE @@ -82,22 +82,22 @@ typedef interface ID3DXAllocateHierarchy *LPD3DXALLOCATEHIERARCHY; DECLARE_INTERFACE(ID3DXAllocateHierarchy) { - STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, + STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, LPD3DXFRAME *ppNewFrame) PURE; - STDMETHOD(CreateMeshContainer)(THIS_ - LPCSTR Name, - CONST D3DXMESHDATA *pMeshData, - CONST D3DXMATERIAL *pMaterials, - CONST D3DXEFFECTINSTANCE *pEffectInstances, - DWORD NumMaterials, - CONST DWORD *pAdjacency, - LPD3DXSKININFO pSkinInfo, + STDMETHOD(CreateMeshContainer)(THIS_ + LPCSTR Name, + CONST D3DXMESHDATA *pMeshData, + CONST D3DXMATERIAL *pMaterials, + CONST D3DXEFFECTINSTANCE *pEffectInstances, + DWORD NumMaterials, + CONST DWORD *pAdjacency, + LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE; - STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; + STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; - STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; + STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; }; typedef interface ID3DXLoadUserData ID3DXLoadUserData; @@ -109,12 +109,12 @@ typedef interface ID3DXLoadUserData *LPD3DXLOADUSERDATA; DECLARE_INTERFACE(ID3DXLoadUserData) { STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, + + STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, + LPD3DXFILEDATA pXofChildData) PURE; + + STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, - LPD3DXFILEDATA pXofChildData) PURE; }; typedef interface ID3DXSaveUserData ID3DXSaveUserData; @@ -125,22 +125,22 @@ typedef interface ID3DXSaveUserData *LPD3DXSAVEUSERDATA; DECLARE_INTERFACE(ID3DXSaveUserData) { - STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, - LPD3DXFILESAVEOBJECT pXofSave, + STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, + LPD3DXFILESAVEOBJECT pXofSave, LPD3DXFILESAVEDATA pXofFrameData) PURE; - - STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, - LPD3DXFILESAVEOBJECT pXofSave, + + STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, + LPD3DXFILESAVEOBJECT pXofSave, LPD3DXFILESAVEDATA pXofMeshData) PURE; - - /* NOTE: this is called once per Save. All top level objects should be added using the + + /* NOTE: this is called once per Save. All top level objects should be added using the * provided interface. One call adds objects before the frame hierarchy, the other after */ - STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; - STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; /* callbacks for the user to register and then save templates to the XFile */ - STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; - STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; + STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; }; typedef enum _D3DXCALLBACK_SEARCH_FLAGS @@ -177,7 +177,7 @@ DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -185,7 +185,7 @@ DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -252,7 +252,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -260,7 +260,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -300,7 +300,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) STDMETHOD(UnregisterTranslationKey)(THIS_ UINT Animation, UINT Key) PURE; /* One-time animaton SRT keyframe registration */ - STDMETHOD(RegisterAnimationSRTKeys)(THIS_ + STDMETHOD(RegisterAnimationSRTKeys)(THIS_ LPCSTR pName, /* Animation name */ UINT NumScaleKeys, /* Number of scale keys */ UINT NumRotationKeys, /* Number of rotation keys */ @@ -311,7 +311,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) DWORD *pAnimationIndex) PURE; /* Returns the animation index */ /* Compression */ - STDMETHOD(Compress)(THIS_ + STDMETHOD(Compress)(THIS_ DWORD Flags, /* Compression flags (use D3DXCOMPRESS_STRONG for better results) */ FLOAT Lossiness, /* Compression loss ratio in the [0, 1] range */ LPD3DXFRAME pHierarchy, /* Frame hierarchy (optional) */ @@ -352,7 +352,7 @@ DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -360,7 +360,7 @@ DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -441,7 +441,7 @@ typedef interface ID3DXAnimationCallbackHandler *LPD3DXANIMATIONCALLBACKHANDLER; DECLARE_INTERFACE(ID3DXAnimationCallbackHandler) { - STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; + STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; }; typedef interface ID3DXAnimationController ID3DXAnimationController; @@ -464,11 +464,11 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) STDMETHOD_(UINT, GetMaxNumEvents)(THIS) PURE; /* Animation output registration */ - STDMETHOD(RegisterAnimationOutput)(THIS_ - LPCSTR pName, - D3DXMATRIX *pMatrix, - D3DXVECTOR3 *pScale, - D3DXQUATERNION *pRotation, + STDMETHOD(RegisterAnimationOutput)(THIS_ + LPCSTR pName, + D3DXMATRIX *pMatrix, + D3DXVECTOR3 *pScale, + D3DXQUATERNION *pRotation, D3DXVECTOR3 *pTranslation) PURE; /* Animation set registration */ @@ -528,11 +528,11 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) STDMETHOD(GetEventDesc)(THIS_ D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc) PURE; /* Cloning */ - STDMETHOD(CloneAnimationController)(THIS_ - UINT MaxNumAnimationOutputs, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, + STDMETHOD(CloneAnimationController)(THIS_ + UINT MaxNumAnimationOutputs, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, LPD3DXANIMATIONCONTROLLER *ppAnimController) PURE; }; @@ -540,26 +540,26 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) extern "C" { #endif /* __cplusplus */ -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXA ( LPCSTR Filename, DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXW ( LPCWSTR Filename, DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); @@ -570,7 +570,7 @@ D3DXLoadMeshHierarchyFromXW #define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory ( LPCVOID Memory, @@ -578,27 +578,27 @@ D3DXLoadMeshHierarchyFromXInMemory DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshHierarchyToFileA ( LPCSTR Filename, DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, + CONST D3DXFRAME *pFrameRoot, LPD3DXANIMATIONCONTROLLER pAnimcontroller, LPD3DXSAVEUSERDATA pUserDataSaver ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshHierarchyToFileW ( LPCWSTR Filename, DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, + CONST D3DXFRAME *pFrameRoot, LPD3DXANIMATIONCONTROLLER pAnimController, LPD3DXSAVEUSERDATA pUserDataSaver ); @@ -616,14 +616,14 @@ D3DXFrameDestroy LPD3DXALLOCATEHIERARCHY pAlloc ); -HRESULT WINAPI +HRESULT WINAPI D3DXFrameAppendChild ( LPD3DXFRAME pFrameParent, CONST D3DXFRAME *pFrameChild ); -LPD3DXFRAME WINAPI +LPD3DXFRAME WINAPI D3DXFrameFind ( CONST D3DXFRAME *pFrameRoot, @@ -640,7 +640,7 @@ D3DXFrameRegisterNamedMatrices /* * D3DXFrameNumNamedMatrices: * -------------------------- - * Counts number of frames in a subtree that have non-null names + * Counts number of frames in a subtree that have non-null names * * Parameters: * pFrameRoot @@ -672,9 +672,9 @@ D3DXFrameNumNamedMatrices HRESULT WINAPI D3DXFrameCalculateBoundingSphere ( - CONST D3DXFRAME *pFrameRoot, - LPD3DXVECTOR3 pObjectCenter, - FLOAT *pObjectRadius + CONST D3DXFRAME *pFrameRoot, + LPD3DXVECTOR3 pObjectCenter, + FLOAT *pObjectRadius ); @@ -682,7 +682,7 @@ D3DXFrameCalculateBoundingSphere * D3DXCreateKeyframedAnimationSet: * -------------------------------- * This function creates a compressable keyframed animations set interface. - * + * * Parameters: * pName * Name of the animation set @@ -698,28 +698,28 @@ D3DXFrameCalculateBoundingSphere * Array of callback keys * ppAnimationSet * Returns the animation set interface - * + * */ HRESULT WINAPI D3DXCreateKeyframedAnimationSet ( - LPCSTR pName, + LPCSTR pName, DOUBLE TicksPerSecond, D3DXPLAYBACK_TYPE Playback, - UINT NumAnimations, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet + UINT NumAnimations, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet ); /* * D3DXCreateCompressedAnimationSet: * -------------------------------- - * This function creates a compressed animations set interface from + * This function creates a compressed animations set interface from * compressed data. - * + * * Parameters: * pName * Name of the animation set @@ -735,28 +735,28 @@ D3DXCreateKeyframedAnimationSet * Array of callback keys * ppAnimationSet * Returns the animation set interface - * + * */ HRESULT WINAPI D3DXCreateCompressedAnimationSet ( - LPCSTR pName, + LPCSTR pName, DOUBLE TicksPerSecond, D3DXPLAYBACK_TYPE Playback, - LPD3DXBUFFER pCompressedData, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet + LPD3DXBUFFER pCompressedData, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet ); HRESULT WINAPI D3DXCreateAnimationController ( - UINT MaxNumMatrices, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, + UINT MaxNumMatrices, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, LPD3DXANIMATIONCONTROLLER *ppAnimController ); diff --git a/gfx/include/d3d9/d3dx9core.h b/gfx/include/d3d9/d3dx9core.h index c3df8ce5c3..e3e10bd37e 100644 --- a/gfx/include/d3d9/d3dx9core.h +++ b/gfx/include/d3d9/d3dx9core.h @@ -24,7 +24,7 @@ BOOL WINAPI D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); BOOL WINAPI - D3DXDebugMute(BOOL Mute); + D3DXDebugMute(BOOL Mute); UINT WINAPI D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); @@ -37,7 +37,7 @@ typedef interface ID3DXBuffer ID3DXBuffer; typedef interface ID3DXBuffer *LPD3DXBUFFER; // {8BA5FB08-5195-40e2-AC58-0D989C3A0102} -DEFINE_GUID(IID_ID3DXBuffer, +DEFINE_GUID(IID_ID3DXBuffer, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); #undef INTERFACE @@ -70,7 +70,7 @@ typedef interface ID3DXSprite *LPD3DXSPRITE; // {BA0B762D-7D28-43ec-B9DC-2F84443B0614} -DEFINE_GUID(IID_ID3DXSprite, +DEFINE_GUID(IID_ID3DXSprite, 0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); @@ -107,9 +107,9 @@ DECLARE_INTERFACE_(ID3DXSprite, IUnknown) extern "C" { #endif //__cplusplus -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE9 pDevice, +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE* ppSprite); #ifdef __cplusplus @@ -160,7 +160,7 @@ typedef interface ID3DXFont *LPD3DXFONT; // {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} -DEFINE_GUID(IID_ID3DXFont, +DEFINE_GUID(IID_ID3DXFont, 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); @@ -228,9 +228,9 @@ extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXCreateFontA( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, @@ -243,9 +243,9 @@ HRESULT WINAPI LPCSTR pFaceName, LPD3DXFONT* ppFont); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateFontW( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, @@ -265,16 +265,16 @@ HRESULT WINAPI #endif -HRESULT WINAPI - D3DXCreateFontIndirectA( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCA* pDesc, +HRESULT WINAPI + D3DXCreateFontIndirectA( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCA* pDesc, LPD3DXFONT* ppFont); -HRESULT WINAPI - D3DXCreateFontIndirectW( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCW* pDesc, +HRESULT WINAPI + D3DXCreateFontIndirectW( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCW* pDesc, LPD3DXFONT* ppFont); #ifdef UNICODE @@ -304,7 +304,7 @@ typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; // {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} -DEFINE_GUID(IID_ID3DXRenderToSurface, +DEFINE_GUID(IID_ID3DXRenderToSurface, 0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); @@ -364,7 +364,7 @@ typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; // {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} -DEFINE_GUID(IID_ID3DXRenderToEnvMap, +DEFINE_GUID(IID_ID3DXRenderToEnvMap, 0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); @@ -382,17 +382,17 @@ DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - STDMETHOD(BeginCube)(THIS_ + STDMETHOD(BeginCube)(THIS_ LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; STDMETHOD(BeginSphere)(THIS_ LPDIRECT3DTEXTURE9 pTex) PURE; - STDMETHOD(BeginHemisphere)(THIS_ + STDMETHOD(BeginHemisphere)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; - STDMETHOD(BeginParabolic)(THIS_ + STDMETHOD(BeginParabolic)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; @@ -427,7 +427,7 @@ typedef interface ID3DXLine *LPD3DXLINE; // {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} -DEFINE_GUID(IID_ID3DXLine, +DEFINE_GUID(IID_ID3DXLine, 0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); #undef INTERFACE @@ -449,7 +449,7 @@ DECLARE_INTERFACE_(ID3DXLine, IUnknown) DWORD dwVertexListCount, D3DCOLOR Color) PURE; STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, - DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, + DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, D3DCOLOR Color) PURE; STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; diff --git a/gfx/include/d3d9/d3dx9effect.h b/gfx/include/d3d9/d3dx9effect.h index 4fbb3f75aa..3947c7a91b 100644 --- a/gfx/include/d3d9/d3dx9effect.h +++ b/gfx/include/d3d9/d3dx9effect.h @@ -108,7 +108,7 @@ typedef interface ID3DXEffectPool ID3DXEffectPool; typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL; // {9537AB04-3250-412e-8213-FCD2F8677933} -DEFINE_GUID(IID_ID3DXEffectPool, +DEFINE_GUID(IID_ID3DXEffectPool, 0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); @@ -134,7 +134,7 @@ typedef interface ID3DXBaseEffect ID3DXBaseEffect; typedef interface ID3DXBaseEffect *LPD3DXBASEEFFECT; // {017C18AC-103F-4417-8C51-6BF6EF1E56BE} -DEFINE_GUID(IID_ID3DXBaseEffect, +DEFINE_GUID(IID_ID3DXBaseEffect, 0x17c18ac, 0x103f, 0x4417, 0x8c, 0x51, 0x6b, 0xf6, 0xef, 0x1e, 0x56, 0xbe); @@ -209,7 +209,7 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) //Set Range of an Array to pass to device //Useful for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; }; @@ -217,7 +217,7 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) //---------------------------------------------------------------------------- // ID3DXEffectStateManager: // ------------------------ -// This is a user implemented interface that can be used to manage device +// This is a user implemented interface that can be used to manage device // state changes made by an Effect. //---------------------------------------------------------------------------- @@ -225,7 +225,7 @@ typedef interface ID3DXEffectStateManager ID3DXEffectStateManager; typedef interface ID3DXEffectStateManager *LPD3DXEFFECTSTATEMANAGER; // {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} -DEFINE_GUID(IID_ID3DXEffectStateManager, +DEFINE_GUID(IID_ID3DXEffectStateManager, 0x79aab587, 0x6dbc, 0x4fa7, 0x82, 0xde, 0x37, 0xfa, 0x17, 0x81, 0xc5, 0xce); #undef INTERFACE @@ -240,11 +240,11 @@ DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // The following methods are called by the Effect when it wants to make + // The following methods are called by the Effect when it wants to make // the corresponding device call. Note that: - // 1. Users manage the state and are therefore responsible for making the - // the corresponding device calls themselves inside their callbacks. - // 2. Effects pay attention to the return values of the callbacks, and so + // 1. Users manage the state and are therefore responsible for making the + // the corresponding device calls themselves inside their callbacks. + // 2. Effects pay attention to the return values of the callbacks, and so // users must pay attention to what they return in their callbacks. STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix) PURE; @@ -276,7 +276,7 @@ typedef interface ID3DXEffect ID3DXEffect; typedef interface ID3DXEffect *LPD3DXEFFECT; // {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} -DEFINE_GUID(IID_ID3DXEffect, +DEFINE_GUID(IID_ID3DXEffect, 0xf6ceb4b3, 0x4e4c, 0x40dd, 0xb8, 0x83, 0x8d, 0x8d, 0xe5, 0xea, 0xc, 0xd5); #undef INTERFACE @@ -350,10 +350,10 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) //Set Range of an Array to pass to device //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; // ID3DXBaseEffect - - + + // Pool STDMETHOD(GetPool)(THIS_ LPD3DXEFFECTPOOL* ppPool) PURE; @@ -394,7 +394,7 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) // Cloning STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect) PURE; - + // Fast path for setting variables directly in ID3DXEffect STDMETHOD(SetRawValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes) PURE; }; @@ -407,7 +407,7 @@ typedef interface ID3DXEffectCompiler ID3DXEffectCompiler; typedef interface ID3DXEffectCompiler *LPD3DXEFFECTCOMPILER; // {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} -DEFINE_GUID(IID_ID3DXEffectCompiler, +DEFINE_GUID(IID_ID3DXEffectCompiler, 0x51b8a949, 0x1a31, 0x47e6, 0xbe, 0xa0, 0x4b, 0x30, 0xdb, 0x53, 0xf1, 0xe0); @@ -479,10 +479,10 @@ DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - + //Set Range of an Array to pass to device //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; // ID3DXBaseEffect // Parameter sharing, specialization, and information @@ -588,7 +588,7 @@ HRESULT WINAPI LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -600,7 +600,7 @@ HRESULT WINAPI LPCWSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -620,7 +620,7 @@ HRESULT WINAPI LPCSTR pSrcResource, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -633,7 +633,7 @@ HRESULT WINAPI LPCWSTR pSrcResource, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -653,7 +653,7 @@ HRESULT WINAPI UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -721,10 +721,10 @@ HRESULT WINAPI LPD3DXEFFECTCOMPILER* ppCompiler, LPD3DXBUFFER* ppParseErrors); -HRESULT WINAPI +HRESULT WINAPI D3DXDisassembleEffect( - LPD3DXEFFECT pEffect, - BOOL EnableColorCode, + LPD3DXEFFECT pEffect, + BOOL EnableColorCode, LPD3DXBUFFER *ppDisassembly); #ifdef __cplusplus diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index 165014b0df..f861629e0d 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -362,7 +362,7 @@ typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; * This class helps keep matrices 16-byte aligned as preferred by P4 cpus. * It aligns matrices on the stack and on the heap or in global scope. * It does this using __declspec(align(16)) which works on VC7 and on VC 6 - * with the processor pack. Unfortunately there is no way to detect the + * with the processor pack. Unfortunately there is no way to detect the * latter so this is turned on only on VC7. On other compilers this is the * the same as D3DXMATRIX. * @@ -392,7 +392,7 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX /* delete operators */ void operator delete ( void* ); /* These are NOT virtual; Do not */ void operator delete[] ( void* ); /* cast to D3DXMATRIX and delete. */ - + /* assignment operators */ _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); @@ -662,7 +662,7 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformCoord // Transform (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - + // Transform Array (x, y, 0, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec2TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); @@ -674,8 +674,8 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray // Transform Array (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - - + + #ifdef __cplusplus } @@ -754,14 +754,14 @@ D3DXVECTOR4* WINAPI D3DXVec3Transform D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the // transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - - -// Transform Array (x, y, z, 1) by matrix. + + +// Transform Array (x, y, z, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec3TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -769,8 +769,8 @@ D3DXVECTOR4* WINAPI D3DXVec3TransformArray D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the // transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -784,7 +784,7 @@ D3DXVECTOR3* WINAPI D3DXVec3Project D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - + // Project vector Array from object space into screen space D3DXVECTOR3* WINAPI D3DXVec3ProjectArray ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, @@ -871,7 +871,7 @@ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric // Transform vector by matrix. D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - + // Transform vector array by matrix. D3DXVECTOR4* WINAPI D3DXVec4TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -903,7 +903,7 @@ FLOAT WINAPI D3DXMatrixDeterminant ( CONST D3DXMATRIX *pM ); HRESULT WINAPI D3DXMatrixDecompose - ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, + ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); D3DXMATRIX* WINAPI D3DXMatrixTranspose @@ -968,9 +968,9 @@ D3DXMATRIX* WINAPI D3DXMatrixTransformation // Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixTransformation2D - ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, - FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, + FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); // Build affine transformation matrix. NULL arguments are treated as identity. @@ -982,7 +982,7 @@ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation // Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); // Build a lookat matrix. (right-handed) @@ -1126,7 +1126,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionLn // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - + // Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). // Expects unit quaternions. D3DXQUATERNION* WINAPI D3DXQuaternionSlerp @@ -1141,11 +1141,11 @@ D3DXQUATERNION* WINAPI D3DXQuaternionSquad CONST D3DXQUATERNION *pC, FLOAT t ); // Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way +// from Q1 to Q2. The control points are chosen in such a way // to ensure the continuity of tangents with adjacent segments. void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); // Barycentric interpolation. @@ -1209,7 +1209,7 @@ D3DXPLANE* WINAPI D3DXPlaneFromPoints // M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - + // Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. // M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransformArray @@ -1276,7 +1276,7 @@ extern "C" { // Calculate Fresnel term given the cosine of theta (likely obtained by // taking the dot of two normals), and the refraction index of the material. FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); + (FLOAT CosTheta, FLOAT RefractionIndex); #ifdef __cplusplus } @@ -1292,7 +1292,7 @@ typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; // {C7885BA7-F990-4fe7-922D-8515E477DD85} -DEFINE_GUID(IID_ID3DXMatrixStack, +DEFINE_GUID(IID_ID3DXMatrixStack, 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); @@ -1387,9 +1387,9 @@ DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) extern "C" { #endif -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, LPD3DXMATRIXSTACK* ppStack); #ifdef __cplusplus @@ -1402,7 +1402,7 @@ HRESULT WINAPI // // NOTE: // * Most of these functions can take the same object as in and out parameters. -// The exceptions are the rotation functions. +// The exceptions are the rotation functions. // // * Out parameters are typically also returned as return values, so that // the output of one function may be used as a parameter to another. @@ -1426,19 +1426,19 @@ extern "C" { FLOAT* WINAPI D3DXSHEvalDirection ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); - + FLOAT* WINAPI D3DXSHRotate ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); - + FLOAT* WINAPI D3DXSHRotateZ ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); - + FLOAT* WINAPI D3DXSHAdd ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); FLOAT* WINAPI D3DXSHScale ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); - + FLOAT WINAPI D3DXSHDot ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); @@ -1456,7 +1456,7 @@ FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); //============================================================================ HRESULT WINAPI D3DXSHEvalDirectionalLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, + ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); @@ -1469,7 +1469,7 @@ HRESULT WINAPI D3DXSHEvalConeLight ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - + HRESULT WINAPI D3DXSHEvalHemisphereLight ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); @@ -1496,7 +1496,7 @@ HRESULT WINAPI D3DXSHEvalHemisphereLight // pGOut // Output SH vector for Green // pBOut -// Output SH vector for Blue +// Output SH vector for Blue // //============================================================================ diff --git a/gfx/include/d3d9/d3dx9mesh.h b/gfx/include/d3d9/d3dx9mesh.h index 6798c5898f..2418f7acdb 100644 --- a/gfx/include/d3d9/d3dx9mesh.h +++ b/gfx/include/d3d9/d3dx9mesh.h @@ -13,27 +13,27 @@ #define __D3DX9MESH_H__ // {7ED943DD-52E8-40b5-A8D8-76685C406330} -DEFINE_GUID(IID_ID3DXBaseMesh, +DEFINE_GUID(IID_ID3DXBaseMesh, 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); // {4020E5C2-1403-4929-883F-E2E849FAC195} -DEFINE_GUID(IID_ID3DXMesh, +DEFINE_GUID(IID_ID3DXMesh, 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); // {8875769A-D579-4088-AAEB-534D1AD84E96} -DEFINE_GUID(IID_ID3DXPMesh, +DEFINE_GUID(IID_ID3DXPMesh, 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); // {667EA4C7-F1CD-4386-B523-7C0290B83CC5} -DEFINE_GUID(IID_ID3DXSPMesh, +DEFINE_GUID(IID_ID3DXSPMesh, 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); // {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} -DEFINE_GUID(IID_ID3DXSkinInfo, +DEFINE_GUID(IID_ID3DXSkinInfo, 0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4); // {3CE6CC22-DBF2-44f4-894D-F9C34A337139} -DEFINE_GUID(IID_ID3DXPatchMesh, +DEFINE_GUID(IID_ID3DXPatchMesh, 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); //patch mesh can be quads or tris @@ -49,11 +49,11 @@ typedef enum _D3DXPATCHMESHTYPE { enum _D3DXMESH { D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. @@ -91,11 +91,11 @@ enum _D3DXMESHSIMP typedef enum _D3DXCLEANTYPE { D3DXCLEAN_BACKFACING = 0x00000001, D3DXCLEAN_BOWTIES = 0x00000002, - + // Helper options D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING, - D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, + D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, } D3DXCLEANTYPE; enum _MAX_FVF_DECL_SIZE @@ -170,7 +170,7 @@ typedef D3DXMATERIAL *LPD3DXMATERIAL; typedef enum _D3DXEFFECTDEFAULTTYPE { - D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string + D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float) D3DXEDT_DWORD = 0x3, // pValue points to a DWORD @@ -208,7 +208,7 @@ enum _D3DXWELDEPSILONSFLAGS { D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched // vertices so that both components identical AND if all components "equal" // remove one of the vertices D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal @@ -258,9 +258,9 @@ DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -298,9 +298,9 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -320,10 +320,10 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) // ID3DXMesh STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE; }; @@ -348,9 +348,9 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -368,9 +368,9 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; @@ -380,8 +380,8 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; STDMETHOD(Save)(THIS_ IStream *pStream, CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, LPD3DXMESH* ppOptMesh) PURE; STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; @@ -413,13 +413,13 @@ DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsByFace, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsbyFace, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; @@ -441,7 +441,7 @@ enum _D3DXMESHOPT { D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards - + // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead }; @@ -494,7 +494,7 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE; - // Control mesh access + // Control mesh access STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; @@ -507,18 +507,18 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) // This function returns the size of the tessellated mesh given a tessellation level. // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must // be set to TRUE and TessellationLevel should be the max tessellation. - // This will result in the max mesh size necessary for adaptive tessellation. + // This will result in the max mesh size necessary for adaptive tessellation. STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE; - + //GenerateAdjacency determines which patches are adjacent with provided tolerance //this information is used internally to optimize tessellation STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE; - + //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh //has adjacency, the new mesh will also have adjacency STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE; - + // Optimizes the patchmesh for efficient tessellation. This function is designed // to perform one time optimization for patch meshes that need to be tessellated // repeatedly by calling the Tessellate() method. The optimization performed is @@ -542,8 +542,8 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) D3DTEXTUREFILTERTYPE *MipFilter, D3DTEXTUREADDRESS *Wrap, DWORD *dwLODBias) PURE; - - // Performs the uniform tessellation based on the tessellation level. + + // Performs the uniform tessellation based on the tessellation level. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE; @@ -553,9 +553,9 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) // at the 2 vertices it connects. // MaxTessLevel specifies the upper limit for adaptive tesselation. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. - STDMETHOD(TessellateAdaptive)(THIS_ + STDMETHOD(TessellateAdaptive)(THIS_ CONST D3DXVECTOR4 *pTrans, - DWORD dwMaxTessLevel, + DWORD dwMaxTessLevel, DWORD dwMinTessLevel, LPD3DXMESH pMesh) PURE; @@ -583,24 +583,24 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) // This gets the max face influences based on a triangle mesh with the specified index buffer STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE; - + // Set min bone influence. Bone influences that are smaller than this are ignored STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE; - // Get min bone influence. + // Get min bone influence. STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE; - + // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this. - + // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this. - + // Clone a skin info object STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE; - - // Update bone influence information to match vertices after they are reordered. This should be called + + // Update bone influence information to match vertices after they are reordered. This should be called // if the target vertex buffer has been reordered externally. STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE; @@ -611,39 +611,39 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; // Apply SW skinning based on current pose matrices to the target vertices. - STDMETHOD(UpdateSkinnedMesh)(THIS_ - CONST D3DXMATRIX* pBoneTransforms, - CONST D3DXMATRIX* pBoneInvTransposeTransforms, - LPCVOID pVerticesSrc, + STDMETHOD(UpdateSkinnedMesh)(THIS_ + CONST D3DXMATRIX* pBoneTransforms, + CONST D3DXMATRIX* pBoneInvTransposeTransforms, + LPCVOID pVerticesSrc, PVOID pVerticesDst) PURE; // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination // table that describes which bones affect which subsets of the mesh - STDMETHOD(ConvertToBlendedMesh)(THIS_ + STDMETHOD(ConvertToBlendedMesh)(THIS_ LPD3DXMESH pMesh, - DWORD Options, - CONST DWORD *pAdjacencyIn, + DWORD Options, + CONST DWORD *pAdjacencyIn, LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, DWORD* pMaxFaceInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, LPD3DXMESH* ppMesh) PURE; - // Takes a mesh and returns a new mesh with per vertex blend weights and indices + // Takes a mesh and returns a new mesh with per vertex blend weights and indices // and a bone combination table that describes which bones palettes affect which subsets of the mesh - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ LPD3DXMESH pMesh, - DWORD Options, - DWORD paletteSize, - CONST DWORD *pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, + DWORD Options, + DWORD paletteSize, + CONST DWORD *pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, DWORD* pMaxVertexInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, LPD3DXMESH* ppMesh) PURE; }; @@ -652,28 +652,28 @@ extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, LPD3DXSPMESH* ppSMesh); @@ -694,72 +694,72 @@ HRESULT WINAPI CONST DWORD* pAdjacency, LPD3DXBUFFER* ppErrorsAndWarnings); -HRESULT WINAPI +HRESULT WINAPI D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, + DWORD MinValue, + DWORD Options, LPD3DXPMESH* ppPMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, + DWORD MinValue, + DWORD Options, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeBoundingSphere( CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, + DWORD NumVertices, DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pCenter, + D3DXVECTOR3 *pCenter, FLOAT *pRadius); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeBoundingBox( CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, + DWORD NumVertices, DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMin, D3DXVECTOR3 *pMax); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeNormals( LPD3DXBASEMESH pMesh, CONST DWORD *pAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateBuffer( - DWORD NumBytes, + DWORD NumBytes, LPD3DXBUFFER *ppBuffer); HRESULT WINAPI D3DXLoadMeshFromXA( - LPCSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPCSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); HRESULT WINAPI D3DXLoadMeshFromXW( - LPCWSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPCWSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); @@ -769,67 +769,67 @@ HRESULT WINAPI #define D3DXLoadMeshFromX D3DXLoadMeshFromXA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXInMemory( LPCVOID Memory, DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXResource( HMODULE Module, LPCSTR Name, LPCSTR Type, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshToXA( LPCSTR pFilename, LPD3DXMESH pMesh, CONST DWORD* pAdjacency, CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, + CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials, DWORD Format ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshToXW( LPCWSTR pFilename, LPD3DXMESH pMesh, CONST DWORD* pAdjacency, CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, + CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials, DWORD Format ); - + #ifdef UNICODE #define D3DXSaveMeshToX D3DXSaveMeshToXW #else #define D3DXSaveMeshToX D3DXSaveMeshToXA #endif - -HRESULT WINAPI + +HRESULT WINAPI D3DXCreatePMeshFromStream( - IStream *pStream, + IStream *pStream, DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, DWORD* pNumMaterials, LPD3DXPMESH *ppPMesh); @@ -838,10 +838,10 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreateSkinInfo( DWORD NumVertices, - CONST D3DVERTEXELEMENT9 *pDeclaration, + CONST D3DVERTEXELEMENT9 *pDeclaration, DWORD NumBones, LPD3DXSKININFO* ppSkinInfo); - + // Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices // The bone names and initial bone transforms are not filled in the skin info object by this method. HRESULT WINAPI @@ -850,34 +850,34 @@ HRESULT WINAPI DWORD FVF, DWORD NumBones, LPD3DXSKININFO* ppSkinInfo); - + #ifdef __cplusplus } extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXof( - LPD3DXFILEDATA pxofMesh, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXFILEDATA pxofMesh, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); // This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file -// If skinning info is not present, ppSkinInfo will be NULL +// If skinning info is not present, ppSkinInfo will be NULL HRESULT WINAPI D3DXLoadSkinMeshFromXof( - LPD3DXFILEDATA pxofMesh, + LPD3DXFILEDATA pxofMesh, DWORD Options, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER* ppAdjacency, LPD3DXBUFFER* ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, DWORD *pMatOut, LPD3DXSKININFO* ppSkinInfo, LPD3DXMESH* ppMesh); @@ -894,12 +894,12 @@ HRESULT WINAPI DWORD NumBones, CONST D3DXBONECOMBINATION *pBoneCombinationTable, LPD3DXSKININFO* ppSkinInfo); - + HRESULT WINAPI D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic LPD3DXMESH *ppMeshOut, LPD3DXBUFFER *ppAdjacencyOut); @@ -907,7 +907,7 @@ HRESULT WINAPI //generates implied outputdecl from input decl //the decl generated from this should be used to generate the output decl for -//the tessellator subroutines. +//the tessellator subroutines. HRESULT WINAPI D3DXGenerateOutputDecl( @@ -917,14 +917,14 @@ HRESULT WINAPI //loads patches from an XFileData //since an X file can have up to 6 different patch meshes in it, //returns them in an array - pNumPatches will contain the number of -//meshes in the actual file. +//meshes in the actual file. HRESULT WINAPI D3DXLoadPatchMeshFromXof( LPD3DXFILEDATA pXofObjMesh, DWORD Options, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, PDWORD pNumMaterials, LPD3DXPATCHMESH *ppMesh); @@ -935,10 +935,10 @@ HRESULT WINAPI DWORD *pdwTriangles, //output number of triangles DWORD *pdwVertices); //output number of vertices -//computes the size of a single triangle patch +//computes the size of a single triangle patch HRESULT WINAPI D3DXTriPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (3) + CONST FLOAT *pfNumSegs, //segments for each edge (3) DWORD *pdwTriangles, //output number of triangles DWORD *pdwVertices); //output number of vertices @@ -964,25 +964,25 @@ HRESULT WINAPI -//creates an NPatch PatchMesh from a D3DXMESH +//creates an NPatch PatchMesh from a D3DXMESH HRESULT WINAPI D3DXCreateNPatchMesh( LPD3DXMESH pMeshSysMem, LPD3DXPATCHMESH *pPatchMesh); - + //creates a patch mesh HRESULT WINAPI D3DXCreatePatchMesh( CONST D3DXPATCHINFO *pInfo, //patch type DWORD dwNumPatches, //number of patches DWORD dwNumVertices, //number of control vertices - DWORD dwOptions, //options + DWORD dwOptions, //options CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPATCHMESH *pPatchMesh); - + //returns the number of degenerates in a patch mesh - //text output put in string. HRESULT WINAPI @@ -994,10 +994,10 @@ HRESULT WINAPI UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF); -UINT WINAPI +UINT WINAPI D3DXGetDeclVertexSize(CONST D3DVERTEXELEMENT9 *pDecl,DWORD Stream); -UINT WINAPI +UINT WINAPI D3DXGetDeclLength(CONST D3DVERTEXELEMENT9 *pDecl); HRESULT WINAPI @@ -1010,20 +1010,20 @@ HRESULT WINAPI CONST D3DVERTEXELEMENT9 *pDeclarator, DWORD *pFVF); -HRESULT WINAPI +HRESULT WINAPI D3DXWeldVertices( - LPD3DXMESH pMesh, + LPD3DXMESH pMesh, DWORD Flags, - CONST D3DXWELDEPSILONS *pEpsilons, - CONST DWORD *pAdjacencyIn, + CONST D3DXWELDEPSILONS *pEpsilons, + CONST DWORD *pAdjacencyIn, DWORD *pAdjacencyOut, - DWORD *pFaceRemap, + DWORD *pFaceRemap, LPD3DXBUFFER *ppVertexRemap); typedef struct _D3DXINTERSECTINFO { DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates + FLOAT U; // Barycentric Hit Coordinates FLOAT V; // Barycentric Hit Coordinates FLOAT Dist; // Ray-Intersection Parameter Distance } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; @@ -1033,13 +1033,13 @@ HRESULT WINAPI D3DXIntersect( LPD3DXBASEMESH pMesh, CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, + CONST D3DXVECTOR3 *pRayDir, BOOL *pHit, // True if any faces were intersected DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pU, // Barycentric Hit Coordinates FLOAT *pV, // Barycentric Hit Coordinates FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) DWORD *pCountOfHits); // Number of entries in AllHits array HRESULT WINAPI @@ -1047,20 +1047,20 @@ HRESULT WINAPI LPD3DXBASEMESH pMesh, DWORD AttribId, CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, + CONST D3DXVECTOR3 *pRayDir, BOOL *pHit, // True if any faces were intersected DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pU, // Barycentric Hit Coordinates FLOAT *pV, // Barycentric Hit Coordinates FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) DWORD *pCountOfHits); // Number of entries in AllHits array HRESULT WINAPI D3DXSplitMesh ( - LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, + LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, CONST DWORD MaxSize, CONST DWORD Options, DWORD *pMeshesOut, @@ -1070,7 +1070,7 @@ HRESULT WINAPI D3DXSplitMesh LPD3DXBUFFER *ppVertRemapArrayOut ); -BOOL WINAPI D3DXIntersectTri +BOOL WINAPI D3DXIntersectTri ( CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position @@ -1088,9 +1088,9 @@ BOOL WINAPI CONST D3DXVECTOR3 *pRayPosition, CONST D3DXVECTOR3 *pRayDirection); -BOOL WINAPI +BOOL WINAPI D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMin, CONST D3DXVECTOR3 *pMax, CONST D3DXVECTOR3 *pRayPosition, CONST D3DXVECTOR3 *pRayDirection); @@ -1124,11 +1124,11 @@ HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh, //puts the binorm in BINORM[BinormIndex] also specified in the decl. // //If neither the binorm or the tangnet are in the meshes declaration, -//the function will fail. +//the function will fail. // //If a tangent or Binorm field is in the Decl, but the user does not //wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified -//in the TangentIndex or BinormIndex will cause it to ignore the specified +//in the TangentIndex or BinormIndex will cause it to ignore the specified //semantic. // //Wrap should be specified if the texture coordinates wrap. @@ -1186,7 +1186,7 @@ typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserCont // integrated metric tensor for that face. This lets you control // the way this triangle may be stretched in the atlas. The IMT // passed in will be 3 floats (a,b,c) and specify a symmetric -// matrix (a b) that, given a vector (s,t), specifies the +// matrix (a b) that, given a vector (s,t), specifies the // (b c) // distance between a vector v1 and a vector v2 = v1 + (s,t) as // sqrt((s, t) * M * (s, t)^T). @@ -1202,7 +1202,7 @@ typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserCont // in some 2-D space. For D3DXUVAtlas, this space is created by // letting S be the direction from the first to the second // vertex, and T be the cross product between the normal and S. -// +// // pStatusCallback - Since the atlas creation process can be very CPU intensive, // this allows the programmer to specify a function to be called // periodically, similarly to how it is done in the PRT simulation @@ -1459,7 +1459,7 @@ HRESULT WINAPI LPD3DXBUFFER *ppStripLengths, DWORD *pNumStrips); - + //============================================================================ // // D3DXOptimizeFaces: @@ -1485,17 +1485,17 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI D3DXOptimizeFaces( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, DWORD* pFaceRemap); - + //============================================================================ // // D3DXOptimizeVertices: // -------------------- -// Generate a vertex remapping to optimize for in order use of vertices for +// Generate a vertex remapping to optimize for in order use of vertices for // a given set of indices. This is commonly used after applying the face // remap generated by D3DXOptimizeFaces // @@ -1516,10 +1516,10 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI D3DXOptimizeVertices( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, DWORD* pVertexRemap); #ifdef __cplusplus @@ -1546,8 +1546,8 @@ typedef enum _D3DXSHGPUSIMOPT { D3DXSHGPUSIMOPT_SHADOWRES1024 = 2, D3DXSHGPUSIMOPT_SHADOWRES2048 = 3, - D3DXSHGPUSIMOPT_HIGHQUALITY = 4, - + D3DXSHGPUSIMOPT_HIGHQUALITY = 4, + D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff } D3DXSHGPUSIMOPT; @@ -1560,7 +1560,7 @@ typedef struct _D3DXSHMATERIAL { BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror - // subsurface scattering parameters + // subsurface scattering parameters FLOAT RelativeIndexOfRefraction; D3DCOLORVALUE Absorption; D3DCOLORVALUE ReducedScattering; @@ -1583,10 +1583,10 @@ typedef struct _D3DXSHPRTSPLITMESHVERTDATA { typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA { UINT uVertStart; // initial index into remapped vertex array UINT uVertLength; // number of vertices in this super cluster - + UINT uFaceStart; // initial index into face array UINT uFaceLength; // number of faces in this super cluster - + UINT uClusterStart; // initial index into cluster array UINT uClusterLength; // number of clusters in this super cluster } D3DXSHPRTSPLITMESHCLUSTERDATA; @@ -1601,19 +1601,19 @@ typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserCon // GUIDs // {F1827E47-00A8-49cd-908C-9D11955F8728} -DEFINE_GUID(IID_ID3DXPRTBuffer, +DEFINE_GUID(IID_ID3DXPRTBuffer, 0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28); // {A758D465-FE8D-45ad-9CF0-D01E56266A07} -DEFINE_GUID(IID_ID3DXPRTCompBuffer, +DEFINE_GUID(IID_ID3DXPRTCompBuffer, 0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7); // {838F01EC-9729-4527-AADB-DF70ADE7FEA9} -DEFINE_GUID(IID_ID3DXTextureGutterHelper, +DEFINE_GUID(IID_ID3DXTextureGutterHelper, 0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9); // {683A4278-CD5F-4d24-90AD-C4E1B6855D53} -DEFINE_GUID(IID_ID3DXPRTEngine, +DEFINE_GUID(IID_ID3DXPRTEngine, 0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53); // interface defenitions @@ -1654,26 +1654,26 @@ DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) // every scalar in buffer is multiplied by Scale STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE; - + // every scalar contains the sum of this and pBuffers values - // pBuffer must have the same storage class/dimensions + // pBuffer must have the same storage class/dimensions STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE; // GutterHelper (described below) will fill in the gutter // regions of a texture by interpolating "internal" values STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE; STDMETHOD(ReleaseGH)(THIS) PURE; - + // Evaluates attached gutter helper on the contents of this buffer STDMETHOD(EvalGH)(THIS) PURE; // extracts a given channel into texture pTexture // NumCoefficients starting from StartCoefficient are copied - STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, + STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE; // extracts NumCoefficients coefficients into mesh - only applicable on single channel - // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients + // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients // should be Order^2 STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart, LPD3DXMESH pScene) PURE; @@ -1717,19 +1717,19 @@ DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) // copies basis vectors for cluster "Cluster" into pClusterBasis // (NumPCA+1)*NumCoeffs*NumChannels floats STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE; - + // UINT per sample - which cluster it belongs to STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE; - + // copies NumExtract PCA projection coefficients starting at StartPCA // into pPCACoefficients - NumSamples*NumExtract floats copied STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE; // copies NumPCA projection coefficients starting at StartPCA // into pTexture - should be able to cope with signed formats - STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, + STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, LPDIRECT3DTEXTURE9 pTexture) PURE; - + // copies NumPCA projection coefficients into mesh pScene // Usage is D3DDECLUSAGE where coefficients are to be stored // UsageIndexStart is starting index @@ -1767,7 +1767,7 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXTextureGutterHelper - + // dimensions of texture this is bound too STDMETHOD_(UINT, GetWidth)(THIS) PURE; STDMETHOD_(UINT, GetHeight)(THIS) PURE; @@ -1775,19 +1775,19 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) // Applying gutters recomputes all of the gutter texels of class "2" // based on texels of class "1" or "4" - + // Applies gutters to a raw float buffer - each texel is NumCoeffs floats // Width and Height must match GutterHelper STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height); - + // Applies gutters to pTexture // Dimensions must match GutterHelper STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture); - + // Applies gutters to a D3DXPRTBuffer // Dimensions must match GutterHelper STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer); - + // Resamples a texture from a mesh onto this gutterhelpers // parameterization. It is assumed that the UV coordinates // for this gutter helper are in TEXTURE 0 (usage/usage index) @@ -1802,63 +1802,63 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) // for pTextureIn // UsageIndex - which index for Usage above for pTextureIn // pTextureOut- Resampled texture - // + // // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn, LPD3DXMESH pMeshIn, D3DDECLUSAGE Usage, UINT UsageIndex, - LPDIRECT3DTEXTURE9 pTextureOut); - + LPDIRECT3DTEXTURE9 pTextureOut); + // the routines below provide access to the data structures // used by the Apply functions // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - + // face of the mesh that texel belongs too - // only valid if same texel is valid in pGutterData // pFaceData must be allocated by the user STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE; - + // BaryMap is a D3DXVECTOR2 per texel // the 1st two barycentric coordinates for the corresponding // face (3rd weight is always 1-sum of first two) // only valid if same texel is valid in pGutterData // pBaryData must be allocated by the user STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - + // TexelMap is a D3DXVECTOR2 per texel that // stores the location in pixel coordinates where the // corresponding texel is mapped // pTexelData must be allocated by the user STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - + // GutterMap is a BYTE per texel // 0/1/2 for Invalid/Internal/Gutter texels // 4 represents a gutter texel that will be computed // during PRT // pGutterData must be allocated by the user STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE; - + // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - + // face of the mesh that texel belongs too - // only valid if same texel is valid in pGutterData STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE; - + // BaryMap is a D3DXVECTOR2 per texel // the 1st two barycentric coordinates for the corresponding // face (3rd weight is always 1-sum of first two) // only valid if same texel is valid in pGutterData STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - + // TexelMap is a D3DXVECTOR2 per texel that // stores the location in pixel coordinates where the // corresponding texel is mapped STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - + // GutterMap is a BYTE per texel // 0/1/2 for Invalid/Internal/Gutter texels // 4 represents a gutter texel that will be computed // during PRT - STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; + STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; }; @@ -1895,7 +1895,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXPRTEngine - + // This sets a material per attribute in the scene mesh and it is // the only way to specify subsurface scattering parameters. if // bSetAlbedo is FALSE, NumChannels must match the current @@ -1909,53 +1909,53 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // albedo that might have been set before. FALSE won't clobber. // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube // and scaled by this amount - STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, + STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE; - + // setting albedo per-vertex or per-texel over rides the albedos stored per mesh // but it does not over ride any other settings - + // sets an albedo to be used per vertex - the albedo is represented as a float // pDataIn input pointer (pointint to albedo of 1st sample) // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects // Stride - stride in bytes to get to next samples albedo STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE; - + // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) // pAlbedoTexture - texture that stores the albedo (dimension arbitrary) // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects // pGH - optional gutter helper, otherwise one is constructed in computation routines and // destroyed (if not attached to buffers) - STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, - UINT NumChannels, + STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, + UINT NumChannels, LPD3DXTEXTUREGUTTERHELPER pGH) PURE; - + // gets the per-vertex albedo - STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; - + STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; + // If pixel PRT is being computed normals default to ones that are interpolated // from the vertex normals. This specifies a texture that stores an object // space normal map instead (must use a texture format that can represent signed values) - // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed + // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE; - + // Copies per-vertex albedo from mesh // pMesh - mesh that represents the scene. It must have the same // properties as the mesh used to create the PRTEngine // Usage - D3DDECLUSAGE to extract albedos from // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects - STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, - D3DDECLUSAGE Usage, + STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, + D3DDECLUSAGE Usage, UINT NumChannels) PURE; // Resamples the input buffer into the output buffer // can be used to move between per-vertex and per-texel buffers. This can also be used // to convert single channel buffers to 3-channel buffers and vice-versa. STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE; - + // Returns the scene mesh - including modifications from adaptive spatial sampling // The returned mesh only has positions, normals and texture coordinates (if defined) // pD3DDevice - d3d device that will be used to allocate the mesh @@ -1998,10 +1998,10 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Adaptive - if TRUE adaptive sampling (angular) is used // AdaptiveThresh - threshold used to terminate adaptive angular sampling // ignored if adaptive sampling is not set - STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, - BOOL UseSphere, - BOOL UseCosine, - BOOL Adaptive, + STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, + BOOL UseSphere, + BOOL UseCosine, + BOOL Adaptive, FLOAT AdaptiveThresh) PURE; // Methods that compute the direct lighting contribution for objects @@ -2011,9 +2011,9 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // // SHOrder - order of SH to use // pDataOut - PRT buffer that is generated. Can be single channel - STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, + STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, LPD3DXPRTBUFFER pDataOut) PURE; - + // Adaptive variant of above function. This will refine the mesh // generating new vertices/faces to approximate the PRT signal // more faithfully. @@ -2023,15 +2023,15 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it + // MaxSubdiv - maximum subdivision level, if 0 is specified it // will default to 4 // pDataOut - PRT buffer that is generated. Can be single channel. - STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, + STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, LPD3DXPRTBUFFER pDataOut) PURE; - + // Function that computes the direct lighting contribution for objects // light is always represented using spherical harmonics (SH) // This is done on the GPU and is much faster then using the CPU. @@ -2068,7 +2068,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // pDataIn - input data (previous bounce) // pDataOut - result of subsurface scattering simulation // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, + STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; // Adaptive version of ComputeSS. @@ -2079,11 +2079,11 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 + // MaxSubdiv - maximum subdivision level, if 0 is specified it + // will default to 4 // pDataOut - result of subsurface scattering simulation // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, + STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, @@ -2093,7 +2093,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // works for SH based PRT or generic lighting // Albedo is not multiplied by result // - // pDataIn - previous bounces data + // pDataIn - previous bounces data // pDataOut - PRT buffer that is generated // pDataTotal - [optional] can be used to keep a running sum STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn, @@ -2102,16 +2102,16 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Adaptive version of above function. // - // pDataIn - previous bounces data, can be single channel + // pDataIn - previous bounces data, can be single channel // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) // if value is less then 1e-6f, 1e-6f is specified // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it + // MaxSubdiv - maximum subdivision level, if 0 is specified it // will default to 4 // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum + // pDataTotal - [optional] can be used to keep a running sum STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, @@ -2120,7 +2120,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataTotal) PURE; // Computes projection of distant SH radiance into a local SH radiance - // function. This models how direct lighting is attenuated by the + // function. This models how direct lighting is attenuated by the // scene and is a form of "neighborhood transfer." The result is // a linear operator (matrix) at every sample point, if you multiply // this matrix by the distant SH lighting coefficients you get an @@ -2129,24 +2129,24 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // than be projected into another basis or used with any rendering // technique that uses spherical harmonics as input. // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars + // FALSE for UseCosine before this method is called. + // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars // per channel at each sample location. // // SHOrderIn - Order of the SH representation of distant lighting // SHOrderOut - Order of the SH representation of local lighting // NumVolSamples - Number of sample locations // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, - UINT SHOrderOut, + // pDataOut - PRT Buffer that will store output results + STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, + UINT SHOrderOut, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; - + // At each sample location computes a linear operator (matrix) that maps // the representation of source radiance (NumCoeffs in pSurfDataIn) - // into a local incident radiance function approximated with spherical + // into a local incident radiance function approximated with spherical // harmonics. For example if a light map data is specified in pSurfDataIn // the result is an SH representation of the flow of light at each sample // point. If PRT data for an outdoor scene is used, each sample point @@ -2155,7 +2155,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // ComputeVolumeSamplesDirectSH this gives the complete representation for // how light arrives at each sample point parameterized by distant lighting. // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. + // FALSE for UseCosine before this method is called. // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars // per channel at each sample location. // @@ -2164,8 +2164,8 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // NumVolSamples - Number of sample locations // pSampleLocs - position of sample locations // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, - UINT SHOrder, + STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, + UINT SHOrder, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; @@ -2185,7 +2185,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut) PURE; - // given the solution for PRT or light maps, computes transfer vector at arbitrary + // given the solution for PRT or light maps, computes transfer vector at arbitrary // position/normal pairs in space // // pSurfDataIn - input data @@ -2204,21 +2204,21 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Frees temporary data structures that can be created for subsurface scattering // this data is freed when the PRTComputeEngine is freed and is lazily created STDMETHOD(FreeSSData)(THIS) PURE; - + // Frees temporary data structures that can be created for bounce simulations // this data is freed when the PRTComputeEngine is freed and is lazily created STDMETHOD(FreeBounceData)(THIS) PURE; - // This computes the Local Deformable PRT (LDPRT) coefficients relative to the - // per sample normals that minimize error in a least squares sense with respect - // to the input PRT data set. These coefficients can be used with skinned/transformed - // normals to model global effects with dynamic objects. Shading normals can + // This computes the Local Deformable PRT (LDPRT) coefficients relative to the + // per sample normals that minimize error in a least squares sense with respect + // to the input PRT data set. These coefficients can be used with skinned/transformed + // normals to model global effects with dynamic objects. Shading normals can // optionally be solved for - these normals (along with the LDPRT coefficients) can // more accurately represent the PRT signal. The coefficients are for zonal // harmonics oriented in the normal/shading normal direction. // // pDataIn - SH PRT dataset that is input - // SHOrder - Order of SH to compute conv coefficients for + // SHOrder - Order of SH to compute conv coefficients for // pNormOut - Optional array of vectors (passed in) that will be filled with // "shading normals", LDPRT coefficients are optimized for // these normals. This array must be the same size as the number of @@ -2233,7 +2233,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // can be useful when using subsurface scattering // fScale - value to scale each vector in submesh by STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE; - + // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo // burned into the dataset, often better not to do this. If this is not done the user // must mutliply the albedo themselves when rendering - just multiply the albedo times @@ -2245,7 +2245,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // // pDataOut - dataset that will get albedo pushed into it STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE; - + // Sets a pointer to an optional call back function that reports back to the // user percentage done and gives them the option of quitting // pCB - pointer to call back function, return S_OK for the simulation @@ -2254,16 +2254,16 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // will be invoked // lpUserContext - will be passed back to the users call back STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE; - + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function // takes into account settings from SetMinMaxIntersection. If the closest intersection // is not needed this function is more efficient compared to the ClosestRayIntersection // method. // pRayPos - origin of ray // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) - + STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE; - + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an // intersection the closest face that was intersected and its first two barycentric coordinates // are returned. This function takes into account settings from SetMinMaxIntersection. @@ -2276,7 +2276,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // pU - Barycentric coordinate for vertex 0 // pV - Barycentric coordinate for vertex 1 // pDist - Distance along ray where the intersection occured - + STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE; }; @@ -2308,8 +2308,8 @@ extern "C" { // //============================================================================ -HRESULT WINAPI - D3DXCreatePRTBuffer( +HRESULT WINAPI + D3DXCreatePRTBuffer( UINT NumSamples, UINT NumCoeffs, UINT NumChannels, @@ -2338,7 +2338,7 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI - D3DXCreatePRTBufferTex( + D3DXCreatePRTBufferTex( UINT Width, UINT Height, UINT NumCoeffs, @@ -2361,12 +2361,12 @@ HRESULT WINAPI HRESULT WINAPI D3DXLoadPRTBufferFromFileA( - LPCSTR pFilename, + LPCSTR pFilename, LPD3DXPRTBUFFER* ppBuffer); - + HRESULT WINAPI D3DXLoadPRTBufferFromFileW( - LPCWSTR pFilename, + LPCWSTR pFilename, LPD3DXPRTBUFFER* ppBuffer); #ifdef UNICODE @@ -2394,7 +2394,7 @@ HRESULT WINAPI D3DXSavePRTBufferToFileA( LPCSTR pFileName, LPD3DXPRTBUFFER pBuffer); - + HRESULT WINAPI D3DXSavePRTBufferToFileW( LPCWSTR pFileName, @@ -2404,7 +2404,7 @@ HRESULT WINAPI #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW #else #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileA -#endif +#endif //============================================================================ @@ -2423,12 +2423,12 @@ HRESULT WINAPI HRESULT WINAPI D3DXLoadPRTCompBufferFromFileA( - LPCSTR pFilename, + LPCSTR pFilename, LPD3DXPRTCOMPBUFFER* ppBuffer); - + HRESULT WINAPI D3DXLoadPRTCompBufferFromFileW( - LPCWSTR pFilename, + LPCWSTR pFilename, LPD3DXPRTCOMPBUFFER* ppBuffer); #ifdef UNICODE @@ -2455,7 +2455,7 @@ HRESULT WINAPI D3DXSavePRTCompBufferToFileA( LPCSTR pFileName, LPD3DXPRTCOMPBUFFER pBuffer); - + HRESULT WINAPI D3DXSavePRTCompBufferToFileW( LPCWSTR pFileName, @@ -2465,7 +2465,7 @@ HRESULT WINAPI #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW #else #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA -#endif +#endif //============================================================================ // @@ -2496,10 +2496,10 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreatePRTCompBuffer( D3DXSHCOMPRESSQUALITYTYPE Quality, - UINT NumClusters, + UINT NumClusters, UINT NumPCA, LPD3DXSHPRTSIMCB pCB, - LPVOID lpUserContext, + LPVOID lpUserContext, LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTCOMPBUFFER *ppBufferOut ); @@ -2527,11 +2527,11 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI - D3DXCreateTextureGutterHelper( +HRESULT WINAPI + D3DXCreateTextureGutterHelper( UINT Width, UINT Height, - LPD3DXMESH pMesh, + LPD3DXMESH pMesh, FLOAT GutterSize, LPD3DXTEXTUREGUTTERHELPER* ppBuffer); @@ -2560,12 +2560,12 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI - D3DXCreatePRTEngine( +HRESULT WINAPI + D3DXCreatePRTEngine( LPD3DXMESH pMesh, DWORD *pAdjacency, BOOL ExtractUVs, - LPD3DXMESH pBlockerMesh, + LPD3DXMESH pBlockerMesh, LPD3DXPRTENGINE* ppEngine); //============================================================================ @@ -2602,15 +2602,15 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXConcatenateMeshes( - LPD3DXMESH *ppMeshes, - UINT NumMeshes, - DWORD Options, - CONST D3DXMATRIX *pGeomXForms, - CONST D3DXMATRIX *pTextureXForms, + LPD3DXMESH *ppMeshes, + UINT NumMeshes, + DWORD Options, + CONST D3DXMATRIX *pGeomXForms, + CONST D3DXMATRIX *pTextureXForms, CONST D3DVERTEXELEMENT9 *pDecl, - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH *ppMeshOut); //============================================================================ @@ -2636,16 +2636,16 @@ HRESULT WINAPI // that corresponding cluster was assigned to // pNumSuperClusters // Returns the number of super clusters allocated -// +// //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXSHPRTCompSuperCluster( - UINT *pClusterIDs, - LPD3DXMESH pScene, - UINT MaxNumClusters, + UINT *pClusterIDs, + LPD3DXMESH pScene, + UINT MaxNumClusters, UINT NumClusters, - UINT *pSuperClusterIDs, + UINT *pSuperClusterIDs, UINT *pNumSuperClusters); //============================================================================ @@ -2657,7 +2657,7 @@ HRESULT WINAPI // to split the mesh into a group of faces/vertices per super cluster. // Each super cluster contains all of the faces that contain any vertex // classified in one of its clusters. All of the vertices connected to this -// set of faces are also included with the returned array ppVertStatus +// set of faces are also included with the returned array ppVertStatus // indicating whether or not the vertex belongs to the supercluster. // // Parameters: @@ -2680,12 +2680,12 @@ HRESULT WINAPI // NumFaces // Number of faces in the original mesh (pInputIB is 3 times this length) // ppIBData -// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. +// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. // Format determined by bIBIs32Bit. Allocated by function // pIBDataLength // Length of ppIBData, assigned in function // OutputIBIs32Bit -// Indicates whether the output index buffer is to be 32-bit (otherwise +// Indicates whether the output index buffer is to be 32-bit (otherwise // 16-bit is assumed) // ppFaceRemap // LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is @@ -2703,33 +2703,33 @@ HRESULT WINAPI // //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXSHPRTCompSplitMeshSC( - UINT *pClusterIDs, - UINT NumVertices, - UINT NumClusters, - UINT *pSuperClusterIDs, + UINT *pClusterIDs, + UINT NumVertices, + UINT NumClusters, + UINT *pSuperClusterIDs, UINT NumSuperClusters, - LPVOID pInputIB, - BOOL InputIBIs32Bit, + LPVOID pInputIB, + BOOL InputIBIs32Bit, UINT NumFaces, - LPD3DXBUFFER *ppIBData, - UINT *pIBDataLength, - BOOL OutputIBIs32Bit, - LPD3DXBUFFER *ppFaceRemap, - LPD3DXBUFFER *ppVertData, - UINT *pVertDataLength, + LPD3DXBUFFER *ppIBData, + UINT *pIBDataLength, + BOOL OutputIBIs32Bit, + LPD3DXBUFFER *ppFaceRemap, + LPD3DXBUFFER *ppVertData, + UINT *pVertDataLength, UINT *pSCClusterList, D3DXSHPRTSPLITMESHCLUSTERDATA *pSCData); - - + + #ifdef __cplusplus } #endif //__cplusplus ////////////////////////////////////////////////////////////////////////////// // -// Definitions of .X file templates used by mesh load/save functions +// Definitions of .X file templates used by mesh load/save functions // that are not RM standard // ////////////////////////////////////////////////////////////////////////////// @@ -2739,35 +2739,35 @@ DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, 0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2); // {B8D65549-D7C9-4995-89CF-53A9A8B031E3} -DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, +DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, 0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); // {A64C844A-E282-4756-8B80-250CDE04398C} -DEFINE_GUID(DXFILEOBJ_FaceAdjacency, +DEFINE_GUID(DXFILEOBJ_FaceAdjacency, 0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c); // {6F0D123B-BAD2-4167-A0D0-80224F25FABB} -DEFINE_GUID(DXFILEOBJ_SkinWeights, +DEFINE_GUID(DXFILEOBJ_SkinWeights, 0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb); // {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} -DEFINE_GUID(DXFILEOBJ_Patch, +DEFINE_GUID(DXFILEOBJ_Patch, 0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6); // {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} -DEFINE_GUID(DXFILEOBJ_PatchMesh, +DEFINE_GUID(DXFILEOBJ_PatchMesh, 0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf); // {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} -DEFINE_GUID(DXFILEOBJ_PatchMesh9, +DEFINE_GUID(DXFILEOBJ_PatchMesh9, 0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea); // {B6C3E656-EC8B-4b92-9B62-681659522947} -DEFINE_GUID(DXFILEOBJ_PMInfo, +DEFINE_GUID(DXFILEOBJ_PMInfo, 0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47); // {917E0427-C61E-4a14-9C64-AFE65F9E9844} -DEFINE_GUID(DXFILEOBJ_PMAttributeRange, +DEFINE_GUID(DXFILEOBJ_PMAttributeRange, 0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44); // {574CCC14-F0B3-4333-822D-93E8A8A08E4C} @@ -2775,35 +2775,35 @@ DEFINE_GUID(DXFILEOBJ_PMVSplitRecord, 0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c); // {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} -DEFINE_GUID(DXFILEOBJ_FVFData, +DEFINE_GUID(DXFILEOBJ_FVFData, 0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97); // {F752461C-1E23-48f6-B9F8-8350850F336F} -DEFINE_GUID(DXFILEOBJ_VertexElement, +DEFINE_GUID(DXFILEOBJ_VertexElement, 0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f); // {BF22E553-292C-4781-9FEA-62BD554BDD93} -DEFINE_GUID(DXFILEOBJ_DeclData, +DEFINE_GUID(DXFILEOBJ_DeclData, 0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93); // {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} -DEFINE_GUID(DXFILEOBJ_EffectFloats, +DEFINE_GUID(DXFILEOBJ_EffectFloats, 0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d); // {D55B097E-BDB6-4c52-B03D-6051C89D0E42} -DEFINE_GUID(DXFILEOBJ_EffectString, +DEFINE_GUID(DXFILEOBJ_EffectString, 0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42); // {622C0ED0-956E-4da9-908A-2AF94F3CE716} -DEFINE_GUID(DXFILEOBJ_EffectDWord, +DEFINE_GUID(DXFILEOBJ_EffectDWord, 0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16); // {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} -DEFINE_GUID(DXFILEOBJ_EffectParamFloats, +DEFINE_GUID(DXFILEOBJ_EffectParamFloats, 0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); // {1DBC4C88-94C1-46ee-9076-2C28818C9481} -DEFINE_GUID(DXFILEOBJ_EffectParamString, +DEFINE_GUID(DXFILEOBJ_EffectParamString, 0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81); // {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} @@ -2811,15 +2811,15 @@ DEFINE_GUID(DXFILEOBJ_EffectParamDWord, 0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5); // {E331F7E4-0559-4cc2-8E99-1CEC1657928F} -DEFINE_GUID(DXFILEOBJ_EffectInstance, +DEFINE_GUID(DXFILEOBJ_EffectInstance, 0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f); // {9E415A43-7BA6-4a73-8743-B73D47E88476} -DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, +DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, 0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76); // {7F9B00B3-F125-4890-876E-1CFFBF697C4D} -DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, +DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, 0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d); #pragma pack(push, 1) @@ -3001,5 +3001,5 @@ typedef struct _XFILECOMPRESSEDANIMATIONSET DWORD nAttributeMispredicts; \ array DWORD attributeMispredicts[nAttributeMispredicts]; \ } " - + #endif //__D3DX9MESH_H__ diff --git a/gfx/include/d3d9/d3dx9shader.h b/gfx/include/d3d9/d3dx9shader.h index 46ddf4c85a..174ec6667b 100644 --- a/gfx/include/d3d9/d3dx9shader.h +++ b/gfx/include/d3d9/d3dx9shader.h @@ -187,7 +187,7 @@ typedef interface ID3DXConstantTable ID3DXConstantTable; typedef interface ID3DXConstantTable *LPD3DXCONSTANTTABLE; // {AB3C758F-093E-4356-B762-4DB18F1B3A01} -DEFINE_GUID(IID_ID3DXConstantTable, +DEFINE_GUID(IID_ID3DXConstantTable, 0xab3c758f, 0x93e, 0x4356, 0xb7, 0x62, 0x4d, 0xb1, 0x8f, 0x1b, 0x3a, 0x1); @@ -243,7 +243,7 @@ typedef interface ID3DXTextureShader ID3DXTextureShader; typedef interface ID3DXTextureShader *LPD3DXTEXTURESHADER; // {3E3D67F8-AA7A-405d-A857-BA01D4758426} -DEFINE_GUID(IID_ID3DXTextureShader, +DEFINE_GUID(IID_ID3DXTextureShader, 0x3e3d67f8, 0xaa7a, 0x405d, 0xa8, 0x57, 0xba, 0x1, 0xd4, 0x75, 0x84, 0x26); #undef INTERFACE @@ -460,9 +460,9 @@ HRESULT WINAPI HRESULT WINAPI D3DXDisassembleShader( - CONST DWORD* pShader, - BOOL EnableColorCode, - LPCSTR pComments, + CONST DWORD* pShader, + BOOL EnableColorCode, + LPCSTR pComments, LPD3DXBUFFER* ppDisassembly); LPCSTR WINAPI @@ -519,18 +519,18 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreateTextureShader( - CONST DWORD* pFunction, + CONST DWORD* pFunction, LPD3DXTEXTURESHADER* ppTextureShader); -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShaderFromFileA( LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPD3DXBUFFER* ppShaderText, LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI + +HRESULT WINAPI D3DXPreprocessShaderFromFileW( LPCWSTR pSrcFile, CONST D3DXMACRO* pDefines, @@ -543,8 +543,8 @@ HRESULT WINAPI #else #define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileA #endif - -HRESULT WINAPI + +HRESULT WINAPI D3DXPreprocessShaderFromResourceA( HMODULE hSrcModule, LPCSTR pSrcResource, @@ -553,7 +553,7 @@ HRESULT WINAPI LPD3DXBUFFER* ppShaderText, LPD3DXBUFFER* ppErrorMsgs); -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShaderFromResourceW( HMODULE hSrcModule, LPCWSTR pSrcResource, @@ -568,7 +568,7 @@ HRESULT WINAPI #define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShader( LPCSTR pSrcData, UINT SrcDataSize, @@ -603,7 +603,7 @@ typedef struct _D3DXSHADER_CONSTANTTABLE DWORD Constants; // number of constants DWORD ConstantInfo; // D3DXSHADER_CONSTANTINFO[Constants] offset DWORD Flags; // flags shader was compiled with - DWORD Target; // LPCSTR offset + DWORD Target; // LPCSTR offset } D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE; @@ -643,4 +643,4 @@ typedef struct _D3DXSHADER_STRUCTMEMBERINFO -#endif //__D3DX9SHADER_H__ +#endif /* __D3DX9SHADER_H__ */ diff --git a/gfx/include/d3d9/d3dx9shape.h b/gfx/include/d3d9/d3dx9shape.h index 9d1ff52e7f..cc0c618c5a 100644 --- a/gfx/include/d3d9/d3dx9shape.h +++ b/gfx/include/d3d9/d3dx9shape.h @@ -16,39 +16,39 @@ extern "C" { #endif -HRESULT WINAPI +HRESULT WINAPI D3DXCreatePolygon( LPDIRECT3DDEVICE9 pDevice, - FLOAT Length, - UINT Sides, + FLOAT Length, + UINT Sides, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateBox( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, FLOAT Width, FLOAT Height, FLOAT Depth, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateCylinder( LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); HRESULT WINAPI D3DXCreateSphere( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius, - UINT Slices, + LPDIRECT3DDEVICE9 pDevice, + FLOAT Radius, + UINT Slices, UINT Stacks, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); @@ -57,9 +57,9 @@ HRESULT WINAPI D3DXCreateTorus( LPDIRECT3DDEVICE9 pDevice, FLOAT InnerRadius, - FLOAT OuterRadius, + FLOAT OuterRadius, UINT Sides, - UINT Rings, + UINT Rings, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); diff --git a/gfx/include/d3d9/d3dx9tex.h b/gfx/include/d3d9/d3dx9tex.h index ec29c0187a..4de1ead96c 100644 --- a/gfx/include/d3d9/d3dx9tex.h +++ b/gfx/include/d3d9/d3dx9tex.h @@ -61,12 +61,12 @@ typedef enum _D3DXIMAGE_FILEFORMAT } D3DXIMAGE_FILEFORMAT; -typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, +typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData); -typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, +typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pTexCoord, CONST D3DXVECTOR3 *pTexelSize, LPVOID pData); - + typedef struct _D3DXIMAGE_INFO { UINT Width; @@ -974,7 +974,7 @@ HRESULT WINAPI LPD3DXFILL3D pFunction, LPVOID pData); -HRESULT WINAPI +HRESULT WINAPI D3DXFillTextureTX( LPDIRECT3DTEXTURE9 pTexture, LPD3DXTEXTURESHADER pTextureShader); @@ -984,9 +984,9 @@ HRESULT WINAPI D3DXFillCubeTextureTX( LPDIRECT3DCUBETEXTURE9 pCubeTexture, LPD3DXTEXTURESHADER pTextureShader); - - -HRESULT WINAPI + + +HRESULT WINAPI D3DXFillVolumeTextureTX( LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, LPD3DXTEXTURESHADER pTextureShader); diff --git a/gfx/include/d3d9/d3dx9xof.h b/gfx/include/d3d9/d3dx9xof.h index 6b47acd273..0ad3a1250f 100644 --- a/gfx/include/d3d9/d3dx9xof.h +++ b/gfx/include/d3d9/d3dx9xof.h @@ -58,23 +58,23 @@ typedef struct _D3DXF_FILELOADMEMORY #if defined( _WIN32 ) && !defined( _NO_COM ) // {cef08cf9-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFile, +DEFINE_GUID( IID_ID3DXFile, 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfa-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveObject, +DEFINE_GUID( IID_ID3DXFileSaveObject, 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfb-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveData, +DEFINE_GUID( IID_ID3DXFileSaveData, 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfc-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileEnumObject, +DEFINE_GUID( IID_ID3DXFileEnumObject, 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfd-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileData, +DEFINE_GUID( IID_ID3DXFileData, 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); #endif // defined( _WIN32 ) && !defined( _NO_COM ) @@ -131,7 +131,7 @@ DECLARE_INTERFACE_( ID3DXFile, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( CreateEnumObject )( THIS_ LPCVOID, D3DXF_FILELOADOPTIONS, ID3DXFileEnumObject** ) PURE; STDMETHOD( CreateSaveObject )( THIS_ LPCVOID, D3DXF_FILESAVEOPTIONS, @@ -152,7 +152,7 @@ DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; @@ -171,7 +171,7 @@ DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetSave )( THIS_ ID3DXFileSaveObject** ) PURE; STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; STDMETHOD( GetId )( THIS_ LPGUID ) PURE; @@ -193,7 +193,7 @@ DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; @@ -213,7 +213,7 @@ DECLARE_INTERFACE_( ID3DXFileData, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetEnum )( THIS_ ID3DXFileEnumObject** ) PURE; STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; STDMETHOD( GetId )( THIS_ LPGUID ) PURE; diff --git a/gfx/include/d3d9caps.h b/gfx/include/d3d9caps.h index 96a9bef9d4..cd89f29450 100644 --- a/gfx/include/d3d9caps.h +++ b/gfx/include/d3d9caps.h @@ -12,9 +12,9 @@ #ifndef DIRECT3D_VERSION #define DIRECT3D_VERSION 0x0900 -#endif //DIRECT3D_VERSION +#endif /* DIRECT3D_VERSION */ -// include this file content only if compiling for DX9 interfaces +/* include this file content only if compiling for DX9 interfaces */ #if(DIRECT3D_VERSION >= 0x0900) @@ -107,17 +107,17 @@ typedef struct _D3DCONTENTPROTECTIONCAPS #define D3DCPCAPS_SEQUENTIAL_CTR_IV 0x00000100 #define D3DCPCAPS_ENCRYPTSLICEDATAONLY 0x00000200 -DEFINE_GUID(D3DCRYPTOTYPE_AES128_CTR, +DEFINE_GUID(D3DCRYPTOTYPE_AES128_CTR, 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f); -DEFINE_GUID(D3DCRYPTOTYPE_PROPRIETARY, +DEFINE_GUID(D3DCRYPTOTYPE_PROPRIETARY, 0xab4e9afd, 0x1d1c, 0x46e6, 0xa7, 0x2f, 0x8, 0x69, 0x91, 0x7b, 0xd, 0xe8); -DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP, +DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP, 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20); -DEFINE_GUID(D3DKEYEXCHANGE_DXVA, +DEFINE_GUID(D3DKEYEXCHANGE_DXVA, 0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b); -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ typedef struct _D3DCAPS9 @@ -146,13 +146,13 @@ typedef struct _D3DCAPS9 DWORD AlphaCmpCaps; DWORD ShadeCaps; DWORD TextureCaps; - DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's - DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture9's - DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture9's - DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture9's - DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's + DWORD TextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DTexture9's */ + DWORD CubeTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DCubeTexture9's */ + DWORD VolumeTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DVolumeTexture9's */ + DWORD TextureAddressCaps; /* D3DPTADDRESSCAPS for IDirect3DTexture9's */ + DWORD VolumeTextureAddressCaps; /* D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's */ - DWORD LineCaps; // D3DLINECAPS + DWORD LineCaps; /* D3DLINECAPS */ DWORD MaxTextureWidth, MaxTextureHeight; DWORD MaxVolumeExtent; @@ -183,51 +183,49 @@ typedef struct _D3DCAPS9 float MaxPointSize; - DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxPrimitiveCount; /* max number of primitives per DrawPrimitive call */ DWORD MaxVertexIndex; DWORD MaxStreams; - DWORD MaxStreamStride; // max stride for SetStreamSource + DWORD MaxStreamStride; /* max stride for SetStreamSource */ DWORD VertexShaderVersion; - DWORD MaxVertexShaderConst; // number of vertex shader constant registers + DWORD MaxVertexShaderConst; /* number of vertex shader constant registers */ DWORD PixelShaderVersion; - float PixelShader1xMaxValue; // max value storable in registers of ps.1.x shaders + float PixelShader1xMaxValue; /* max value storable in registers of ps.1.x shaders */ - // Here are the DX9 specific ones + /* Here are the DX9 specific ones */ DWORD DevCaps2; float MaxNpatchTessellationLevel; DWORD Reserved5; - UINT MasterAdapterOrdinal; // ordinal of master adaptor for adapter group - UINT AdapterOrdinalInGroup; // ordinal inside the adapter group - UINT NumberOfAdaptersInGroup; // number of adapters in this adapter group (only if master) - DWORD DeclTypes; // Data types, supported in vertex declarations - DWORD NumSimultaneousRTs; // Will be at least 1 - DWORD StretchRectFilterCaps; // Filter caps supported by StretchRect + UINT MasterAdapterOrdinal; /* ordinal of master adaptor for adapter group */ + UINT AdapterOrdinalInGroup; /* ordinal inside the adapter group */ + UINT NumberOfAdaptersInGroup; /* number of adapters in this adapter group (only if master) */ + DWORD DeclTypes; /* Data types, supported in vertex declarations */ + DWORD NumSimultaneousRTs; /* Will be at least 1 */ + DWORD StretchRectFilterCaps; /* Filter caps supported by StretchRect */ D3DVSHADERCAPS2_0 VS20Caps; D3DPSHADERCAPS2_0 PS20Caps; - DWORD VertexTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders - DWORD MaxVShaderInstructionsExecuted; // maximum number of vertex shader instructions that can be executed - DWORD MaxPShaderInstructionsExecuted; // maximum number of pixel shader instructions that can be executed - DWORD MaxVertexShader30InstructionSlots; + DWORD VertexTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders */ + DWORD MaxVShaderInstructionsExecuted; /* maximum number of vertex shader instructions that can be executed */ + DWORD MaxPShaderInstructionsExecuted; /* maximum number of pixel shader instructions that can be executed */ + DWORD MaxVertexShader30InstructionSlots; DWORD MaxPixelShader30InstructionSlots; } D3DCAPS9; -// -// BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS -// +/* + * BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS + */ -// -// Caps -// +/* + * Caps + */ #define D3DCAPS_OVERLAY 0x00000800L #define D3DCAPS_READ_SCANLINE 0x00020000L -// -// Caps2 -// +/* Caps2 */ #define D3DCAPS2_FULLSCREENGAMMA 0x00020000L #define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L #define D3DCAPS2_RESERVED 0x02000000L @@ -240,21 +238,21 @@ typedef struct _D3DCAPS9 #define D3DCAPS2_CANSHARERESOURCE 0x80000000L -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// -// Caps3 -// +/* Caps3 */ #define D3DCAPS3_RESERVED 0x8000001fL -// Indicates that the device can respect the ALPHABLENDENABLE render state -// when fullscreen while using the FLIP or DISCARD swap effect. -// COPY and COPYVSYNC swap effects work whether or not this flag is set. +/* Indicates that the device can respect the ALPHABLENDENABLE render state + * when fullscreen while using the FLIP or DISCARD swap effect. + * COPY and COPYVSYNC swap effects work whether or not this flag is set. + */ #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L -// Indicates that the device can perform a gamma correction from -// a windowed back buffer containing linear content to the sRGB desktop. +/* Indicates that the device can perform a gamma correction from + * a windowed back buffer containing linear content to the sRGB desktop. + */ #define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L #define D3DCAPS3_COPY_TO_VIDMEM 0x00000100L /* Device can acclerate copies from sysmem to local vidmem */ @@ -262,10 +260,7 @@ typedef struct _D3DCAPS9 #define D3DCAPS3_DXVAHD 0x00000400L #define D3DCAPS3_DXVAHD_LIMITED 0x00000800L - -// -// PresentationIntervals -// +/* PresentationIntervals */ #define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L #define D3DPRESENT_INTERVAL_ONE 0x00000001L #define D3DPRESENT_INTERVAL_TWO 0x00000002L @@ -273,17 +268,13 @@ typedef struct _D3DCAPS9 #define D3DPRESENT_INTERVAL_FOUR 0x00000008L #define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L -// -// CursorCaps -// -// Driver supports HW color cursor in at least hi-res modes(height >=400) +/* CursorCaps */ +/* Driver supports HW color cursor in at least hi-res modes(height >=400) */ #define D3DCURSORCAPS_COLOR 0x00000001L -// Driver supports HW cursor also in low-res modes(height < 400) +/* Driver supports HW cursor also in low-res modes(height < 400) */ #define D3DCURSORCAPS_LOWRES 0x00000002L -// -// DevCaps -// +/* DevCaps */ #define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ #define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */ #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */ @@ -305,9 +296,9 @@ typedef struct _D3DCAPS9 #define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */ #define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */ -// -// PrimitiveMiscCaps -// +/* + * PrimitiveMiscCaps + */ #define D3DPMISCCAPS_MASKZ 0x00000002L #define D3DPMISCCAPS_CULLNONE 0x00000010L #define D3DPMISCCAPS_CULLCW 0x00000020L @@ -332,13 +323,13 @@ typedef struct _D3DCAPS9 #define D3DPMISCCAPS_POSTBLENDSRGBCONVERT 0x00200000L /* Indicates device can perform conversion to sRGB after blending. */ -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// -// LineCaps -// +/* + * LineCaps + */ #define D3DLINECAPS_TEXTURE 0x00000001L #define D3DLINECAPS_ZTEST 0x00000002L #define D3DLINECAPS_BLEND 0x00000004L @@ -346,9 +337,9 @@ typedef struct _D3DCAPS9 #define D3DLINECAPS_FOG 0x00000010L #define D3DLINECAPS_ANTIALIAS 0x00000020L -// -// RasterCaps -// +/* + * RasterCaps + */ #define D3DPRASTERCAPS_DITHER 0x00000001L #define D3DPRASTERCAPS_ZTEST 0x00000010L #define D3DPRASTERCAPS_FOGVERTEX 0x00000080L @@ -363,12 +354,12 @@ typedef struct _D3DCAPS9 #define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ #define D3DPRASTERCAPS_SCISSORTEST 0x01000000L #define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L -#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L +#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L #define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L -// -// ZCmpCaps, AlphaCmpCaps -// +/* + * ZCmpCaps, AlphaCmpCaps + */ #define D3DPCMPCAPS_NEVER 0x00000001L #define D3DPCMPCAPS_LESS 0x00000002L #define D3DPCMPCAPS_EQUAL 0x00000004L @@ -378,9 +369,9 @@ typedef struct _D3DCAPS9 #define D3DPCMPCAPS_GREATEREQUAL 0x00000040L #define D3DPCMPCAPS_ALWAYS 0x00000080L -// -// SourceBlendCaps, DestBlendCaps -// +/* + * SourceBlendCaps, DestBlendCaps + */ #define D3DPBLENDCAPS_ZERO 0x00000001L #define D3DPBLENDCAPS_ONE 0x00000002L #define D3DPBLENDCAPS_SRCCOLOR 0x00000004L @@ -402,31 +393,32 @@ typedef struct _D3DCAPS9 #define D3DPBLENDCAPS_SRCCOLOR2 0x00004000L #define D3DPBLENDCAPS_INVSRCCOLOR2 0x00008000L -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ - -// -// ShadeCaps -// +/* + * ShadeCaps + */ #define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L #define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L #define D3DPSHADECAPS_FOGGOURAUD 0x00080000L -// -// TextureCaps -// +/* + * TextureCaps + */ #define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ #define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ #define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ #define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ #define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ #define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ -// Device can use non-POW2 textures if: -// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage -// 2) D3DRS_WRAP(N) is zero for this texture's coordinates -// 3) mip mapping is not enabled (use magnification filter only) + +/* Device can use non-POW2 textures if: + * 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage + * 2) D3DRS_WRAP(N) is zero for this texture's coordinates + * 3) mip mapping is not enabled (use magnification filter only) + */ #define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L #define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ #define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ @@ -436,12 +428,12 @@ typedef struct _D3DCAPS9 #define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ #define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ #define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ -#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation +#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation in programmable and fixed function pixel shaders */ -// -// TextureFilterCaps, StretchRectFilterCaps -// +/* + * TextureFilterCaps, StretchRectFilterCaps + */ #define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ #define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L #define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L @@ -455,7 +447,7 @@ typedef struct _D3DCAPS9 #define D3DPTFILTERCAPS_CONVOLUTIONMONO 0x00040000L /* Min and Mag for the convolution mono filter */ -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ #define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ @@ -464,9 +456,9 @@ typedef struct _D3DCAPS9 #define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000L #define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000L -// -// TextureAddressCaps -// +/* + * TextureAddressCaps + */ #define D3DPTADDRESSCAPS_WRAP 0x00000001L #define D3DPTADDRESSCAPS_MIRROR 0x00000002L #define D3DPTADDRESSCAPS_CLAMP 0x00000004L @@ -474,9 +466,9 @@ typedef struct _D3DCAPS9 #define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L #define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L -// -// StencilCaps -// +/* + * StencilCaps + */ #define D3DSTENCILCAPS_KEEP 0x00000001L #define D3DSTENCILCAPS_ZERO 0x00000002L #define D3DSTENCILCAPS_REPLACE 0x00000004L @@ -487,9 +479,9 @@ typedef struct _D3DCAPS9 #define D3DSTENCILCAPS_DECR 0x00000080L #define D3DSTENCILCAPS_TWOSIDED 0x00000100L -// -// TextureOpCaps -// +/* + * TextureOpCaps + */ #define D3DTEXOPCAPS_DISABLE 0x00000001L #define D3DTEXOPCAPS_SELECTARG1 0x00000002L #define D3DTEXOPCAPS_SELECTARG2 0x00000004L @@ -517,16 +509,16 @@ typedef struct _D3DCAPS9 #define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L #define D3DTEXOPCAPS_LERP 0x02000000L -// -// FVFCaps -// +/* + * FVFCaps + */ #define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ #define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ #define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ -// -// VertexProcessingCaps -// +/* + * VertexProcessingCaps + */ #define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ #define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ #define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ @@ -537,9 +529,9 @@ typedef struct _D3DCAPS9 #define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200L /* device does not support TexGen in non-local viewer mode */ -// -// DevCaps2 -// +/* + * DevCaps2 + */ #define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */ #define D3DDEVCAPS2_DMAPNPATCH 0x00000002L /* Device supports displacement maps for N-Patches*/ #define D3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004L /* Device supports adaptive tesselation of RT-patches*/ @@ -548,9 +540,9 @@ typedef struct _D3DCAPS9 #define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020L /* Device supports presampled displacement maps for N-Patches */ #define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040L /* Vertex elements in a vertex declaration can share the same stream offset */ -// -// DeclTypes -// +/* + * DeclTypes + */ #define D3DDTCAPS_UBYTE4 0x00000001L #define D3DDTCAPS_UBYTE4N 0x00000002L #define D3DDTCAPS_SHORT2N 0x00000004L diff --git a/gfx/include/d3d9types.h b/gfx/include/d3d9types.h index 80fabba9e8..ef96fda496 100644 --- a/gfx/include/d3d9types.h +++ b/gfx/include/d3d9types.h @@ -565,25 +565,25 @@ typedef enum _D3DTEXTUREOP D3DTOP_MODULATE4X = 6, /* multiply and 2 bits */ /* Add */ - D3DTOP_ADD = 7, // add arguments together - D3DTOP_ADDSIGNED = 8, // add with -0.5 bias - D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit - D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation - D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product - // Arg1 + Arg2 - Arg1*Arg2 - // = Arg1 + (1-Arg1)*Arg2 + D3DTOP_ADD = 7, /* add arguments together */ + D3DTOP_ADDSIGNED = 8, /* add with -0.5 bias */ + D3DTOP_ADDSIGNED2X = 9, /* as above but left 1 bit */ + D3DTOP_SUBTRACT = 10, /* Arg1 - Arg2, with no saturation */ + D3DTOP_ADDSMOOTH = 11, /* add 2 args, subtract product */ + /* Arg1 + Arg2 - Arg1*Arg2 */ + /* = Arg1 + (1-Arg1)*Arg2 */ - // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) - D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha - D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha - D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR + /* Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) */ + D3DTOP_BLENDDIFFUSEALPHA = 12, /* iterated alpha */ + D3DTOP_BLENDTEXTUREALPHA = 13, /* texture alpha */ + D3DTOP_BLENDFACTORALPHA = 14, /* alpha from D3DRS_TEXTUREFACTOR */ - // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) - D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha - D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color + /* Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) */ + D3DTOP_BLENDTEXTUREALPHAPM = 15, /* texture alpha */ + D3DTOP_BLENDCURRENTALPHA = 16, /* by alpha of current color */ - // Specular mapping - D3DTOP_PREMODULATE = 17, // modulate with next texture before use + /* Specular mapping */ + D3DTOP_PREMODULATE = 17, /* modulate with next texture before use */ D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB // COLOROP only D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A @@ -1173,7 +1173,7 @@ typedef enum _D3DSHADER_MIN_PRECISION } D3DSHADER_MIN_PRECISION; // If the older D3DSPDM_PARTIALPRECISION is set, // that is equivalent to the whole operation specifying -// D3DMP_16 (on all operands). The two encodings are not +// D3DMP_16 (on all operands). The two encodings are not // used together however. @@ -1451,7 +1451,7 @@ typedef enum _D3DFORMAT /* Binary format indicating that the data has no inherent type */ D3DFMT_BINARYBUFFER = 199, - + #endif // !D3D_DISABLE_9EX /* -- D3D9Ex only */ @@ -1601,10 +1601,11 @@ typedef enum _D3DRESOURCETYPE { #endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// When passed to CheckDeviceFormat, D3DUSAGE_AUTOGENMIPMAP may return -// D3DOK_NOAUTOGEN if the device doesn't support autogeneration for that format. -// D3DOK_NOAUTOGEN is a success code, not a failure code... the SUCCEEDED and FAILED macros -// will return true and false respectively for this code. +/* When passed to CheckDeviceFormat, D3DUSAGE_AUTOGENMIPMAP may return + * D3DOK_NOAUTOGEN if the device doesn't support autogeneration for that format. + * D3DOK_NOAUTOGEN is a success code, not a failure code... the SUCCEEDED and FAILED macros + * will return true and false respectively for this code. + */ #define D3DUSAGE_AUTOGENMIPMAP (0x00000400L) #define D3DUSAGE_DMAP (0x00004000L) @@ -1631,7 +1632,7 @@ typedef enum _D3DRESOURCETYPE { #define D3DUSAGE_TEXTAPI (0x10000000L) #define D3DUSAGE_RESTRICTED_CONTENT (0x00000800L) #define D3DUSAGE_RESTRICT_SHARED_RESOURCE (0x00002000L) -#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER (0x00001000L) +#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER (0x00001000L) #endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ @@ -1656,7 +1657,7 @@ typedef enum _D3DCUBEMAP_FACES #define D3DLOCK_DISCARD 0x00002000L #define D3DLOCK_NOOVERWRITE 0x00001000L #define D3DLOCK_NOSYSLOCK 0x00000800L -#define D3DLOCK_DONOTWAIT 0x00004000L +#define D3DLOCK_DONOTWAIT 0x00004000L #define D3DLOCK_NO_DIRTY_UPDATE 0x00008000L @@ -1983,7 +1984,7 @@ typedef struct _D3DPRESENTSTATS { typedef enum D3DSCANLINEORDERING { - D3DSCANLINEORDERING_UNKNOWN = 0, + D3DSCANLINEORDERING_UNKNOWN = 0, D3DSCANLINEORDERING_PROGRESSIVE = 1, D3DSCANLINEORDERING_INTERLACED = 2, } D3DSCANLINEORDERING; @@ -2045,14 +2046,14 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_INPUT typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT { - D3D_OMAC omac; + D3D_OMAC omac; GUID QueryType; HANDLE hChannel; UINT SequenceNumber; HRESULT ReturnCode; } D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_PROTECTION, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_PROTECTION, 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5); typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS @@ -2061,7 +2062,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { struct { - UINT ProtectionEnabled : 1; + UINT ProtectionEnabled : 1; UINT OverlayOrFullscreenRequired : 1; UINT Reserved : 30; }; @@ -2079,7 +2080,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CHANNELTYPE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CHANNELTYPE, 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT @@ -2091,7 +2092,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT @@ -2103,7 +2104,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT @@ -2125,7 +2126,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT @@ -2137,7 +2138,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUN } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT @@ -2166,7 +2167,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUT } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT @@ -2178,7 +2179,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCE } D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT @@ -2186,7 +2187,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT; @@ -2195,13 +2196,13 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT NumOutputIDs; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTID, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTID, 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT @@ -2209,7 +2210,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT OutputIDIndex; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT; @@ -2219,14 +2220,14 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT OutputIDIndex; UINT64 OutputID; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b); typedef enum _D3DBUSTYPE @@ -2240,8 +2241,8 @@ typedef enum _D3DBUSTYPE D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000, D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000, D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000, - D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, - D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, + D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, + D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, } D3DBUSTYPE; typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT @@ -2255,7 +2256,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT @@ -2267,7 +2268,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT @@ -2288,7 +2289,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT @@ -2302,24 +2303,24 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT { - D3D_OMAC omac; - GUID ConfigureType; - HANDLE hChannel; - UINT SequenceNumber; + D3D_OMAC omac; + GUID ConfigureType; + HANDLE hChannel; + UINT SequenceNumber; } D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT; typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT { - D3D_OMAC omac; - GUID ConfigureType; + D3D_OMAC omac; + GUID ConfigureType; HANDLE hChannel; - UINT SequenceNumber; + UINT SequenceNumber; HRESULT ReturnCode; } D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE @@ -2332,7 +2333,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE } D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_PROTECTION, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_PROTECTION, 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION @@ -2344,7 +2345,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION } D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION @@ -2358,7 +2359,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION } D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE @@ -2372,7 +2373,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE } D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION @@ -2385,7 +2386,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION typedef struct _D3DENCRYPTED_BLOCK_INFO { - UINT NumEncryptedBytesAtBeginning; + UINT NumEncryptedBytesAtBeginning; UINT NumBytesInSkipPattern; UINT NumBytesInEncryptPattern; } D3DENCRYPTED_BLOCK_INFO; diff --git a/gfx/include/vulkan/vulkan.h b/gfx/include/vulkan/vulkan.h index 121738c08f..463e0a1731 100644 --- a/gfx/include/vulkan/vulkan.h +++ b/gfx/include/vulkan/vulkan.h @@ -49,7 +49,7 @@ extern "C" { #define VK_NULL_HANDLE 0 - + #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; @@ -60,7 +60,7 @@ extern "C" { #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif - + typedef uint32_t VkFlags; diff --git a/gfx/video_coord_array.c b/gfx/video_coord_array.c index 835b9ba967..f06a619861 100644 --- a/gfx/video_coord_array.c +++ b/gfx/video_coord_array.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 9a3ec1e1db..1dee18db50 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c new file mode 100644 index 0000000000..22f481ce45 --- /dev/null +++ b/gfx/video_display_server.c @@ -0,0 +1,62 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include "video_display_server.h" +#include "video_driver.h" +#include "../verbosity.h" + +static const video_display_server_t *current_display_server = NULL; +static void *current_display_server_data = NULL; + +void* video_display_server_init(void) +{ + enum rarch_display_type type = video_driver_display_type_get(); + + switch (type) + { +#if defined(_WIN32) && !defined(_XBOX) + case RARCH_DISPLAY_WIN32: + current_display_server = &dispserv_win32; + break; +#endif +#if defined(HAVE_X11) + case RARCH_DISPLAY_X11: + current_display_server = &dispserv_x11; + break; +#endif + default: + current_display_server = &dispserv_null; + break; + } + + current_display_server_data = current_display_server->init(); + + RARCH_LOG("[Video]: Found display server: %s\n", current_display_server->ident); + + return current_display_server_data; +} + +void video_display_server_destroy(void) +{ + +} + +bool video_display_server_set_window_opacity(unsigned opacity) +{ + return current_display_server->set_window_opacity(current_display_server_data, opacity); +} diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h new file mode 100644 index 0000000000..ae5387c578 --- /dev/null +++ b/gfx/video_display_server.h @@ -0,0 +1,44 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __VIDEO_DISPLAY_SERVER__H +#define __VIDEO_DISPLAY_SERVER__H + +#include +#include + +RETRO_BEGIN_DECLS + +typedef struct video_display_server +{ + void *(*init)(void); + void (*destroy)(void); + bool (*set_window_opacity)(void *data, unsigned opacity); + const char *ident; +} video_display_server_t; + +void* video_display_server_init(void); +void video_display_server_destroy(void); +bool video_display_server_set_window_opacity(unsigned opacity); + +extern const video_display_server_t dispserv_win32; +extern const video_display_server_t dispserv_x11; +extern const video_display_server_t dispserv_null; + +RETRO_END_DECLS + +#endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index b4ae34c571..0302d7008b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -46,12 +46,9 @@ #include "../menu/menu_setting.h" #endif -#ifdef HAVE_OPENGL -#include "common/gl_common.h" -#endif - #include "video_thread_wrapper.h" #include "video_driver.h" +#include "video_display_server.h" #include "../frontend/frontend_driver.h" #include "../record/record_driver.h" @@ -178,7 +175,7 @@ static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; static struct retro_hw_render_callback hw_render; -static const struct +static const struct retro_hw_render_context_negotiation_interface * hw_render_context_negotiation = NULL; @@ -195,7 +192,7 @@ static bool video_driver_active = false; static video_driver_frame_t frame_bak = NULL; /* If set during context deinit, the driver should keep - * graphics context alive to avoid having to reset all + * graphics context alive to avoid having to reset all * context state. */ static bool video_driver_cache_context = false; @@ -215,7 +212,7 @@ static void *video_context_data = NULL; /** * dynamic.c:dynamic_request_hw_context will try to set flag data when the context * is in the middle of being rebuilt; in these cases we will save flag - * data and set this to true. + * data and set this to true. * When the context is reinit, it checks this, reads from * deferred_flag_data and cleans it. * @@ -668,7 +665,7 @@ static void video_driver_filter_free(void) if (video_driver_state_filter) rarch_softfilter_free(video_driver_state_filter); video_driver_state_filter = NULL; - + if (video_driver_state_buffer) { #ifdef _3DS @@ -693,7 +690,7 @@ static void video_driver_init_filter(enum retro_pixel_format colfmt_int) unsigned width = geom->max_width; unsigned height = geom->max_height; /* Deprecated format. Gets pre-converted. */ - enum retro_pixel_format colfmt = + enum retro_pixel_format colfmt = (colfmt_int == RETRO_PIXEL_FORMAT_0RGB1555) ? RETRO_PIXEL_FORMAT_RGB565 : colfmt_int; @@ -721,11 +718,11 @@ static void video_driver_init_filter(enum retro_pixel_format colfmt_int) maxsize = MAX(pow2_x, pow2_y); video_driver_state_scale = maxsize / RARCH_SCALE_BASE; video_driver_state_out_rgb32 = rarch_softfilter_get_output_format( - video_driver_state_filter) == + video_driver_state_filter) == RETRO_PIXEL_FORMAT_XRGB8888; video_driver_state_out_bpp = video_driver_state_out_rgb32 ? - sizeof(uint32_t) : + sizeof(uint32_t) : sizeof(uint16_t); /* TODO: Aligned output. */ @@ -786,7 +783,7 @@ static void video_driver_monitor_compute_fps_statistics(void) double stddev = 0.0; unsigned samples = 0; - if (video_driver_frame_time_count < + if (video_driver_frame_time_count < (2 * MEASURE_FRAME_TIME_SAMPLES_COUNT)) { RARCH_LOG( @@ -841,7 +838,7 @@ static void video_driver_free_internal(void) if ( !video_driver_data_own - && video_driver_data + && video_driver_data && current_video && current_video->free ) current_video->free(video_driver_data); @@ -1060,7 +1057,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) if (current_video->poke_interface) current_video->poke_interface(video_driver_data, &video_driver_poke); - if (current_video->viewport_info && + if (current_video->viewport_info && (!custom_vp->width || !custom_vp->height)) { @@ -1093,6 +1090,8 @@ static bool video_driver_init_internal(bool *video_is_threaded) video_context_driver_reset(); + video_display_server_init(); + return true; error: @@ -1391,7 +1390,7 @@ bool video_driver_cached_frame(void) recording_data = NULL; retro_ctx.frame_cb( - (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID) + (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID) ? frame_cache_data : NULL, frame_cache_width, frame_cache_height, frame_cache_pitch); @@ -1554,6 +1553,7 @@ static void video_driver_lock_new(void) void video_driver_destroy(void) { + video_display_server_destroy(); video_driver_cb_has_focus = null_driver_has_focus; video_driver_use_rgba = false; video_driver_data_own = false; @@ -1625,13 +1625,13 @@ void video_driver_set_viewport_config(void) base_width = 1; if (base_height == 0) base_height = 1; - aspectratio_lut[ASPECT_RATIO_CONFIG].value = + aspectratio_lut[ASPECT_RATIO_CONFIG].value = (float)base_width / base_height; /* 1:1 PAR. */ } } else { - aspectratio_lut[ASPECT_RATIO_CONFIG].value = + aspectratio_lut[ASPECT_RATIO_CONFIG].value = settings->floats.video_aspect_ratio; } } @@ -1676,7 +1676,7 @@ void video_driver_set_viewport_core(void) if (geom->aspect_ratio > 0.0f) aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio; else - aspectratio_lut[ASPECT_RATIO_CORE].value = + aspectratio_lut[ASPECT_RATIO_CORE].value = (float)geom->base_width / geom->base_height; } @@ -1918,10 +1918,10 @@ void video_driver_load_settings(config_file_t *conf) CONFIG_GET_INT_BASE(conf, global, console.screen.soft_filter_index, "soft_filter_index"); - CONFIG_GET_INT_BASE(conf, global, + CONFIG_GET_INT_BASE(conf, global, console.screen.resolutions.current.id, "current_resolution_id"); - CONFIG_GET_INT_BASE(conf, global, + CONFIG_GET_INT_BASE(conf, global, console.screen.flicker_filter_index, "flicker_filter_index"); } @@ -2050,7 +2050,7 @@ bool video_driver_is_active(void) } void video_driver_get_record_status( - bool *has_gpu_record, + bool *has_gpu_record, uint8_t **gpu_buf) { *gpu_buf = video_driver_record_gpu_buffer; @@ -2074,7 +2074,7 @@ void video_driver_gpu_record_deinit(void) bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb) { if ( - video_driver_poke + video_driver_poke && video_driver_poke->get_current_software_framebuffer && video_driver_poke->get_current_software_framebuffer( video_driver_data, fb)) @@ -2087,7 +2087,7 @@ bool video_driver_get_hw_render_interface( const struct retro_hw_render_interface **iface) { if ( - video_driver_poke + video_driver_poke && video_driver_poke->get_hw_render_interface && video_driver_poke->get_hw_render_interface( video_driver_data, iface)) @@ -2109,11 +2109,11 @@ void video_driver_set_title_buf(void) struct retro_system_info info; core_get_system_info(&info); - fill_pathname_noext(video_driver_title_buf, + fill_pathname_noext(video_driver_title_buf, msg_hash_to_str(MSG_PROGRAM), " ", sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, + strlcat(video_driver_title_buf, info.library_name, sizeof(video_driver_title_buf)); strlcat(video_driver_title_buf, @@ -2131,7 +2131,7 @@ void video_driver_set_title_buf(void) * @aspect_ratio : Aspect ratio (in float). * @keep_aspect : Preserve aspect ratio? * - * Gets viewport scaling dimensions based on + * Gets viewport scaling dimensions based on * scaled integer aspect ratio. **/ void video_viewport_get_scaled_integer(struct video_viewport *vp, @@ -2157,7 +2157,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, else { unsigned base_width; - /* Use system reported sizes as these define the + /* Use system reported sizes as these define the * geometry for the "normal" case. */ unsigned base_height = video_driver_av_info.geometry.base_height; @@ -2168,7 +2168,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, * This is sort of contradictory with the goal of integer scale, * but it is desirable in some cases. * - * If square pixels are used, base_height will be equal to + * If square pixels are used, base_height will be equal to * system->av_info.base_height. */ base_width = (unsigned)roundf(base_height * aspect_ratio); @@ -2244,7 +2244,7 @@ void video_driver_frame(const void *data, unsigned width, unsigned output_height = 0; unsigned output_pitch = 0; const char *msg = NULL; - retro_time_t new_time = + retro_time_t new_time = cpu_features_get_time_usec(); if (!video_driver_active) @@ -2276,8 +2276,8 @@ void video_driver_frame(const void *data, unsigned width, /* Get the amount of frames per seconds. */ if (video_driver_frame_count) { - unsigned write_index = - video_driver_frame_time_count++ & + unsigned write_index = + video_driver_frame_time_count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); video_driver_frame_time_samples[write_index] = new_time - fps_time; fps_time = new_time; @@ -2312,7 +2312,7 @@ void video_driver_frame(const void *data, unsigned width, snprintf(frames_text, sizeof(frames_text), - STRING_REP_UINT64, + "%" PRIu64, (uint64_t)video_driver_frame_count); strlcat(video_driver_window_title, @@ -2330,7 +2330,7 @@ void video_driver_frame(const void *data, unsigned width, snprintf( video_info.fps_text, sizeof(video_info.fps_text), - "FPS: %6.1f || %s: " STRING_REP_UINT64, + "FPS: %6.1f || %s: %" PRIu64, last_fps, msg_hash_to_str(MSG_FRAMES), (uint64_t)video_driver_frame_count); @@ -2369,7 +2369,7 @@ void video_driver_frame(const void *data, unsigned width, if ( ( !video_driver_state_filter - || !video_info.post_filter_record + || !video_info.post_filter_record || !data || video_driver_record_gpu_buffer ) && recording_data @@ -2409,7 +2409,7 @@ void video_driver_frame(const void *data, unsigned width, video_driver_frame_count++; - // Display the FPS, with a higher priority. + /* Display the FPS, with a higher priority. */ if (video_info.fps_show) runloop_msg_queue_push(video_info.fps_text, 2, 1, true); } @@ -2504,7 +2504,7 @@ void video_driver_build_info(video_frame_info_t *video_info) settings = config_get_ptr(); custom_vp = &settings->video_viewport_custom; video_info->refresh_rate = settings->floats.video_refresh_rate; - video_info->black_frame_insertion = + video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; @@ -2521,7 +2521,7 @@ void video_driver_build_info(video_frame_info_t *video_info) if (libretro_get_shared_context() && hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE) video_info->shared_context = true; - + video_info->font_enable = settings->bools.video_font_enable; video_info->font_msg_pos_x = settings->floats.video_msg_pos_x; video_info->font_msg_pos_y = settings->floats.video_msg_pos_y; @@ -2879,7 +2879,7 @@ bool video_context_driver_check_window(gfx_ctx_size_t *size_data) bool video_context_driver_init_image_buffer(const video_info_t *data) { - if ( + if ( current_video_context.image_buffer_init && current_video_context.image_buffer_init(video_context_data, data)) return true; @@ -2888,7 +2888,7 @@ bool video_context_driver_init_image_buffer(const video_info_t *data) bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img) { - if ( + if ( current_video_context.image_buffer_write && current_video_context.image_buffer_write(video_context_data, img->frame, img->width, img->height, img->pitch, @@ -2978,7 +2978,7 @@ bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc) bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics) { - if ( + if ( current_video_context.get_metrics(video_context_data, metrics->type, metrics->value)) @@ -3084,12 +3084,12 @@ bool video_context_driver_set_flags(gfx_ctx_flags_t *flags) { if (!flags) return false; - if (!current_video_context.set_flags) + if (!current_video_context.set_flags) { deferred_flag_data.flags = flags->flags; deferred_video_context_driver_set_flags = true; return false; - } + } current_video_context.set_flags(video_context_data, flags->flags); return true; @@ -3231,12 +3231,12 @@ static struct video_shader *video_shader_driver_get_current_shader_null(void *da static void video_shader_driver_set_params_null(void *data, void *shader_data, - unsigned width, unsigned height, - unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, - const void *info, - const void *prev_info, + const void *info, + const void *prev_info, const void *feedback_info, const void *fbo_info, unsigned fbo_info_cnt) { @@ -3289,7 +3289,7 @@ static void video_shader_driver_reset_to_defaults(void) if (current_shader->use) video_driver_cb_shader_use = current_shader->use; - else + else { current_shader->use = video_shader_driver_use_null; video_driver_cb_shader_use = video_shader_driver_use_null; @@ -3376,7 +3376,7 @@ bool video_shader_driver_info(video_shader_ctx_info_t *shader_info) bool video_shader_driver_filter_type(video_shader_ctx_filter_t *filter) { if (filter) - return current_shader->filter_type(shader_data, + return current_shader->filter_type(shader_data, filter->index, filter->smooth); return false; } diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 0267c11e6d..6abae88e13 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -56,6 +56,7 @@ #define VIDEO_SHADER_MENU_3 (GFX_MAX_SHADERS - 4) #define VIDEO_SHADER_MENU_4 (GFX_MAX_SHADERS - 5) #define VIDEO_SHADER_MENU_5 (GFX_MAX_SHADERS - 6) +#define VIDEO_SHADER_MENU_6 (GFX_MAX_SHADERS - 7) #endif @@ -205,11 +206,11 @@ typedef struct shader_backend /* Set shader parameters. */ void (*set_params)(void *data, void *shader_data, - unsigned width, unsigned height, - unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_counter, - const void *info, + const void *info, const void *prev_info, const void *feedback_info, const void *fbo_info, unsigned fbo_info_cnt); @@ -339,20 +340,20 @@ typedef struct video_info /* Start with V-Sync enabled. */ bool vsync; - /* If true, the output image should have the aspect ratio + /* If true, the output image should have the aspect ratio * as set in aspect_ratio. */ bool force_aspect; bool font_enable; - /* Width of window. - * If fullscreen mode is requested, - * a width of 0 means the resolution of the + /* Width of window. + * If fullscreen mode is requested, + * a width of 0 means the resolution of the * desktop should be used. */ unsigned width; - /* Height of window. - * If fullscreen mode is requested, + /* Height of window. + * If fullscreen mode is requested, * a height of 0 means the resolutiof the desktop should be used. */ unsigned height; @@ -369,7 +370,7 @@ typedef struct video_info bool is_threaded; - /* Use 32bit RGBA rather than native RGB565/XBGR1555. + /* Use 32bit RGBA rather than native RGB565/XBGR1555. * * XRGB1555 format is 16-bit and has byte ordering: 0RRRRRGGGGGBBBBB, * in native endian. @@ -390,17 +391,17 @@ typedef struct video_info unsigned viwidth; #endif - /* + /* * input_scale defines the maximum size of the picture that will * ever be used with the frame callback. * * The maximum resolution is a multiple of 256x256 size (RARCH_SCALE_BASE), * so an input scale of 2 means you should allocate a texture or of 512x512. * - * Maximum input size: RARCH_SCALE_BASE * input_scale + * Maximum input size: RARCH_SCALE_BASE * input_scale */ unsigned input_scale; - + uintptr_t parent; } video_info_t; @@ -719,7 +720,7 @@ typedef struct video_poke_interface } video_poke_interface_t; -/* msg is for showing a message on the screen +/* msg is for showing a message on the screen * along with the video frame. */ typedef bool (*video_driver_frame_t)(void *data, const void *frame, unsigned width, @@ -736,20 +737,20 @@ typedef struct video_driver const input_driver_t **input, void **input_data); - /* Updates frame on the screen. + /* Updates frame on the screen. * Frame can be either XRGB1555, RGB565 or ARGB32 format - * depending on rgb32 setting in video_info_t. - * Pitch is the distance in bytes between two scanlines in memory. - * - * When msg is non-NULL, + * depending on rgb32 setting in video_info_t. + * Pitch is the distance in bytes between two scanlines in memory. + * + * When msg is non-NULL, * it's a message that should be displayed to the user. */ video_driver_frame_t frame; - /* Should we care about syncing to vblank? Fast forwarding. + /* Should we care about syncing to vblank? Fast forwarding. * - * Requests nonblocking operation. + * Requests nonblocking operation. * - * True = VSync is turned off. + * True = VSync is turned off. * False = VSync is turned on. * */ void (*set_nonblock_state)(void *data, bool toggle); @@ -803,7 +804,7 @@ typedef struct video_driver typedef struct d3d_renderchain_driver { - void (*set_mvp)(void *chain_data, + void (*set_mvp)(void *chain_data, void *data, unsigned vp_width, unsigned vp_height, unsigned rotation); void (*chain_free)(void *data); @@ -837,60 +838,77 @@ typedef struct d3d_renderchain_driver typedef struct gl_renderchain_driver { void (*set_coords)(void *handle_data, + void *chain_data, void *shader_data, const struct video_coords *coords); - void (*set_mvp)(void *data, void *shader_data, + void (*set_mvp)(void *data, + void *chain_data, + void *shader_data, const void *mat_data); void (*init_texture_reference)( - void *data, unsigned i, + void *data, void *chain_data, unsigned i, unsigned internal_fmt, unsigned texture_fmt, unsigned texture_type); - void (*fence_iterate)(void *data, unsigned hard_sync_frames); - void (*fence_free)(void *data); + void (*fence_iterate)(void *data, void *chain_data, + unsigned hard_sync_frames); + void (*fence_free)(void *data, void *chain_data); void (*readback)(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src); void (*init_pbo)(unsigned size, const void *data); void (*bind_pbo)(unsigned idx); - void (*unbind_pbo)(void); + void (*unbind_pbo)(void *data, void *chain_data); void (*copy_frame)( - void *data, + void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch); - void (*restore_default_state)(void *data); - void (*new_vao)(void *data); - void (*free_vao)(void *data); - void (*bind_vao)(void *data); - void (*unbind_vao)(void *data); - void (*disable_client_arrays)(void); + void (*restore_default_state)(void *data, void *chain_data); + void (*new_vao)(void *data, void *chain_data); + void (*free_vao)(void *data, void *chain_data); + void (*bind_vao)(void *data, void *chain_data); + void (*unbind_vao)(void *data, void *chain_data); + void (*disable_client_arrays)(void *data, void *chain_data); void (*ff_vertex)(const void *data); void (*ff_matrix)(const void *data); - void (*bind_backbuffer)(void); - void (*deinit_fbo)(void *data); + void (*bind_backbuffer)(void *data, void *chain_data); + void (*deinit_fbo)(void *data, void *chain_data); void (*viewport_info)( - void *data, struct video_viewport *vp); + void *data, void *chain_data, struct video_viewport *vp); bool (*read_viewport)( - void *data, uint8_t *buffer, bool is_idle); + void *data, void *chain_data, uint8_t *buffer, bool is_idle); void (*bind_prev_texture)( void *data, + void *chain_data, const struct video_tex_info *tex_info); - void (*chain_free)(void *data); + void (*chain_free)(void *data, void *chain_data); void *(*chain_new)(void); - void (*init)(void *data, unsigned fbo_width, unsigned fbo_height); - bool (*init_hw_render)(void *data, unsigned width, unsigned height); - void (*free)(void *data); - void (*deinit_hw_render)(void *data); - void (*start_render)(void *data, video_frame_info_t *video_info); - void (*check_fbo_dimensions)(void *data); + void (*init)(void *data, void *chain_data, + unsigned fbo_width, unsigned fbo_height); + bool (*init_hw_render)(void *data, void *chain_data, + unsigned width, unsigned height); + void (*free)(void *data, void *chain_data); + void (*deinit_hw_render)(void *data, void *chain_data); + void (*start_render)(void *data, void *chain_data, + video_frame_info_t *video_info); + void (*check_fbo_dimensions)(void *data, void *chain_data); void (*recompute_pass_sizes)(void *data, + void *chain_data, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height); void (*renderchain_render)(void *data, + void *chain_data, video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, const struct video_tex_info *feedback_info); + void (*resolve_extensions)( + void *data, + void *chain_data, + const char *context_ident, + const video_info_t *video); const char *ident; } gl_renderchain_driver_t; @@ -939,9 +957,9 @@ void video_driver_unset_own_driver(void); bool video_driver_owns_driver(void); bool video_driver_is_hw_context(void); struct retro_hw_render_callback *video_driver_get_hw_context(void); -const struct retro_hw_render_context_negotiation_interface +const struct retro_hw_render_context_negotiation_interface *video_driver_get_context_negotiation_interface(void); -void video_driver_set_context_negotiation_interface(const struct +void video_driver_set_context_negotiation_interface(const struct retro_hw_render_context_negotiation_interface *iface); bool video_driver_is_video_cache_context(void); void video_driver_set_video_cache_context_ack(void); @@ -950,9 +968,9 @@ void video_driver_set_active(void); bool video_driver_is_active(void); bool video_driver_gpu_record_init(unsigned size); void video_driver_gpu_record_deinit(void); -bool video_driver_get_current_software_framebuffer(struct +bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb); -bool video_driver_get_hw_render_interface(const struct +bool video_driver_get_hw_render_interface(const struct retro_hw_render_interface **iface); bool video_driver_get_viewport_info(struct video_viewport *viewport); void video_driver_set_title_buf(void); @@ -971,7 +989,7 @@ const void *video_driver_find_handle(int index); * video_driver_find_ident: * @index : index of driver to get handle to. * - * Returns: Human-readable identifier of video driver at index. + * Returns: Human-readable identifier of video driver at index. * Can be NULL if nothing found. **/ const char *video_driver_find_ident(int index); @@ -1074,7 +1092,7 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, * @aspect_ratio : Aspect ratio (in float). * @keep_aspect : Preserve aspect ratio? * - * Gets viewport scaling dimensions based on + * Gets viewport scaling dimensions based on * scaled integer aspect ratio. **/ void video_viewport_get_scaled_integer(struct video_viewport *vp, @@ -1176,7 +1194,7 @@ void video_driver_reinit(void); void video_driver_get_window_title(char *buf, unsigned len); void video_driver_get_record_status( - bool *has_gpu_record, + bool *has_gpu_record, uint8_t **gpu_buf); bool *video_driver_get_threaded(void); diff --git a/gfx/video_filter.c b/gfx/video_filter.c index 9c4f1bf740..86976263a2 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -165,7 +165,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, userdata.conf = filt->conf; /* Index-specific configs take priority over ident-specific. */ - userdata.prefix[0] = key; + userdata.prefix[0] = key; userdata.prefix[1] = filt->impl->short_ident; /* Simple assumptions. */ @@ -209,7 +209,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, filt->impl_data = filt->impl->create( &softfilter_config, input_fmt, input_fmt, max_width, max_height, - threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : + threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : cpu_features_get_core_amount(), cpu_features, &userdata); if (!filt->impl_data) @@ -312,7 +312,7 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, RARCH_LOG("[SoftFilter]: Found plug: %s (%s).\n", impl->ident, impl->short_ident); - + filt->plugs = new_plugs; filt->plugs[filt->num_plugs].lib = lib; filt->plugs[filt->num_plugs].impl = impl; @@ -524,7 +524,7 @@ void rarch_softfilter_process(rarch_softfilter_t *filt, if (filt->impl && filt->impl->get_work_packets) filt->impl->get_work_packets(filt->impl_data, filt->packets, output, output_stride, input, width, height, input_stride); - + #ifdef HAVE_THREADS /* Fire off workers */ for (i = 0; i < filt->threads; i++) diff --git a/gfx/video_filters/2xbr.c b/gfx/video_filters/2xbr.c index 4dd94db1d0..ef978ee741 100644 --- a/gfx/video_filters/2xbr.c +++ b/gfx/video_filters/2xbr.c @@ -32,7 +32,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + #include "softfilter.h" #include #include @@ -68,17 +68,17 @@ struct filter_data uint16_t tbl_5_to_8[32]; uint16_t tbl_6_to_8[64]; }; - + static unsigned twoxbr_generic_input_fmts(void) { return SOFTFILTER_FMT_RGB565 | SOFTFILTER_FMT_XRGB8888; } - + static unsigned twoxbr_generic_output_fmts(unsigned input_fmts) { return input_fmts; } - + static unsigned twoxbr_generic_threads(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -218,7 +218,7 @@ static void SetupFormat(void * data) filt->RGBtoYUV[c] = y + u + v; } } - + static void *twoxbr_generic_create(const struct softfilter_config *config, unsigned in_fmt, unsigned out_fmt, unsigned max_width, unsigned max_height, @@ -244,7 +244,7 @@ static void *twoxbr_generic_create(const struct softfilter_config *config, return filt; } - + static void twoxbr_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) @@ -252,7 +252,7 @@ static void twoxbr_generic_output(void *data, *out_width = width * TWOXBR_SCALE; *out_height = height * TWOXBR_SCALE; } - + static void twoxbr_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -263,9 +263,9 @@ static void twoxbr_generic_destroy(void *data) free(filt->workers); free(filt); } - + #define ALPHA_BLEND_128_W(dst, src) dst = ((src & pg_lbmask) >> 1) + ((dst & pg_lbmask) >> 1) - + #define ALPHA_BLEND_32_W(dst, src) \ dst = ( \ (pg_red_mask & ((dst & pg_red_mask) + \ @@ -277,7 +277,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask))) >>3))) ) - + #define ALPHA_BLEND_8888_32_W(dst, src) \ dst = ( \ @@ -304,7 +304,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask))) >>2))) ) - + #define ALPHA_BLEND_8888_64_W(dst, src) \ dst = ( \ (pg_red_mask & ((dst & pg_red_mask) + \ @@ -330,7 +330,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask)) * 192) >>8))) ) - + #define ALPHA_BLEND_8888_192_W(dst, src) \ dst = ( \ @@ -375,44 +375,44 @@ static void twoxbr_generic_destroy(void *data) ALPHA_BLEND_224_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N2], PIXEL); \ E[N1] = E[N2]; \ - - + + #define LEFT_2_2X(N3, N2, PIXEL)\ ALPHA_BLEND_192_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N2], PIXEL); \ - + #define UP_2_2X(N3, N1, PIXEL)\ ALPHA_BLEND_192_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N1], PIXEL); \ - + #define DIA_2X(N3, PIXEL)\ ALPHA_BLEND_128_W(E[N3], PIXEL); \ - + #define LEFT_UP_2_8888_2X(N3, N2, N1, PIXEL)\ ALPHA_BLEND_8888_224_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N2], PIXEL); \ E[N1] = E[N2]; \ - - + + #define LEFT_2_8888_2X(N3, N2, PIXEL)\ ALPHA_BLEND_8888_192_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N2], PIXEL); \ - + #define UP_2_8888_2X(N3, N1, PIXEL)\ ALPHA_BLEND_8888_192_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N1], PIXEL); \ - + #define DIA_8888_2X(N3, PIXEL)\ ALPHA_BLEND_128_W(E[N3], PIXEL); \ #define df(Z, A, B)\ abs(Z->RGBtoYUV[A] - Z->RGBtoYUV[B])\ - + #define eq(Z, A, B)\ (df(Z, A, B) < 155)\ - + float df8(uint32_t A, uint32_t B, @@ -443,7 +443,7 @@ int eq8(uint32_t A, uint32_t B, { uint32_t r, g, b; uint32_t y, u, v; - + #ifdef MSB_FIRST r = abs((int)(((A & pg_red_mask )>>24) - ((B & pg_red_mask )>> 24))); g = abs((int)(((A & pg_green_mask )>>16) - ((B & pg_green_mask )>> 16))); @@ -453,7 +453,7 @@ int eq8(uint32_t A, uint32_t B, g = abs((int)(((A & pg_green_mask)>>8 ) - ((B & pg_green_mask )>> 8))); r = abs((int)(((A & pg_red_mask ) - (B & pg_red_mask )))); #endif - + y = fabs(0.299*r + 0.587*g + 0.114*b); u = fabs(-0.169*r - 0.331*g + 0.500*b); v = fabs(0.500*r - 0.419*g - 0.081*b); @@ -495,7 +495,7 @@ int eq8(uint32_t A, uint32_t B, ALPHA_BLEND_128_W( E[N3], ((df(Z, PE,PF) <= df(Z, PE,PH)) ? PF : PH)); \ }\ }\ - + #define FILTRO_RGB8888(Z, PE, _PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ ex = (PE!=PH && PE!=PF); \ if ( ex )\ @@ -530,8 +530,8 @@ int eq8(uint32_t A, uint32_t B, ALPHA_BLEND_128_W( E[N3], ((df8(PE,PF, pg_red_mask, pg_green_mask, pg_blue_mask) <= df8(PE,PH, pg_red_mask, pg_green_mask, pg_blue_mask)) ? PF : PH)); \ }\ }\ - - + + #ifndef twoxbr_function #define twoxbr_function(FILTRO, Z) \ E[0] = E[1] = E[2] = E[3] = PE;\ @@ -546,8 +546,8 @@ int eq8(uint32_t A, uint32_t B, ++in; \ out += 2 #endif - - + + static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) @@ -563,12 +563,12 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, (void)filt; nextline = (last) ? 0 : src_stride; - + for (; height; height--) { uint32_t *in = (uint32_t*)src; uint32_t *out = (uint32_t*)dst; - + for (finish = width; finish; finish -= 1) { uint32_t E[4]; @@ -594,7 +594,7 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, uint32_t G5 = *(in + nextline + nextline - 1); uint32_t H5 = *(in + nextline + nextline); uint32_t I5 = *(in + nextline + nextline + 1); - + /* * Map of the pixels: A1 B1 C1 * A0 PA PB PC C4 @@ -602,15 +602,15 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, * G0 PG PH _PI I4 * G5 H5 I5 */ - + twoxbr_function(FILTRO_RGB8888, filt); } - + src += src_stride; dst += 2 * dst_stride; } } - + static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) @@ -622,12 +622,12 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, uint16_t pg_blue_mask = BLUE_MASK565; uint16_t pg_lbmask = PG_LBMASK565; unsigned nextline = (last) ? 0 : src_stride; - + for (; height; height--) { uint16_t *in = (uint16_t*)src; uint16_t *out = (uint16_t*)dst; - + for (finish = width; finish; finish -= 1) { uint16_t E[4]; @@ -653,7 +653,7 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, uint16_t G5 = *(in + nextline + nextline - 1); uint16_t H5 = *(in + nextline + nextline); uint16_t I5 = *(in + nextline + nextline + 1); - + /* * Map of the pixels: A1 B1 C1 * A0 PA PB PC C4 @@ -661,47 +661,47 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, * G0 PG PH _PI I4 * G5 H5 I5 */ - + twoxbr_function(FILTRO_RGB565, filt); } - + src += src_stride; dst += 2 * dst_stride; } } - + static void twoxbr_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; unsigned width = thr->width; unsigned height = thr->height; - + twoxbr_generic_rgb565(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); } - + static void twoxbr_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; unsigned width = thr->width; unsigned height = thr->height; - + twoxbr_generic_xrgb8888(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); } - + static void twoxbr_generic_packets(void *data, struct softfilter_work_packet *packets, void *output, size_t output_stride, @@ -713,25 +713,25 @@ static void twoxbr_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - + unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * TWOXBR_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; thr->in_pitch = input_stride; thr->width = width; thr->height = y_end - y_start; - - /* Workers need to know if they can access + + /* Workers need to know if they can access * pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; - + if (filt->in_fmt == SOFTFILTER_FMT_RGB565) packets[i].work = twoxbr_work_cb_rgb565; #if 0 @@ -743,14 +743,14 @@ static void twoxbr_generic_packets(void *data, packets[i].thread_data = thr; } } - + static const struct softfilter_implementation twoxbr_generic = { twoxbr_generic_input_fmts, twoxbr_generic_output_fmts, - + twoxbr_generic_create, twoxbr_generic_destroy, - + twoxbr_generic_threads, twoxbr_generic_output, twoxbr_generic_packets, @@ -758,14 +758,14 @@ static const struct softfilter_implementation twoxbr_generic = { "2xBR", "2xbr", }; - + const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { (void)simd; return &twoxbr_generic; } - + #ifdef RARCH_INTERNAL #undef softfilter_get_implementation #undef softfilter_thread_data diff --git a/gfx/video_filters/2xsai.c b/gfx/video_filters/2xsai.c index 42a005143a..7accb0ae6f 100644 --- a/gfx/video_filters/2xsai.c +++ b/gfx/video_filters/2xsai.c @@ -225,7 +225,7 @@ static void twoxsai_generic_destroy(void *data) #endif static void twoxsai_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -257,7 +257,7 @@ static void twoxsai_generic_xrgb8888(unsigned width, unsigned height, } static void twoxsai_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; @@ -290,7 +290,7 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height, static void twoxsai_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -306,7 +306,7 @@ static void twoxsai_work_cb_rgb565(void *data, void *thread_data) static void twoxsai_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -331,12 +331,12 @@ static void twoxsai_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * TWOXSAI_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; @@ -344,7 +344,7 @@ static void twoxsai_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; diff --git a/gfx/video_filters/blargg_ntsc_snes.c b/gfx/video_filters/blargg_ntsc_snes.c index a8a3ea715a..334885981e 100644 --- a/gfx/video_filters/blargg_ntsc_snes.c +++ b/gfx/video_filters/blargg_ntsc_snes.c @@ -182,7 +182,7 @@ static void blargg_ntsc_snes_render_rgb565(void *data, int width, int height, } static void blargg_ntsc_snes_rgb565(void *data, unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { blargg_ntsc_snes_render_rgb565(data, width, height, @@ -194,7 +194,7 @@ static void blargg_ntsc_snes_rgb565(void *data, unsigned width, unsigned height, static void blargg_ntsc_snes_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -217,7 +217,7 @@ static void blargg_ntsc_snes_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -229,7 +229,7 @@ static void blargg_ntsc_snes_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can + /* Workers need to know if they can * access pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/darken.c b/gfx/video_filters/darken.c index b4b3a573a1..17cdce7334 100644 --- a/gfx/video_filters/darken.c +++ b/gfx/video_filters/darken.c @@ -104,7 +104,7 @@ static void darken_destroy(void *data) static void darken_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -120,7 +120,7 @@ static void darken_work_cb_xrgb8888(void *data, void *thread_data) static void darken_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -143,7 +143,7 @@ static void darken_packets(void *data, struct filter_data *filt = (struct filter_data*)data; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; diff --git a/gfx/video_filters/epx.c b/gfx/video_filters/epx.c index 2fa0407d96..0256f80ca6 100644 --- a/gfx/video_filters/epx.c +++ b/gfx/video_filters/epx.c @@ -196,7 +196,7 @@ static void epx_generic_rgb565 (unsigned width, unsigned height, static void epx_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -221,7 +221,7 @@ static void epx_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -233,7 +233,7 @@ static void epx_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can + /* Workers need to know if they can * access pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/lq2x.c b/gfx/video_filters/lq2x.c index fc362801ad..e00be0d29b 100644 --- a/gfx/video_filters/lq2x.c +++ b/gfx/video_filters/lq2x.c @@ -104,7 +104,7 @@ static void lq2x_generic_destroy(void *data) } static void lq2x_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned x, y; @@ -149,7 +149,7 @@ static void lq2x_generic_rgb565(unsigned width, unsigned height, } static void lq2x_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned x, y; @@ -194,7 +194,7 @@ static void lq2x_generic_xrgb8888(unsigned width, unsigned height, static void lq2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -210,7 +210,7 @@ static void lq2x_work_cb_rgb565(void *data, void *thread_data) static void lq2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -236,7 +236,7 @@ static void lq2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -248,7 +248,7 @@ static void lq2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/phosphor2x.c b/gfx/video_filters/phosphor2x.c index 1d3db0a02c..8ba64afe2a 100644 --- a/gfx/video_filters/phosphor2x.c +++ b/gfx/video_filters/phosphor2x.c @@ -118,7 +118,7 @@ static void blit_linear_line_xrgb8888(uint32_t * out, /* Blend edge pixels against black. */ out[0] = blend_pixels_xrgb8888(out[0], 0); - out[(width << 1) - 1] = + out[(width << 1) - 1] = blend_pixels_xrgb8888(out[(width << 1) - 1], 0); } @@ -133,12 +133,12 @@ static void blit_linear_line_rgb565(uint16_t * out, /* Blend in-between pixels. */ for (i = 1; i < (width << 1) - 1; i += 2) - out[i] = + out[i] = blend_pixels_rgb565(out[i - 1], out[i + 1]); /* Blend edge pixels against black. */ out[0] = blend_pixels_rgb565(out[0], 0); - out[(width << 1) - 1] = + out[(width << 1) - 1] = blend_pixels_rgb565(out[(width << 1) - 1], 0); } @@ -152,7 +152,7 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 0; x < width; x += 2) { unsigned r = red_xrgb8888(scanline[x]); - unsigned r_set = clamp8(r * filt->phosphor_bleed * + unsigned r_set = clamp8(r * filt->phosphor_bleed * filt->phosphor_bloom_8888[r]); set_red_xrgb8888(scanline[x + 1], r_set); } @@ -161,7 +161,7 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 0; x < width; x++) { unsigned g = green_xrgb8888(scanline[x]); - unsigned g_set = clamp8((g >> 1) + 0.5 * g * + unsigned g_set = clamp8((g >> 1) + 0.5 * g * filt->phosphor_bleed * filt->phosphor_bloom_8888[g]); set_green_xrgb8888(scanline[x], g_set); } @@ -171,13 +171,13 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 1; x < width; x += 2) { unsigned b = blue_xrgb8888(scanline[x]); - unsigned b_set = clamp8(b * filt->phosphor_bleed * + unsigned b_set = clamp8(b * filt->phosphor_bleed * filt->phosphor_bloom_8888[b]); set_blue_xrgb8888(scanline[x + 1], b_set); } } -static void bleed_phosphors_rgb565(void *data, +static void bleed_phosphors_rgb565(void *data, uint16_t *scanline, unsigned width) { unsigned x; @@ -187,7 +187,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 0; x < width; x += 2) { unsigned r = red_rgb565(scanline[x]); - unsigned r_set = clamp6(r * filt->phosphor_bleed * + unsigned r_set = clamp6(r * filt->phosphor_bleed * filt->phosphor_bloom_565[r]); set_red_rgb565(scanline[x + 1], r_set); } @@ -196,7 +196,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 0; x < width; x++) { unsigned g = green_rgb565(scanline[x]); - unsigned g_set = clamp6((g >> 1) + 0.5 * g * + unsigned g_set = clamp6((g >> 1) + 0.5 * g * filt->phosphor_bleed * filt->phosphor_bloom_565[g]); set_green_rgb565(scanline[x], g_set); } @@ -206,7 +206,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 1; x < width; x += 2) { unsigned b = blue_rgb565(scanline[x]); - unsigned b_set = clamp6(b * filt->phosphor_bleed * + unsigned b_set = clamp6(b * filt->phosphor_bleed * filt->phosphor_bloom_565[b]); set_blue_rgb565(scanline[x + 1], b_set); } @@ -263,26 +263,26 @@ static void *phosphor2x_generic_create(const struct softfilter_config *config, #if 0 /* Initialize lookup tables: */ - phosphorBloom = (scaleTimes .* + phosphorBloom = (scaleTimes .* linspace(0, 1, 255) .^ (1/2.2)) + scaleAdd; /* Not exactly sure of order of operations here ... */ #endif for (i = 0; i < 256; i++) { - filt->phosphor_bloom_8888[i] = - filt->scale_times * powf((float)i / 255.0f, 1.0f/2.2f) + + filt->phosphor_bloom_8888[i] = + filt->scale_times * powf((float)i / 255.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_8888[i] = - filt->scanrange_low + i * + filt->scan_range_8888[i] = + filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 255.0f; } for (i = 0; i < 64; i++) { - filt->phosphor_bloom_565[i] = + filt->phosphor_bloom_565[i] = filt->scale_times * powf((float)i / 31.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_565[i] = - filt->scanrange_low + i * + filt->scan_range_565[i] = + filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 31.0f; } @@ -311,7 +311,7 @@ static void phosphor2x_generic_destroy(void *data) static void phosphor2x_generic_xrgb8888(void *data, unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned y; @@ -344,14 +344,14 @@ static void phosphor2x_generic_xrgb8888(void *data, for (x = 0; x < (width << 1); x++) { unsigned max = max_component_xrgb8888(out_line[x]); - set_red_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_red_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * red_xrgb8888(out_line[x]))); - set_green_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_green_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * green_xrgb8888(out_line[x]))); - set_blue_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_blue_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * blue_xrgb8888(out_line[x]))); } } @@ -359,7 +359,7 @@ static void phosphor2x_generic_xrgb8888(void *data, static void phosphor2x_generic_rgb565(void *data, unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned y; @@ -390,14 +390,14 @@ static void phosphor2x_generic_rgb565(void *data, for (x = 0; x < (width << 1); x++) { unsigned max = max_component_rgb565(out_line[x]); - set_red_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_red_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * red_rgb565(out_line[x]))); - set_green_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_green_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * green_rgb565(out_line[x]))); - set_blue_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_blue_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * blue_rgb565(out_line[x]))); } } @@ -405,7 +405,7 @@ static void phosphor2x_generic_rgb565(void *data, static void phosphor2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -421,7 +421,7 @@ static void phosphor2x_work_cb_xrgb8888(void *data, void *thread_data) static void phosphor2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -444,7 +444,7 @@ static void phosphor2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -456,7 +456,7 @@ static void phosphor2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/scale2x.c b/gfx/video_filters/scale2x.c index 34269b236d..e1125be4bc 100644 --- a/gfx/video_filters/scale2x.c +++ b/gfx/video_filters/scale2x.c @@ -168,7 +168,7 @@ static void scale2x_generic_destroy(void *data) static void scale2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -184,7 +184,7 @@ static void scale2x_work_cb_xrgb8888(void *data, void *thread_data) static void scale2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -192,7 +192,7 @@ static void scale2x_work_cb_rgb565(void *data, void *thread_data) unsigned height = thr->height; scale2x_generic_rgb565(width, height, - thr->first, thr->last, input, + thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); @@ -207,12 +207,12 @@ static void scale2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * SCALE2X_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; @@ -220,7 +220,7 @@ static void scale2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc.c b/gfx/video_filters/snes_ntsc/snes_ntsc.c index 8ea1363ba4..bb33031389 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc.c +++ b/gfx/video_filters/snes_ntsc/snes_ntsc.c @@ -85,11 +85,11 @@ void snes_ntsc_init( snes_ntsc_t* ntsc, snes_ntsc_setup_t const* setup ) if ( !setup ) setup = &snes_ntsc_composite; init( &impl, setup ); - + merge_fields = setup->merge_fields; if ( setup->artifacts <= -1 && setup->fringing <= -1 ) merge_fields = 1; - + for ( entry = 0; entry < snes_ntsc_palette_size; entry++ ) { /* Reduce number of significant bits of source color. Clearing the @@ -130,41 +130,41 @@ void snes_ntsc_blit( snes_ntsc_t const* ntsc, SNES_NTSC_IN_T const* input, long snes_ntsc_out_t* line_out = (snes_ntsc_out_t*) rgb_out; int n; ++line_in; - + for ( n = chunk_count; n; --n ) { /* order of input and output pixels must not be altered */ SNES_NTSC_COLOR_IN( 0, SNES_NTSC_ADJ_IN( line_in [0] ) ); SNES_NTSC_RGB_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, SNES_NTSC_ADJ_IN( line_in [1] ) ); SNES_NTSC_RGB_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, SNES_NTSC_ADJ_IN( line_in [2] ) ); SNES_NTSC_RGB_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + line_in += 3; line_out += 7; } - + /* finish final pixels */ SNES_NTSC_COLOR_IN( 0, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + burst_phase = (burst_phase + 1) % snes_ntsc_burst_count; input += in_row_width; rgb_out = (char*) rgb_out + out_pitch; @@ -185,52 +185,52 @@ void snes_ntsc_blit_hires( snes_ntsc_t const* ntsc, SNES_NTSC_IN_T const* input, snes_ntsc_out_t* line_out = (snes_ntsc_out_t*) rgb_out; int n; line_in += 2; - + for ( n = chunk_count; n; --n ) { /* twice as many input pixels per chunk */ SNES_NTSC_COLOR_IN( 0, SNES_NTSC_ADJ_IN( line_in [0] ) ); SNES_NTSC_HIRES_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, SNES_NTSC_ADJ_IN( line_in [1] ) ); SNES_NTSC_HIRES_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, SNES_NTSC_ADJ_IN( line_in [2] ) ); SNES_NTSC_HIRES_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 3, SNES_NTSC_ADJ_IN( line_in [3] ) ); SNES_NTSC_HIRES_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 4, SNES_NTSC_ADJ_IN( line_in [4] ) ); SNES_NTSC_HIRES_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 5, SNES_NTSC_ADJ_IN( line_in [5] ) ); SNES_NTSC_HIRES_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_HIRES_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + line_in += 6; line_out += 7; } - + SNES_NTSC_COLOR_IN( 0, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 3, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 4, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 5, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_HIRES_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + burst_phase = (burst_phase + 1) % snes_ntsc_burst_count; input += in_row_width; rgb_out = (char*) rgb_out + out_pitch; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc.h b/gfx/video_filters/snes_ntsc/snes_ntsc.h index 82205e0115..d9aa710e27 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc.h +++ b/gfx/video_filters/snes_ntsc/snes_ntsc.h @@ -20,7 +20,7 @@ typedef struct snes_ntsc_setup_t double contrast; /* -1 = dark (0.5) +1 = light (1.5) */ double brightness; /* -1 = dark (0.5) +1 = light (1.5) */ double sharpness; /* edge contrast enhancement/blurring */ - + /* Advanced parameters */ double gamma; /* -1 = dark (1.5) +1 = light (0.5) */ double resolution; /* image resolution */ @@ -29,7 +29,7 @@ typedef struct snes_ntsc_setup_t double bleed; /* color bleed (color resolution reduction) */ int merge_fields; /* if 1, merges even and odd fields together to reduce flicker */ float const* decoder_matrix; /* optional RGB decoder matrix, 6 elements */ - + unsigned long const* bsnes_colortbl; /* undocumented; set to 0 */ } snes_ntsc_setup_t; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h b/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h index 2d3c654589..fc9be63739 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h +++ b/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h @@ -87,7 +87,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) /* quadratic mapping to reduce negative (blurring) range */ float to_angle = (float) setup->resolution + 1; to_angle = PI / maxh * (float) LUMA_CUTOFF * (to_angle * to_angle + 1); - + kernels [kernel_size * 3 / 2] = maxh; /* default center value */ for ( i = 0; i < kernel_half * 2 + 1; i++ ) { @@ -105,7 +105,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - (float) 0.5; } } - + /* apply blackman window and find sum */ sum = 0; for ( i = 0; i < kernel_half * 2 + 1; i++ ) @@ -114,7 +114,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) float blackman = 0.42f - 0.5f * (float) cos( x ) + 0.08f * (float) cos( x * 2 ); sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman); } - + /* normalize kernel */ sum = 1.0f / sum; for ( i = 0; i < kernel_half * 2 + 1; i++ ) @@ -130,7 +130,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) float const cutoff_factor = -0.03125f; float cutoff = (float) setup->bleed; int i; - + if ( cutoff < 0 ) { /* keep extreme value accessible only near upper end of scale (1.0) */ @@ -140,10 +140,10 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) cutoff *= -30.0f / 0.65f; } cutoff = cutoff_factor - 0.65f * cutoff_factor * cutoff; - + for ( i = -kernel_half; i <= kernel_half; i++ ) kernels [kernel_size / 2 + i] = (float) exp( i * i * cutoff ); - + /* normalize even and odd phases separately */ for ( i = 0; i < 2; i++ ) { @@ -151,7 +151,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) int x; for ( x = i; x < kernel_size; x += 2 ) sum += kernels [x]; - + sum = 1.0f / sum; for ( x = i; x < kernel_size; x += 2 ) { @@ -160,7 +160,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) } } } - + /* printf( "luma:\n" ); for ( i = kernel_size; i < kernel_size * 2; i++ ) @@ -169,7 +169,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) for ( i = 0; i < kernel_size; i++ ) printf( "%f\n", kernels [i] ); */ - + /* generate linear rescale kernels */ #if rescale_out > 1 { @@ -205,7 +205,7 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( !setup->palette ) impl->contrast *= default_palette_contrast; #endif - + impl->artifacts = (float) setup->artifacts; if ( impl->artifacts > 0 ) impl->artifacts *= artifacts_max - artifacts_mid; @@ -215,9 +215,9 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( impl->fringing > 0 ) impl->fringing *= fringing_max - fringing_mid; impl->fringing = impl->fringing * fringing_mid + fringing_mid; - + init_filters( impl, setup ); - + /* generate gamma table */ if ( gamma_size > 1 ) { @@ -229,7 +229,7 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) impl->to_float [i] = (float) pow( i * to_float, gamma ) * impl->contrast + impl->brightness; } - + /* setup decoder matricies */ { float hue = (float) setup->hue * PI + PI / 180 * ext_decoder_hue; @@ -241,13 +241,13 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( STD_HUE_CONDITION( setup ) ) hue += PI / 180 * (std_decoder_hue - ext_decoder_hue); } - + { float s = (float) sin( hue ) * sat; float c = (float) cos( hue ) * sat; float* out = impl->to_rgb; int n; - + n = burst_count; do { @@ -336,16 +336,16 @@ static void gen_kernel( init_t* impl, float y, float i, float q, snes_ntsc_rgb_t float const qc1 = (q + yy) * pixel->kernel [1]; float const ic2 = (i - yy) * pixel->kernel [2]; float const qc3 = (q - yy) * pixel->kernel [3]; - + float const factor = impl->artifacts * pixel->negate; float const ii = i * factor; float const yc0 = (y + ii) * pixel->kernel [0]; float const yc2 = (y - ii) * pixel->kernel [2]; - + float const qq = q * factor; float const yc1 = (y + qq) * pixel->kernel [1]; float const yc3 = (y - qq) * pixel->kernel [3]; - + float const* k = &impl->kernel [pixel->offset]; int n; ++pixel; @@ -368,12 +368,12 @@ static void gen_kernel( init_t* impl, float y, float i, float q, snes_ntsc_rgb_t } } while ( alignment_count > 1 && --alignment_remain ); - + if ( burst_count <= 1 ) break; - + to_rgb += 6; - + ROTATE_IQ( i, q, -0.866025f, -0.5f ); /* -120 degrees */ } while ( --burst_remain ); diff --git a/gfx/video_filters/softfilter.h b/gfx/video_filters/softfilter.h index 937e3fba8d..99cd10eedc 100644 --- a/gfx/video_filters/softfilter.h +++ b/gfx/video_filters/softfilter.h @@ -41,20 +41,20 @@ extern "C" { #define SOFTFILTER_SIMD_PS (1 << 14) /* A bit-mask of all supported SIMD instruction sets. - * Allows an implementation to pick different + * Allows an implementation to pick different * softfilter_implementation structs. */ typedef unsigned softfilter_simd_mask_t; -/* Returns true if config key was found. Otherwise, returns false, +/* Returns true if config key was found. Otherwise, returns false, * and sets value to default value. */ -typedef int (*softfilter_config_get_float_t)(void *userdata, +typedef int (*softfilter_config_get_float_t)(void *userdata, const char *key, float *value, float default_value); typedef int (*softfilter_config_get_int_t)(void *userdata, const char *key, int *value, int default_value); /* Allocates an array with values. free() with softfilter_config_free_t. */ -typedef int (*softfilter_config_get_float_array_t)(void *userdata, +typedef int (*softfilter_config_get_float_array_t)(void *userdata, const char *key, float **values, unsigned *out_num_values, const float *default_values, unsigned num_default_values); @@ -79,16 +79,16 @@ struct softfilter_config softfilter_config_get_int_array_t get_int_array; softfilter_config_get_string_t get_string; - /* Avoid problems where softfilter plug and + /* Avoid problems where softfilter plug and * host are linked against different C runtimes. */ softfilter_config_free_t free; }; /* Dynamic library entrypoint. */ -typedef const struct softfilter_implementation +typedef const struct softfilter_implementation *(*softfilter_get_implementation_t)(softfilter_simd_mask_t); -/* The same SIMD mask argument is forwarded to create() callback +/* The same SIMD mask argument is forwarded to create() callback * as well to avoid having to keep lots of state around. */ const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd); @@ -111,11 +111,11 @@ const struct softfilter_implementation *softfilter_get_implementation( * Returns a bitmask of supported input formats. */ typedef unsigned (*softfilter_query_input_formats_t)(void); -/* Returns a bitmask of supported output formats +/* Returns a bitmask of supported output formats * for a given input format. */ typedef unsigned (*softfilter_query_output_formats_t)(unsigned input_format); -/* In softfilter_process_t, the softfilter implementation +/* In softfilter_process_t, the softfilter implementation * submits work units to a worker thread pool. */ typedef void (*softfilter_work_t)(void *data, void *thread_data); struct softfilter_work_packet @@ -124,10 +124,10 @@ struct softfilter_work_packet void *thread_data; }; -/* Create a filter with given input and output formats as well as +/* Create a filter with given input and output formats as well as * maximum possible input size. * - * Input sizes can very per call to softfilter_process_t, but they + * Input sizes can very per call to softfilter_process_t, but they * will never be larger than the maximum. */ typedef void *(*softfilter_create_t)(const struct softfilter_config *config, unsigned in_fmt, unsigned out_fmt, @@ -137,13 +137,13 @@ typedef void *(*softfilter_create_t)(const struct softfilter_config *config, typedef void (*softfilter_destroy_t)(void *data); /* Given an input size, query the output size of the filter. - * If width and height == max_width/max_height, no other combination + * If width and height == max_width/max_height, no other combination * of width/height must return a larger size in any dimension. */ typedef void (*softfilter_query_output_size_t)(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height); -/* First step of processing a frame. The filter submits work by +/* First step of processing a frame. The filter submits work by * filling in the packets array. * * The number of elements in the array is as returned by query_num_threads. @@ -155,8 +155,8 @@ typedef void (*softfilter_get_work_packets_t)(void *data, const void *input, unsigned width, unsigned height, size_t input_stride); /* Returns the number of worker threads the filter will use. - * This can differ from the value passed to create() instead the filter - * cannot be parallelized, etc. The number of threads must be less-or-equal + * This can differ from the value passed to create() instead the filter + * cannot be parallelized, etc. The number of threads must be less-or-equal * compared to the value passed to create(). */ typedef unsigned (*softfilter_query_num_threads_t)(void *data); diff --git a/gfx/video_filters/super2xsai.c b/gfx/video_filters/super2xsai.c index 1d5c2bf309..f9dc321a9c 100644 --- a/gfx/video_filters/super2xsai.c +++ b/gfx/video_filters/super2xsai.c @@ -201,7 +201,7 @@ static void supertwoxsai_generic_destroy(void *data) #endif static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -221,7 +221,7 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, // 1 2 3 S1 // A1 A2 //-------------------------------------- - + supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_xrgb8888, supertwoxsai_interpolate2_xrgb8888); } @@ -231,7 +231,7 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, } static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; @@ -251,7 +251,7 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, // 1 2 3 S1 // A1 A2 //-------------------------------------- - + supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_rgb565, supertwoxsai_interpolate2_rgb565); } diff --git a/gfx/video_filters/supereagle.c b/gfx/video_filters/supereagle.c index 06b7c4c8c1..a191d104c3 100644 --- a/gfx/video_filters/supereagle.c +++ b/gfx/video_filters/supereagle.c @@ -215,7 +215,7 @@ static void supereagle_generic_destroy(void *data) #endif static void supereagle_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -239,7 +239,7 @@ static void supereagle_generic_xrgb8888(unsigned width, unsigned height, } static void supereagle_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 26aee9aedd..991e2768a5 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include "video_driver.h" /* video_context_driver_get_api */ #include #include +#include #include #include "../msg_hash.h" @@ -78,7 +80,7 @@ static const char *wrap_mode_to_str(enum gfx_wrap_type type) return "???"; } -/** +/** * wrap_str_to_mode: * @type : Wrap type in human-readable string format. * @@ -107,7 +109,7 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode) return RARCH_WRAP_DEFAULT; } -/** +/** * video_shader_parse_pass: * @conf : Preset file to read from. * @pass : Shader passes handle. @@ -143,10 +145,10 @@ static bool video_shader_parse_pass(config_file_t *conf, float fattr = 0.0f; int iattr = 0; - fp_fbo_buf[0] = mipmap_buf[0] = alias_buf[0] = + fp_fbo_buf[0] = mipmap_buf[0] = alias_buf[0] = scale_name_buf[0] = attr_name_buf[0] = scale_type[0] = scale_type_x[0] = scale_type_y[0] = frame_count_mod[0] = - tmp_str[0] = shader_name[0] = filter_name_buf[0] = + tmp_str[0] = shader_name[0] = filter_name_buf[0] = wrap_name_buf[0] = wrap_mode[0] = frame_count_mod_buf[0] = '\0'; srgb_output_buf[0] = '\0'; @@ -161,7 +163,7 @@ static bool video_shader_parse_pass(config_file_t *conf, strlcpy(tmp_path, tmp_str, path_size); path_resolve_realpath(tmp_path, path_size); - if (!path_file_exists(tmp_path)) + if (!filestream_exists(tmp_path)) strlcpy(pass->source.path, tmp_str, sizeof(pass->source.path)); else strlcpy(pass->source.path, tmp_path, sizeof(pass->source.path)); @@ -331,7 +333,7 @@ error: return false; } -/** +/** * video_shader_parse_textures: * @conf : Preset file to read from. * @shader : Shader pass handle. @@ -382,9 +384,9 @@ static bool video_shader_parse_textures(config_file_t *conf, path_size); path_resolve_realpath(tmp_path, path_size); - if (path_file_exists(tmp_path)) + if (filestream_exists(tmp_path)) { - strlcpy(shader->lut[shader->luts].path, + strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); } @@ -393,7 +395,7 @@ static bool video_shader_parse_textures(config_file_t *conf, snprintf(id_filter, sizeof(id_filter), "%s_linear", id); if (config_get_bool(conf, id_filter, &smooth)) - shader->lut[shader->luts].filter = smooth ? + shader->lut[shader->luts].filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; else shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC; @@ -419,7 +421,7 @@ error: return false; } -/** +/** * video_shader_parse_find_parameter: * @params : Shader parameter handle. * @num_params : Number of shader params in @params. @@ -444,7 +446,7 @@ static struct video_shader_parameter *video_shader_parse_find_parameter( return NULL; } -/** +/** * video_shader_set_current_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. @@ -477,10 +479,10 @@ bool video_shader_resolve_current_parameters(config_file_t *conf, return true; } - for (id = strtok_r(parameters, ";", &save); id; + for (id = strtok_r(parameters, ";", &save); id; id = strtok_r(NULL, ";", &save)) { - struct video_shader_parameter *parameter = + struct video_shader_parameter *parameter = (struct video_shader_parameter*) video_shader_parse_find_parameter( shader->parameters, shader->num_parameters, id); @@ -499,12 +501,12 @@ bool video_shader_resolve_current_parameters(config_file_t *conf, return true; } -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves all shader parameters belonging to shaders. + * Resolves all shader parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -520,10 +522,10 @@ bool video_shader_resolve_parameters(config_file_t *conf, for (i = 0; i < shader->passes; i++) { - RFILE *file = NULL; - size_t line_size = 4096 * sizeof(char); - char *line = (char*)malloc(4096 * sizeof(char)); - const char *path = shader->pass[i].source.path; + intfstream_t *file = NULL; + size_t line_size = 4096 * sizeof(char); + char *line = (char*)malloc(4096 * sizeof(char)); + const char *path = shader->pass[i].source.path; if (string_is_empty(path)) { @@ -545,7 +547,9 @@ bool video_shader_resolve_parameters(config_file_t *conf, /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - file = filestream_open(path, RFILE_MODE_READ_TEXT, -1); + file = intfstream_open_file(path, + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { @@ -556,7 +560,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, line[0] = '\0'; while (shader->num_parameters < ARRAY_SIZE(shader->parameters) - && filestream_gets(file, line, line_size)) + && intfstream_gets(file, line, line_size)) { int ret = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", @@ -582,7 +586,8 @@ bool video_shader_resolve_parameters(config_file_t *conf, } free(line); - filestream_close(file); + intfstream_close(file); + free(file); } if (conf && !video_shader_resolve_current_parameters(conf, shader)) @@ -591,12 +596,12 @@ bool video_shader_resolve_parameters(config_file_t *conf, return true; } -/** +/** * video_shader_parse_imports: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves import parameters belonging to shaders. + * Resolves import parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -611,7 +616,7 @@ static bool video_shader_parse_imports(config_file_t *conf, imports[0] = tmp_str[0] = '\0'; - if (!config_get_array(conf, "imports", imports, + if (!config_get_array(conf, "imports", imports, 1024 * sizeof(char))) { free(imports); @@ -633,10 +638,10 @@ static bool video_shader_parse_imports(config_file_t *conf, unsigned addr = 0; unsigned mask = 0; unsigned equal = 0; - struct state_tracker_uniform_info *var = + struct state_tracker_uniform_info *var = &shader->variable[shader->variables]; - semantic_buf[0] = wram_buf[0] = input_slot_buf[0] = + semantic_buf[0] = wram_buf[0] = input_slot_buf[0] = mask_buf[0] = equal_buf[0] = semantic[0] = '\0'; strlcpy(var->id, id, sizeof(var->id)); @@ -735,13 +740,13 @@ error: return false; } -/** +/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, - * textures, imports, etc). + * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ @@ -921,13 +926,13 @@ static void shader_write_variable(config_file_t *conf, } } -/** +/** * video_shader_write_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Saves preset and all associated state (passes, - * textures, imports, etc) to disk. + * textures, imports, etc) to disk. **/ void video_shader_write_conf_cgp(config_file_t *conf, struct video_shader *shader) @@ -997,7 +1002,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, } config_set_string(conf, "parameters", parameters); - + for (i = 0; i < shader->num_parameters; i++) config_set_float(conf, shader->parameters[i].id, shader->parameters[i].current); @@ -1034,7 +1039,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, if (shader->lut[i].filter != RARCH_FILTER_UNSPEC) { snprintf(key, sizeof(key), "%s_linear", shader->lut[i].id); - config_set_bool(conf, key, + config_set_bool(conf, key, shader->lut[i].filter == RARCH_FILTER_LINEAR); } @@ -1083,7 +1088,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, * Parses type of shader. * * Returns: value of shader type on success, otherwise will return - * user-supplied @fallback value. + * user-supplied @fallback value. **/ enum rarch_shader_type video_shader_parse_type(const char *path, enum rarch_shader_type fallback) @@ -1123,7 +1128,7 @@ enum rarch_shader_type video_shader_parse_type(const char *path, { case GFX_CTX_OPENGL_API: case GFX_CTX_OPENGL_ES_API: - if (shader_type == RARCH_SHADER_GLSL + if (shader_type == RARCH_SHADER_GLSL || (cg_supported && shader_type == RARCH_SHADER_CG)) return shader_type; break; @@ -1161,7 +1166,7 @@ void video_shader_resolve_relative(struct video_shader *shader, unsigned i; size_t tmp_path_size = 4096 * sizeof(char); char *tmp_path = (char*)malloc(4096 * sizeof(char)); - + tmp_path[0] = '\0'; for (i = 0; i < shader->passes; i++) diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index 4dcbabfcf7..cb79c1f09c 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -67,7 +67,7 @@ enum enum gfx_wrap_type { - RARCH_WRAP_BORDER = 0, /* Kinda deprecated, but keep as default. + RARCH_WRAP_BORDER = 0, /* Kinda deprecated, but keep as default. Will be translated to EDGE in GLES. */ RARCH_WRAP_DEFAULT = RARCH_WRAP_BORDER, RARCH_WRAP_EDGE, @@ -157,26 +157,26 @@ struct video_shader struct state_tracker_uniform_info variable[GFX_MAX_VARIABLES]; }; -/** +/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, - * textures, imports, etc). + * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ bool video_shader_read_conf_cgp(config_file_t *conf, struct video_shader *shader); -/** +/** * video_shader_write_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Saves preset and all associated state (passes, - * textures, imports, etc) to disk. + * textures, imports, etc) to disk. **/ void video_shader_write_conf_cgp(config_file_t *conf, struct video_shader *shader); @@ -192,7 +192,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, void video_shader_resolve_relative(struct video_shader *shader, const char *ref_path); -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. @@ -204,12 +204,12 @@ void video_shader_resolve_relative(struct video_shader *shader, bool video_shader_resolve_current_parameters(config_file_t *conf, struct video_shader *shader); -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves all shader parameters belonging to shaders. + * Resolves all shader parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -225,7 +225,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, * Parses type of shader. * * Returns: value of shader type on success, otherwise will return - * user-supplied @fallback value. + * user-supplied @fallback value. **/ enum rarch_shader_type video_shader_parse_type(const char *path, enum rarch_shader_type fallback); diff --git a/gfx/video_state_tracker.c b/gfx/video_state_tracker.c index 8cebede20f..a36a50f8fb 100644 --- a/gfx/video_state_tracker.c +++ b/gfx/video_state_tracker.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -54,7 +54,7 @@ struct state_tracker_internal uint32_t prev[2]; int frame_count; int frame_count_prev; - uint32_t old_value; + uint32_t old_value; int transition_count; }; @@ -121,7 +121,7 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info) tracker->info[i].addr = info->info[i].addr; tracker->info[i].type = info->info[i].type; - tracker->info[i].mask = (info->info[i].mask == 0) + tracker->info[i].mask = (info->info[i].mask == 0) ? 0xffff : info->info[i].mask; tracker->info[i].equal = info->info[i].equal; @@ -250,13 +250,13 @@ static void state_tracker_update_element( } uniform->value = info->frame_count_prev; break; - + #ifdef HAVE_PYTHON case RARCH_STATE_PYTHON: uniform->value = py_state_get(info->py, info->id, frame_count); break; #endif - + default: break; } @@ -282,7 +282,7 @@ unsigned state_tracker_get_uniform(state_tracker_t *tracker, unsigned elem, unsigned frame_count) { unsigned i, elems = elem; - + if (tracker->info_elem < elem) elems = tracker->info_elem; diff --git a/gfx/video_state_tracker.h b/gfx/video_state_tracker.h index abcd2e27e8..649f48e420 100644 --- a/gfx/video_state_tracker.h +++ b/gfx/video_state_tracker.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 59739117f4..3fc697d260 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -590,7 +590,7 @@ static void video_thread_loop(void *data) if (thr->frame.updated) updated = true; - /* To avoid race condition where send_cmd is updated + /* To avoid race condition where send_cmd is updated * right after the switch is checked. */ pkt = thr->cmd_data; @@ -721,7 +721,7 @@ static bool video_thread_frame(void *data, const void *frame_, uint8_t *dst = NULL; thread_video_t *thr = (thread_video_t*)data; - /* If called from within read_viewport, we're actually in the + /* If called from within read_viewport, we're actually in the * driver thread, so just render directly. */ if (thr->frame.within_thread) { @@ -733,7 +733,7 @@ static bool video_thread_frame(void *data, const void *frame_, return false; } - copy_stride = width * (thr->info.rgb32 + copy_stride = width * (thr->info.rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); src = (const uint8_t*)frame_; @@ -762,7 +762,7 @@ static bool video_thread_frame(void *data, const void *frame_, } } - /* Drop frame if updated flag is still set, as thread is + /* Drop frame if updated flag is still set, as thread is * still working on last frame. */ if (!thr->frame.updated) { @@ -875,13 +875,13 @@ static void video_thread_set_viewport(void *data, unsigned width, thread_video_t *thr = (thread_video_t*)data; if (!thr) return; - + slock_lock(thr->lock); if (thr->driver && thr->driver->set_viewport) thr->driver->set_viewport(thr->driver_data, width, height, force_full, allow_rotate); - + slock_unlock(thr->lock); } @@ -898,10 +898,10 @@ static void video_thread_set_rotation(void *data, unsigned rotation) video_thread_send_and_wait_user_to_thread(thr, &pkt); } -/* This value is set async as stalling on the video driver for +/* This value is set async as stalling on the video driver for * every query is too slow. * - * This means this value might not be correct, so viewport + * This means this value might not be correct, so viewport * reads are not supported for now. */ static void video_thread_viewport_info(void *data, struct video_viewport *vp) { @@ -983,7 +983,7 @@ static bool thread_overlay_load(void *data, { thread_video_t *thr = (thread_video_t*)data; thread_packet_t pkt = { CMD_OVERLAY_LOAD }; - const struct texture_image *images = + const struct texture_image *images = (const struct texture_image*)image_data; if (!thr) @@ -1162,7 +1162,7 @@ static void thread_set_texture_frame(void *data, const void *frame, thread_video_t *thr = (thread_video_t*)data; slock_lock(thr->frame.lock); - required = width * height * + required = width * height * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); if (required > thr->texture.frame_cap) @@ -1246,7 +1246,7 @@ static void thread_apply_state_changes(void *data) slock_unlock(thr->frame.lock); } -/* This is read-only state which should not +/* This is read-only state which should not * have any kind of race condition. */ static struct video_shader *thread_get_current_shader(void *data) { @@ -1352,7 +1352,7 @@ static void video_thread_set_callbacks( * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver - * @input_data : Input input data + * @input_data : Input input data * @driver : Input Video driver * @info : Video info handle. * @@ -1381,7 +1381,7 @@ bool video_init_thread(const video_driver_t **out_driver, * video_thread_get_ptr: * @drv : Found driver. * - * Gets the underlying video driver associated with the + * Gets the underlying video driver associated with the * threaded video wrapper. Sets @drv to the found * video driver. * diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 31c2010cff..3fd306590a 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ typedef struct thread_video thread_video_t; * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver - * @input_data : Input input data + * @input_data : Input input data * @driver : Input Video driver * @info : Video info handle. * @@ -61,7 +61,7 @@ bool video_init_thread( * video_thread_get_ptr: * @drv : Found driver. * - * Gets the underlying video driver associated with the + * Gets the underlying video driver associated with the * threaded video wrapper. Sets @drv to the found * video driver. * diff --git a/griffin/griffin.c b/griffin/griffin.c index 2bbb31a47b..060da11798 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -58,6 +58,7 @@ COMPATIBILITY #endif #include "../libretro-common/compat/compat_fnmatch.c" +#include "../libretro-common/compat/fopen_utf8.c" #include "../libretro-common/memmap/memalign.c" /*============================================================ @@ -187,9 +188,8 @@ VIDEO CONTEXT #include "../gfx/drivers_context/wgl_ctx.c" #endif -#if defined(_WIN32) && !defined(_XBOX) #include "../gfx/drivers_context/gdi_ctx.c" -#endif +#include "../gfx/display_servers/dispserv_win32.c" #if defined(HAVE_FFMPEG) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES3) @@ -251,9 +251,12 @@ VIDEO CONTEXT #if defined(HAVE_X11) #include "../gfx/common/x11_common.c" -#include "../gfx/common/dbus_common.c" #include "../gfx/common/xinerama_common.c" +#ifdef HAVE_DBUS +#include "../gfx/common/dbus_common.c" +#endif + #ifndef HAVE_OPENGLES #include "../gfx/drivers_context/x_ctx.c" #endif @@ -370,6 +373,7 @@ VIDEO DRIVER #endif #include "../gfx/drivers_renderchain/null_renderchain.c" +#include "../gfx/display_servers/dispserv_null.c" #ifdef HAVE_OPENGL #include "../gfx/common/gl_common.c" @@ -745,6 +749,7 @@ AUDIO DRIVERS ============================================================ */ #include "../gfx/video_driver.c" +#include "../gfx/video_display_server.c" #include "../gfx/video_coord_array.c" #include "../input/input_driver.c" #include "../audio/audio_driver.c" @@ -819,6 +824,7 @@ FILE #include "../libretro-common/streams/file_stream_transforms.c" #include "../libretro-common/streams/interface_stream.c" #include "../libretro-common/streams/memory_stream.c" +#include "../libretro-common/vfs/vfs_implementation.c" #include "../list_special.c" #include "../libretro-common/string/stdstring.c" #include "../libretro-common/file/nbio/nbio_stdio.c" @@ -1043,6 +1049,17 @@ MENU #include "../menu/menu_setting.c" #include "../menu/menu_cbs.c" #include "../menu/menu_content.c" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../menu/menu_networking.c" + +#ifdef __cplusplus +} +#endif + #include "../menu/widgets/menu_entry.c" #include "../menu/widgets/menu_filebrowser.c" #include "../menu/widgets/menu_dialog.c" diff --git a/input/common/input_x11_common.c b/input/common/input_x11_common.c index d9598496e0..dbbe53fc43 100644 --- a/input/common/input_x11_common.c +++ b/input/common/input_x11_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/common/input_x11_common.h b/input/common/input_x11_common.h index 4d325e4525..a0cd0342d5 100644 --- a/input/common/input_x11_common.h +++ b/input/common/input_x11_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/common/linux_common.c b/input/common/linux_common.c index 17825654a3..0d35611db1 100644 --- a/input/common/linux_common.c +++ b/input/common/linux_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -77,9 +77,9 @@ bool linux_terminal_init(void) void linux_terminal_claim_stdin(void) { - /* We need to disable use of stdin command interface if + /* We need to disable use of stdin command interface if * stdin is supposed to be used for input. */ - linux_stdin_claimed = true; + linux_stdin_claimed = true; } bool linux_terminal_grab_stdin(void *data) @@ -114,7 +114,7 @@ bool linux_terminal_disable_input(void) sa.sa_flags = SA_RESTART | SA_RESETHAND; sigemptyset(&sa.sa_mask); - /* Trap some standard termination codes so we + /* Trap some standard termination codes so we * can restore the keyboard before we lose control. */ sigaction(SIGABRT, &sa, NULL); sigaction(SIGBUS, &sa, NULL); diff --git a/input/common/linux_common.h b/input/common/linux_common.h index b924b7246d..701adbbd88 100644 --- a/input/common/linux_common.h +++ b/input/common/linux_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index 04b24d6746..bf21fbb901 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -27,7 +27,7 @@ struct hidpad_nesusb_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_nesusb_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,15 @@ static void hidpad_nesusb_deinit(void *data) free(device); } -static uint64_t hidpad_nesusb_get_buttons(void *data) +static void hidpad_nesusb_get_buttons(void *data, retro_bits_t* state) { - struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; + if (device) + { + BITS_COPY16_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_nesusb_get_axis(void *data, unsigned axis) @@ -102,7 +105,6 @@ static void hidpad_nesusb_packet_handler(void *data, uint8_t *packet, uint16_t s RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_Y, RETRO_DEVICE_ID_JOYPAD_X, - 16, /* HOME BUTTON when pressing SELECT+START */ }; struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; @@ -113,12 +115,11 @@ static void hidpad_nesusb_packet_handler(void *data, uint8_t *packet, uint16_t s device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START=HOME */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } static void hidpad_nesusb_set_rumble(void *data, diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index 10c922b66c..87b174bd4e 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -27,7 +27,7 @@ struct hidpad_ps2adapter_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_ps2adapter_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,15 @@ static void hidpad_ps2adapter_deinit(void *data) free(device); } -static uint64_t hidpad_ps2adapter_get_buttons(void *data) +static void hidpad_ps2adapter_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; + if (device) + { + BITS_COPY16_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) @@ -74,7 +77,7 @@ static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) if (!device || axis >= 4) return 0; - + switch (axis) { case 0: @@ -90,7 +93,7 @@ static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) val = device->data[2]; break; } - + val = (val << 8) - 0x8000; return (abs(val) > 0x1000) ? val : 0; @@ -133,7 +136,7 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 /* Check if the data corresponds to the first controller, exit otherwise */ if (packet[1] != 1) return; - + memcpy(device->data, packet, size); device->buttons = 0; @@ -143,7 +146,7 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; - + /* Now process the hat values as if they were pad buttons */ hat_value = PS2_H_GET(device->data[6]); device->buttons |= PS2_H_LEFT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 37ca54b8d2..7e96e5a7f4 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -20,6 +20,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" struct hidpad_ps3_data { @@ -27,7 +28,7 @@ struct hidpad_ps3_data send_control_t send_control; uint8_t data[512]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; bool have_led; uint16_t motors[2]; }; @@ -104,12 +105,20 @@ static void hidpad_ps3_deinit(void *data) free(device); } -static uint64_t hidpad_ps3_get_buttons(void *data) +static void hidpad_ps3_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_ps3_data *device = (struct hidpad_ps3_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_ps3_data *device = (struct hidpad_ps3_data*)data; + if ( device ) + { + /*copy first 16 bits - standard RetroPad controls*/ + BITS_COPY16_PTR(state, device->buttons); + + /*PS button?*/ + if (device->buttons & 0x10000) + BIT256_SET_PTR(state, RARCH_MENU_TOGGLE); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps3_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 198107842f..ee5ead5c32 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -20,6 +20,7 @@ #include #include +#include #include "joypad_connection.h" #include "../input_defines.h" @@ -184,35 +185,51 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) return false; } -static uint64_t hidpad_ps4_get_buttons(void *data) +static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { - uint64_t buttonstate = 0; struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; - struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; + struct ps4 *rpt = device ? + (struct ps4*)&device->data : NULL; if (!device || !rpt) - return 0; + return; - buttonstate |= (rpt->btn.r3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0); - buttonstate |= (rpt->btn.l3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0); - buttonstate |= (rpt->btn.options ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0); - buttonstate |= (rpt->btn.share ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0); - buttonstate |= (rpt->btn.r2 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0); - buttonstate |= (rpt->btn.l2 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0); - buttonstate |= (rpt->btn.r1 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0); - buttonstate |= (rpt->btn.l1 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0); + BIT256_CLEAR_ALL_PTR( state ); - buttonstate |= (rpt->btn.triangle ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0); - buttonstate |= (rpt->btn.circle ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0); - buttonstate |= (rpt->btn.cross ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0); - buttonstate |= (rpt->btn.square ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0); - buttonstate |= (rpt->btn.ps ? (UINT64_C(1) << RARCH_MENU_TOGGLE) : 0); - - return buttonstate; + if (rpt->btn.r3) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); + if (rpt->btn.l3) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); + if (rpt->btn.options) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); + if ( rpt->btn.share) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); + if ( rpt->btn.r2) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); + if (rpt->btn.l2) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); + if (rpt->btn.r1) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); + if (rpt->btn.l1) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); + if (rpt->btn.triangle) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); + if (rpt->btn.circle) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); + if (rpt->btn.cross) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); + if (rpt->btn.square) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT))) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN))) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT))) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP))) + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); + if (rpt->btn.ps) + BIT256_SET_PTR( state, RARCH_MENU_TOGGLE ); } static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index d05bfc3793..b9d2e7f9ba 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -27,7 +27,7 @@ struct hidpad_psxadapter_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_psxadapter_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,15 @@ static void hidpad_psxadapter_deinit(void *data) free(device); } -static uint64_t hidpad_psxadapter_get_buttons(void *data) +static void hidpad_psxadapter_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; + if (device) + { + BITS_COPY16_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) @@ -75,7 +78,7 @@ static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) if (!device || axis >= 4 || (device->data[2]==0x7F) ) /* digital mode detection */ return 0; - + switch (axis) { case 0: @@ -91,7 +94,7 @@ static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) val = device->data[2]; break; } - + val = (val << 8) - 0x8000; return (abs(val) > 0x1000) ? val : 0; /* hard coded deadzone */ @@ -107,7 +110,7 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 { uint32_t i, pressed_keys; int16_t hat_value; - static const uint32_t button_mapping[17] = + static const uint32_t button_mapping[16] = { RETRO_DEVICE_ID_JOYPAD_L2, RETRO_DEVICE_ID_JOYPAD_R2, @@ -125,7 +128,6 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_Y, - 16/* HOME BUTTON when pressing SELECT+START */ }; struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; @@ -136,29 +138,28 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START = MENU TOGGLE */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; if (device->data[2]==0x7F) /* digital mode detection */ { /* We're in digital mode, process the dpad values */ - device->buttons |= (device->data[4]==0x00) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - device->buttons |= (device->data[4]==0xFF) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - device->buttons |= (device->data[5]==0x00) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - device->buttons |= (device->data[5]==0xFF) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + device->buttons |= (device->data[4]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + device->buttons |= (device->data[4]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + device->buttons |= (device->data[5]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + device->buttons |= (device->data[5]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; } else { /* We're in analog mode, process the hat values as if they were pad buttons */ hat_value = PSX_H_GET(device->data[6]); - device->buttons |= PSX_H_LEFT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - device->buttons |= PSX_H_RIGHT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - device->buttons |= PSX_H_UP(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - device->buttons |= PSX_H_DOWN(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + device->buttons |= PSX_H_LEFT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + device->buttons |= PSX_H_RIGHT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + device->buttons |= PSX_H_UP(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + device->buttons |= PSX_H_DOWN(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; } } diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index d5cc9e2811..62759b51fb 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -28,7 +28,7 @@ struct hidpad_snesusb_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_snesusb_init(void *data, uint32_t slot, send_control_t ptr) @@ -60,12 +60,15 @@ static void hidpad_snesusb_deinit(void *data) free(device); } -static uint64_t hidpad_snesusb_get_buttons(void *data) +static void hidpad_snesusb_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; + if (device) + { + BITS_COPY16_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) @@ -85,7 +88,7 @@ static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t size) { uint32_t i, pressed_keys; - static const uint32_t button_mapping[17] = + static const uint32_t button_mapping[16] = { RETRO_DEVICE_ID_JOYPAD_L, RETRO_DEVICE_ID_JOYPAD_R, @@ -102,8 +105,7 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, - RETRO_DEVICE_ID_JOYPAD_Y, - 16, /* HOME BUTTON when pressing SELECT+START */ + RETRO_DEVICE_ID_JOYPAD_Y }; struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; @@ -114,12 +116,11 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START = MENU TOGGLE */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } static void hidpad_snesusb_set_rumble(void *data, diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index dcf342a5f1..83ac50d736 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -25,6 +25,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" /* wiimote state flags*/ #define WIIMOTE_STATE_DEV_FOUND 0x0001 @@ -198,7 +199,7 @@ static int wiimote_send(struct connect_wii_wiimote_t* wm, return 1; } -/* +/* * Request the wiimote controller status. * * Controller status includes: battery level, LED status, expansions. @@ -426,13 +427,13 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, switch (wm->handshake_state) { case 0: - /* no ha habido nunca handshake, debemos forzar un + /* no ha habido nunca handshake, debemos forzar un * mensaje de staus para ver que pasa. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); wiimote_set_leds(wm, WIIMOTE_LED_NONE); - /* Request the status of the Wiimote to + /* Request the status of the Wiimote to * see if there is an expansion */ wiimote_status(wm); @@ -440,16 +441,16 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, return 0; case 1: { - /* estamos haciendo handshake o bien se necesita iniciar un + /* estamos haciendo handshake o bien se necesita iniciar un * nuevo handshake ya que se inserta(quita una expansion. */ int attachment = 0; if(event != WM_RPT_CTRL_STATUS) return 0; - /* Is an attachment connected to + /* Is an attachment connected to * the expansion port? */ - if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == + if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT) attachment = 1; @@ -473,19 +474,19 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, /* Rehandshake. */ WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE); - /* forzamos un handshake por si venimos + /* forzamos un handshake por si venimos * de un hanshake completo. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); } - /*Old way. initialize the extension was by writing the + /*Old way. initialize the extension was by writing the * single encryption byte 0x00 to 0x(4)A40040. */ #if 0 buf = 0x00; wiimote_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1); #endif - /* NEW WAY 0x55 to 0x(4)A400F0, then writing + /* NEW WAY 0x55 to 0x(4)A400F0, then writing * 0x00 to 0x(4)A400FB. (support clones) */ buf = 0x55; wiimote_write_data(wm, 0x04A400F0, &buf, 1); @@ -515,7 +516,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, printf("rehandshake\n"); #endif WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE); - /* forzamos un handshake por si venimos + /* forzamos un handshake por si venimos * de un hanshake completo. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); } @@ -671,12 +672,15 @@ static int16_t hidpad_wii_get_axis(void *data, unsigned axis) return 0; } -static uint64_t hidpad_wii_get_buttons(void *data) +static void hidpad_wii_get_buttons(void *data, retro_bits_t *state) { - struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; - if (!device) - return 0; - return device->btns | (device->exp.cc.classic.btns << 16); + struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; + if ( device ) + { + /* TODO/FIXME - Broken? this doesn't match retropad! */ + uint32_t b = device->btns | (device->exp.cc.classic.btns << 16); + BITS_COPY32_PTR(state, b); + } } static void hidpad_wii_packet_handler(void *data, diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index 8f1368fdd7..5705a7acdf 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -20,6 +20,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" struct hidpad_wiiugca_data { @@ -27,7 +28,7 @@ struct hidpad_wiiugca_data send_control_t send_control; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_wiiugca_init(void *data, uint32_t slot, send_control_t ptr) @@ -62,12 +63,15 @@ static void hidpad_wiiugca_deinit(void *data) free(device); } -static uint64_t hidpad_wiiugca_get_buttons(void *data) +static void hidpad_wiiugca_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; + if (device) + { + BITS_COPY16_PTR(state, device->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_wiiugca_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 05d36c240f..c3787bbe3c 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -97,7 +97,7 @@ static void* hidpad_wiiupro_init(void *data, device->connection = connection; device->slot = slot; device->send_control = ptr; - + calib_data->calib_round = 0; /* Without this, the digital buttons won't be reported. */ hidpad_wiiupro_send_control(device); @@ -118,35 +118,51 @@ static void hidpad_wiiupro_deinit(void *data) free(device); } -static uint64_t hidpad_wiiupro_get_buttons(void *data) +static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) { - uint64_t buttonstate = 0; struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; - struct wiiupro *rpt = device ? (struct wiiupro*)&device->data : NULL; + struct wiiupro *rpt = device ? + (struct wiiupro*)&device->data : NULL; if (!device || !rpt) - return 0; + return; - buttonstate |= (rpt->btn.r3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0); - buttonstate |= (rpt->btn.l3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0); - buttonstate |= (rpt->btn.plus ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0); - buttonstate |= (rpt->btn.minus ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0); - buttonstate |= (rpt->btn.zr ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0); - buttonstate |= (rpt->btn.zl ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0); - buttonstate |= (rpt->btn.r ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0); - buttonstate |= (rpt->btn.l ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0); + BIT256_CLEAR_ALL_PTR(state); - buttonstate |= (rpt->btn.x ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0); - buttonstate |= (rpt->btn.a ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0); - buttonstate |= (rpt->btn.b ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0); - buttonstate |= (rpt->btn.y ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0); - buttonstate |= (rpt->btn.left ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0); - buttonstate |= (rpt->btn.right ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0); - buttonstate |= (rpt->btn.up ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0); - buttonstate |= (rpt->btn.down ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0); - buttonstate |= (rpt->btn.home ? (UINT64_C(1) << RARCH_MENU_TOGGLE) : 0); - - return buttonstate; + if (rpt->btn.r3) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R3); + if (rpt->btn.l3) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L3); + if (rpt->btn.plus) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_START); + if ( rpt->btn.minus) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_SELECT); + if ( rpt->btn.zr) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R2); + if ( rpt->btn.zl) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L2); + if ( rpt->btn.r) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R); + if ( rpt->btn.l) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L); + if ( rpt->btn.x) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_X); + if ( rpt->btn.a) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_A); + if ( rpt->btn.b) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_B); + if ( rpt->btn.y) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_Y); + if ( rpt->btn.left) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_LEFT); + if ( rpt->btn.down) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_DOWN); + if ( rpt->btn.right) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_RIGHT); + if ( rpt->btn.up) + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_UP); + if ( rpt->btn.home) + BIT256_SET_PTR(state, RARCH_MENU_TOGGLE); } static int16_t hidpad_wiiupro_get_axis(void *data, unsigned axis) @@ -214,18 +230,18 @@ static void hidpad_wiiupro_packet_handler(void *data, calib_data->hatvalue_calib[1] = (packet[8] | (packet[8 + 1] << 8)); calib_data->hatvalue_calib[2] = (packet[6] | (packet[6 + 1] << 8)); calib_data->hatvalue_calib[3] = (packet[10] | (packet[10 + 1] << 8)); - + calib_data->calib_round++; } else { - device->data.hatvalue[0] = (packet[4] | (packet[4 + 1] << 8)) + device->data.hatvalue[0] = (packet[4] | (packet[4 + 1] << 8)) - calib_data->hatvalue_calib[0]; - device->data.hatvalue[1] = (packet[8] | (packet[8 + 1] << 8)) + device->data.hatvalue[1] = (packet[8] | (packet[8 + 1] << 8)) - calib_data->hatvalue_calib[1]; - device->data.hatvalue[2] = (packet[6] | (packet[6 + 1] << 8)) + device->data.hatvalue[2] = (packet[6] | (packet[6 + 1] << 8)) - calib_data->hatvalue_calib[2]; - device->data.hatvalue[3] = (packet[10] | (packet[10 + 1] << 8)) + device->data.hatvalue[3] = (packet[10] | (packet[10 + 1] << 8)) - calib_data->hatvalue_calib[3]; } } diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 0942505db2..90cb9cf06b 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -103,7 +103,7 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn, const char *name_match = strstr(pad_map[i].name, name); /* Never change, Nintendo. */ - if(pad_map[i].vid == 1406 && pad_map[i].pid == 816) + if(pad_map[i].vid == 1406 && pad_map[i].pid == 816) { if(!string_is_equal(pad_map[i].name, name)) continue; @@ -133,7 +133,7 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn, } } - /* We failed to find a matching pad, + /* We failed to find a matching pad, * set up one without an interface */ if (!s->connected) { @@ -173,11 +173,12 @@ void pad_connection_packet(joypad_connection_t *joyconn, uint32_t pad, joyconn->iface->packet_handler(joyconn->data, data, length); } -uint64_t pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad) +void pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad, retro_bits_t* state) { - if (!joyconn->iface) - return 0; - return joyconn->iface->get_buttons(joyconn->data); + if (joyconn->iface) + joyconn->iface->get_buttons(joyconn->data, state); + else + BIT256_CLEAR_ALL_PTR( state ); } int16_t pad_connection_get_axis(joypad_connection_t *joyconn, @@ -190,8 +191,8 @@ int16_t pad_connection_get_axis(joypad_connection_t *joyconn, bool pad_connection_has_interface(joypad_connection_t *joyconn, unsigned pad) { - if ( joyconn && pad < MAX_USERS - && joyconn[pad].connected + if ( joyconn && pad < MAX_USERS + && joyconn[pad].connected && joyconn[pad].iface) return true; return false; diff --git a/input/connect/joypad_connection.h b/input/connect/joypad_connection.h index c0d3669853..75b6dbb633 100644 --- a/input/connect/joypad_connection.h +++ b/input/connect/joypad_connection.h @@ -21,6 +21,7 @@ #include #include +#include typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size); @@ -38,7 +39,7 @@ typedef struct pad_connection_interface void (*packet_handler)(void* device, uint8_t *packet, uint16_t size); void (*set_rumble)(void* device, enum retro_rumble_effect effect, uint16_t strength); - uint64_t (*get_buttons)(void *data); + void (*get_buttons)(void *data, retro_bits_t *state); int16_t (*get_axis)(void *data, unsigned axis); const char* (*get_name)(void *data); } pad_connection_interface_t; @@ -69,8 +70,8 @@ void pad_connection_pad_deinit(joypad_connection_t *joyconn, void pad_connection_packet(joypad_connection_t *joyconn, uint32_t idx, uint8_t* data, uint32_t length); -uint64_t pad_connection_get_buttons(joypad_connection_t *joyconn, - unsigned idx); +void pad_connection_get_buttons(joypad_connection_t *joyconn, + unsigned idx, retro_bits_t* state); int16_t pad_connection_get_axis(joypad_connection_t *joyconn, unsigned idx, unsigned i); diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index f25477e372..2eb4884bce 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -150,7 +150,7 @@ static void *libandroid_handle; static bool android_input_lookup_name_prekitkat(char *buf, int *vendorId, int *productId, size_t size, int id) -{ +{ jobject name = NULL; jmethodID getName = NULL; jobject device = NULL; @@ -502,9 +502,9 @@ static void *android_input_init(const char *joypad_driver) android->pads_connected = 0; android->quick_tap_time = 0; android->joypad = input_joypad_init_driver(joypad_driver, android); - + input_keymaps_init_keyboard_lut(rarch_key_map_android); - + frontend_android_get_version_sdk(&sdk); RARCH_LOG("sdk version: %d\n", sdk); @@ -528,7 +528,7 @@ static void *android_input_init(const char *joypad_driver) static int android_check_quick_tap(android_input_t *android) { - /* Check if the touch screen has been been quick tapped + /* Check if the touch screen has been been quick tapped * and then not touched again for 200ms * If so then return true and deactivate quick tap timer */ retro_time_t now = cpu_features_get_time_usec(); @@ -604,7 +604,7 @@ static int16_t android_lightgun_device_state(android_input_t *android, unsigned static INLINE void android_mouse_calculate_deltas(android_input_t *android, AInputEvent *event,size_t motion_ptr) { - /* Adjust mouse speed based on ratio + /* Adjust mouse speed based on ratio * between core resolution and system resolution */ float x, y; float x_scale = 1; @@ -663,7 +663,7 @@ static INLINE int android_input_poll_event_type_motion( (source == AINPUT_SOURCE_MOUSE && action != AMOTION_EVENT_ACTION_DOWN); - /* If source is mouse then calculate button state + /* If source is mouse then calculate button state * and mouse deltas and don't process as touchscreen event */ if (source == AINPUT_SOURCE_MOUSE) { @@ -677,7 +677,7 @@ static INLINE int android_input_poll_event_type_motion( } else { - /* If getButtonState is not available + /* If getButtonState is not available * then treat all MotionEvent.ACTION_DOWN as left button presses */ if (action == AMOTION_EVENT_ACTION_DOWN) android->mouse_l = 1; @@ -694,7 +694,7 @@ static INLINE int android_input_poll_event_type_motion( { if(action == AMOTION_EVENT_ACTION_UP && ENABLE_TOUCH_SCREEN_MOUSE) { - /* If touchscreen was pressed for less than 200ms + /* If touchscreen was pressed for less than 200ms * then register time stamp of a quick tap */ if((AMotionEvent_getEventTime(event)-AMotionEvent_getDownTime(event))/1000000 < 200) android->quick_tap_time = AMotionEvent_getEventTime(event); @@ -713,14 +713,14 @@ static INLINE int android_input_poll_event_type_motion( if(action == AMOTION_EVENT_ACTION_DOWN && ENABLE_TOUCH_SCREEN_MOUSE) { - /* When touch screen is pressed, set mouse + /* When touch screen is pressed, set mouse * previous position to current position * before starting to calculate mouse movement deltas. */ android->mouse_x_prev = AMotionEvent_getX(event, motion_ptr); android->mouse_y_prev = AMotionEvent_getY(event, motion_ptr); - /* If another touch happened within 200ms after a quick tap - * then cancel the quick tap and register left mouse button + /* If another touch happened within 200ms after a quick tap + * then cancel the quick tap and register left mouse button * as being held down */ if((AMotionEvent_getEventTime(event) - android->quick_tap_time)/1000000 < 200) { @@ -759,7 +759,7 @@ static INLINE int android_input_poll_event_type_motion( } } - /* If more than one pointer detected + /* If more than one pointer detected * then count it as a mouse right click */ if (ENABLE_TOUCH_SCREEN_MOUSE) android->mouse_r = (android->pointer_count == 2); @@ -920,7 +920,7 @@ static void handle_hotplug(android_input_t *android, android->pads_connected, device_name, id, pad_id1, pad_id2); #endif /* remove the remote or virtual controller device if it is mapped */ - if (strstr(android->pad_states[0].name,"SHIELD Remote") || + if (strstr(android->pad_states[0].name,"SHIELD Remote") || strstr(android->pad_states[0].name,"SHIELD Virtual Controller")) { pad_id1 = -1; @@ -930,7 +930,7 @@ static void handle_hotplug(android_input_t *android, strlcpy(name_buf, device_name, sizeof(name_buf)); } - /* if the actual controller has not been mapped yet, + /* if the actual controller has not been mapped yet, * then configure Virtual device for now */ if (strstr(device_name, "Virtual") && android->pads_connected==0) strlcpy (name_buf, "SHIELD Virtual Controller", sizeof(name_buf)); @@ -940,7 +940,7 @@ static void handle_hotplug(android_input_t *android, /* apply the hack only for the first controller * store the id for later use */ - if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") + if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") && android->pads_connected==0) pad_id1 = id; else if (strstr(device_name, "Virtual") && pad_id1 != -1) @@ -969,7 +969,7 @@ static void handle_hotplug(android_input_t *android, strlcpy (name_buf, "NVIDIA SHIELD Portable", sizeof(name_buf)); } } - + else if(strstr(device_model, "SHIELD") && ( strstr(device_name, "Virtual") || strstr(device_name, "gpio") || strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03"))) @@ -1025,9 +1025,9 @@ static void handle_hotplug(android_input_t *android, * This device is composed of two hid devices * We make it look like one device */ - else if(strstr(device_model, "R800") && + else if(strstr(device_model, "R800") && ( - strstr(device_name, "keypad-game-zeus") || + strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus") ) ) @@ -1199,7 +1199,7 @@ static void android_input_poll_input(void *data) if (port < 0 && !is_keyboard_id(id)) handle_hotplug(android, android_app, &port, id, source); - + switch (type_event) { case AINPUT_EVENT_TYPE_MOTION: @@ -1267,28 +1267,28 @@ static void android_input_poll_memcpy(void *data) } } -static bool android_input_key_pressed(void *data, int key) -{ +static bool android_input_key_pressed(void *data, int key) +{ rarch_joypad_info_t joypad_info; - android_input_t *android = (android_input_t*)data; + android_input_t *android = (android_input_t*)data; const struct retro_keybind *keyptr = (const struct retro_keybind*) &input_config_binds[0][key]; - if( keyptr->valid + if( keyptr->valid && android_keyboard_port_input_pressed(input_config_binds[0], - key)) - return true; + key)) + return true; joypad_info.joy_idx = 0; joypad_info.auto_binds = input_autoconf_binds[0]; joypad_info.axis_threshold = *(input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD)); - if (keyptr->valid && + if (keyptr->valid && input_joypad_pressed(android->joypad, joypad_info, - 0, input_config_binds[0], key)) - return true; + 0, input_config_binds[0], key)) + return true; - return false; + return false; } /* Handle all events. If our activity is in pause state, @@ -1317,7 +1317,7 @@ static void android_input_poll(void *data) android_input_poll_main_cmd(); break; } - + if (android_app->destroyRequested != 0) { rarch_ctl(RARCH_CTL_SET_SHUTDOWN, NULL); diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 9b84770b8b..f14932ab23 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2013-2014 - Jason Fetters - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -17,14 +17,17 @@ #include #include +#include + #ifdef HAVE_CONFIG_H #include "../../config.h" #endif #include "../input_driver.h" - #include "../input_keymaps.h" + #include "cocoa_input.h" + #include "../../gfx/video_driver.h" #include "../../driver.h" @@ -36,13 +39,13 @@ float get_backing_scale_factor(void); int32_t cocoa_input_find_any_key(void) { cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); - + if (!apple) return 0; - + if (apple->joypad) apple->joypad->poll(); - + if (apple->sec_joypad) apple->sec_joypad->poll(); @@ -50,13 +53,13 @@ int32_t cocoa_input_find_any_key(void) } static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, - unsigned buttons, unsigned port) + retro_bits_t * state, unsigned port) { unsigned i; - if (buttons) - for (i = 0; i < 32; i++) - if (buttons & (1 << i)) + if (state) + for (i = 0; i < 256; i++) + if (BIT256_GET_PTR(state,i)) return i; return -1; } @@ -68,26 +71,32 @@ int32_t cocoa_input_find_any_button(uint32_t port) if (!apple) return -1; - + if (apple->joypad) { apple->joypad->poll(); if (apple->joypad->get_buttons) - ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->joypad->get_buttons(port), port); + { + retro_bits_t state; + apple->joypad->get_buttons(port,&state); + ret = cocoa_input_find_any_button_ret(apple, &state, port); + } } if (ret != -1) return ret; - + if (apple->sec_joypad) { apple->sec_joypad->poll(); if (apple->sec_joypad->get_buttons) { + retro_bits_t state; apple->sec_joypad->poll(); - ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->sec_joypad->get_buttons(port), port); + apple->sec_joypad->get_buttons(port,&state); + ret = cocoa_input_find_any_button_ret(apple, &state, port); } } @@ -101,17 +110,17 @@ int32_t cocoa_input_find_any_axis(uint32_t port) { int i; cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); - + if (apple && apple->joypad) apple->joypad->poll(); - + if (apple && apple->sec_joypad) apple->sec_joypad->poll(); for (i = 0; i < 6; i++) { int16_t value = apple->joypad ? apple->joypad->axis(port, i) : 0; - + if (abs(value) > 0x4000) return (value < 0) ? -(i + 1) : i + 1; @@ -130,15 +139,15 @@ static void *cocoa_input_init(const char *joypad_driver) cocoa_input_data_t *apple = (cocoa_input_data_t*)calloc(1, sizeof(*apple)); if (!apple) return NULL; - + input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid); apple->joypad = input_joypad_init_driver(joypad_driver, apple); - + #ifdef HAVE_MFI apple->sec_joypad = input_joypad_init_driver("mfi", apple); #endif - + return apple; } @@ -149,14 +158,14 @@ static void cocoa_input_poll(void *data) #ifndef IOS float backing_scale_factor = get_backing_scale_factor(); #endif - + if (!apple) return; for (i = 0; i < apple->touch_count; i++) { struct video_viewport vp; - + vp.x = 0; vp.y = 0; vp.width = 0; @@ -249,13 +258,13 @@ static int16_t cocoa_pointer_state(cocoa_input_data_t *apple, int16_t x, y; const cocoa_touch_data_t *touch = (const cocoa_touch_data_t *) &apple->touches[idx]; - + if (!touch) return 0; - + x = touch->fixed_x; y = touch->fixed_y; - + if (want_full) { x = touch->full_x; @@ -328,16 +337,16 @@ static void cocoa_input_free(void *data) { unsigned i; cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (!apple || !data) return; - + if (apple->joypad) apple->joypad->destroy(); - + if (apple->sec_joypad) apple->sec_joypad->destroy(); - + for (i = 0; i < MAX_KEYS; i++) apple_key_state[i] = 0; @@ -348,7 +357,7 @@ static bool cocoa_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->joypad) return input_joypad_set_rumble(apple->joypad, port, effect, strength); @@ -364,7 +373,7 @@ static uint64_t cocoa_input_get_capabilities(void *data) { (void)data; - return + return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_MOUSE) | (1 << RETRO_DEVICE_KEYBOARD) | @@ -382,7 +391,7 @@ static void cocoa_input_grab_mouse(void *data, bool state) static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->sec_joypad) return apple->sec_joypad; return NULL; @@ -391,7 +400,7 @@ static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->joypad) return apple->joypad; return NULL; diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index 33194837f5..62f21b4904 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2013-2014 - Jason Fetters - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 9871a9669d..359dc9f5eb 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -45,7 +45,7 @@ static void ctr_input_poll(void *data) ctr->joypad->poll(); } -static int16_t ctr_input_state(void *data, +static int16_t ctr_input_state(void *data, rarch_joypad_info_t joypad_info, const struct retro_keybind **binds, unsigned port, unsigned device, diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index f890444e46..6550bec50e 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -49,6 +49,7 @@ #include "../../gfx/video_driver.h" +#include "../../configuration.h" #include "../../verbosity.h" /* Keep track of which pad indexes are 360 controllers. @@ -267,6 +268,58 @@ static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) return di->state[sym] & 0x80; } +static bool dinput_mbutton_pressed(struct dinput_input *di, unsigned port, unsigned key) +{ + bool result; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return false; + } + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return di->mouse_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return di->mouse_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return di->mouse_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return di->mouse_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return di->mouse_b5; + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + result = di->mouse_wu; + di->mouse_wu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + result = di->mouse_wd; + di->mouse_wd = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + result = di->mouse_hwu; + di->mouse_hwu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + result = di->mouse_hwd; + di->mouse_hwd = false; + return result; + + } + + return false; +} + static bool dinput_is_pressed(struct dinput_input *di, rarch_joypad_info_t joypad_info, const struct retro_keybind *binds, @@ -276,8 +329,13 @@ static bool dinput_is_pressed(struct dinput_input *di, if (!di->blocked && (bind->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind->key)) return true; - if (binds && binds[id].valid && input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) - return true; + if (binds && binds[id].valid) + { + if (dinput_mbutton_pressed(di, port, bind->mbutton)) + return true; + if (input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) + return true; + } return false; } @@ -311,33 +369,83 @@ static bool dinput_meta_key_pressed(void *data, int key) return false; } -static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id) +static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned idx, unsigned id ) { - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return di->mouse_rel_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return di->mouse_rel_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return di->mouse_l; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return di->mouse_m; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return di->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return di->mouse_m && di->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return di->mouse_m && di->mouse_l; - } + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + int x = 0; + int y = 0; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + unsigned num = 0; - return 0; + struct pointer_status* check_pos = di->pointer_head.next; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + while ( check_pos && num < idx ) + { + num++; + check_pos = check_pos->next; + } + + if ( !check_pos && idx > 0 ) /* idx = 0 has mouse fallback. */ + return 0; + + x = di->mouse_x; + y = di->mouse_y; + + if ( check_pos ) + { + x = check_pos->pointer_x; + y = check_pos->pointer_y; + } + + if ( !( video_driver_translate_coord_viewport_wrap( + &vp, x, y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) + { + return 0; + } + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; } -static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id) +static int16_t dinput_mouse_state(struct dinput_input *di, unsigned port, unsigned id) { int16_t state = 0; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return 0; + } + switch (id) { case RETRO_DEVICE_ID_MOUSE_X: @@ -379,8 +487,18 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id) return 0; } -static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned id) +static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned port, unsigned id) { + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return 0; + } + switch (id) { case RETRO_DEVICE_ID_MOUSE_X: @@ -391,7 +509,7 @@ static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned id) break; } - return dinput_mouse_state(di, id); + return dinput_mouse_state(di, port, id); } static int16_t dinput_pointer_state(struct dinput_input *di, @@ -494,10 +612,10 @@ static int16_t dinput_input_state(void *data, return 0; case RETRO_DEVICE_MOUSE: - return dinput_mouse_state(di, id); + return dinput_mouse_state(di, port, id); case RARCH_DEVICE_MOUSE_SCREEN: - return dinput_mouse_state_screen(di, id); + return dinput_mouse_state_screen(di, port, id); case RETRO_DEVICE_POINTER: case RARCH_DEVICE_POINTER_SCREEN: @@ -505,7 +623,48 @@ static int16_t dinput_input_state(void *data, device == RARCH_DEVICE_POINTER_SCREEN); case RETRO_DEVICE_LIGHTGUN: - return dinput_lightgun_state(di, id); + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return dinput_lightgun_aiming_state( di, idx, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + return di->mouse_rel_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return di->mouse_rel_y; + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + + } + break; } return 0; @@ -693,7 +852,7 @@ static void dinput_free(void *data) if (di->mouse) IDirectInputDevice8_Release(di->mouse); - if (string_is_empty(di->joypad_driver_name)) + if (di->joypad_driver_name) free(di->joypad_driver_name); free(di); diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index b4daff900d..cecbc92643 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index eee4a70cd6..5c2b780e9a 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -113,7 +113,7 @@ static int16_t linuxraw_input_state(void *data, linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] ); if (!ret) - ret = input_joypad_pressed(linuxraw->joypad, + ret = input_joypad_pressed(linuxraw->joypad, joypad_info, port, binds[port], id); return ret; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/nullinput.c b/input/drivers/nullinput.c index 78498f88dc..edb3c93e3e 100644 --- a/input/drivers/nullinput.c +++ b/input/drivers/nullinput.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index b5e2037027..8edc841960 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -76,7 +76,7 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3, { CellMouseData mouse_state; cellMouseGetData(id, &mouse_state); - + if (!ps3->mice_connected) return 0; @@ -205,8 +205,8 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port, { case RETRO_SENSOR_ACCELEROMETER_ENABLE: cellPadGetInfo2(&pad_info); - if ((pad_info.device_capability[port] - & CELL_PAD_CAPABILITY_SENSOR_MODE) + if ((pad_info.device_capability[port] + & CELL_PAD_CAPABILITY_SENSOR_MODE) != CELL_PAD_CAPABILITY_SENSOR_MODE) return false; diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 9d2fde4d96..3506b7e029 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -71,7 +71,7 @@ static bool rwebinput_key_pressed_internal(void *data, int key) unsigned sym; bool ret; rwebinput_input_t *rwebinput = (rwebinput_input_t*)data; - + if (key >= RETROK_LAST) return false; @@ -95,7 +95,7 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, { const struct retro_keybind *bind = &binds[id]; int key = binds[id].key; - return bind->valid && (key < RETROK_LAST) + return bind->valid && (key < RETROK_LAST) && rwebinput_key_pressed_internal(rwebinput, key); } diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 5b462d55ff..5376f2b9ce 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2014-2015 - Higor Euripedes - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -96,7 +96,7 @@ static bool sdl_input_meta_key_pressed(void *data, int key) static int16_t sdl_joypad_device_state(sdl_input_t *sdl, rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, + const struct retro_keybind *binds, unsigned port, unsigned id, enum input_device_type *device) { if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key)) @@ -200,9 +200,9 @@ static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id) case RETRO_DEVICE_ID_LIGHTGUN_TURBO: return sdl->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_START: - return sdl->mouse_m && sdl->mouse_r; + return sdl->mouse_m && sdl->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return sdl->mouse_m && sdl->mouse_l; + return sdl->mouse_m && sdl->mouse_l; } return 0; diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 01600ecdea..a22ba8636d 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -14,6 +14,19 @@ * If not, see . */ +/* TODO/FIXME - set this once the kqueue codepath is implemented and working properly */ +#if 1 +#define HAVE_EPOLL +#else +#ifdef __linux__ +#define HAVE_EPOLL 1 +#endif + +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__) +#define HAVE_KQUEUE 1 +#endif +#endif + #include #include @@ -25,7 +38,11 @@ #include #include +#if defined(HAVE_EPOLL) #include +#elif defined(HAVE_KQUEUE) +#include +#endif #include #include @@ -117,7 +134,7 @@ struct udev_input const input_device_driver_t *joypad; - int epfd; + int fd; udev_input_device_t **devices; unsigned num_devices; @@ -450,7 +467,11 @@ static bool udev_input_add_device(udev_input_t *udev, { int fd; struct stat st; +#if defined(HAVE_EPOLL) struct epoll_event event; +#elif defined(HAVE_KQUEUE) + struct kevent event; +#endif struct input_absinfo absinfo; udev_input_device_t **tmp; udev_input_device_t *device = NULL; @@ -518,15 +539,24 @@ static bool udev_input_add_device(udev_input_t *udev, tmp[udev->num_devices++] = device; udev->devices = tmp; +#if defined(HAVE_EPOLL) event.events = EPOLLIN; event.data.ptr = device; /* Shouldn't happen, but just check it. */ - if (epoll_ctl(udev->epfd, EPOLL_CTL_ADD, fd, &event) < 0) + if (epoll_ctl(udev->fd, EPOLL_CTL_ADD, fd, &event) < 0) { RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n", fd, strerror(errno)); } +#elif defined(HAVE_KQUEUE) + EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, LISTENSOCKET); + if (kevent(udev->fd, &event, 1, NULL, 0, NULL) == -1) + { + RARCH_ERR("Failed to add FD (%d) to kqueue list (%s).\n", + fd, strerror(errno)); + } +#endif return true; @@ -639,7 +669,11 @@ static bool udev_input_poll_hotplug_available(struct udev_monitor *dev) static void udev_input_poll(void *data) { int i, ret; +#if defined(HAVE_EPOLL) struct epoll_event events[32]; +#elif defined(HAVE_KQUEUE) + struct kevent events[32]; +#endif udev_input_mouse_t *mouse = NULL; udev_input_t *udev = (udev_input_t*)data; @@ -666,15 +700,30 @@ static void udev_input_poll(void *data) while (udev->monitor && udev_input_poll_hotplug_available(udev->monitor)) udev_input_handle_hotplug(udev); - ret = epoll_wait(udev->epfd, events, ARRAY_SIZE(events), 0); +#if defined(HAVE_EPOLL) + ret = epoll_wait(udev->fd, events, ARRAY_SIZE(events), 0); +#elif defined(HAVE_KQUEUE) + { + struct timespec timeoutspec; + timeoutspec.tv_sec = timeout; + timeoutspec.tv_nsec = 0; + ret = kevent(udev->fd, NULL, 0, events, + ARRAY_SIZE(events), &timeoutspec); + } +#endif for (i = 0; i < ret; i++) { + /* TODO/FIXME - add HAVE_EPOLL/HAVE_KQUEUE codepaths here */ if (events[i].events & EPOLLIN) { int j, len; struct input_event input_events[32]; +#if defined(HAVE_EPOLL) udev_input_device_t *device = (udev_input_device_t*)events[i].data.ptr; +#elif defined(HAVE_KQUEUE) + udev_input_device_t *device = (udev_input_device_t*)events[i].udata; +#endif while ((len = read(device->fd, input_events, sizeof(input_events))) > 0) @@ -874,10 +923,10 @@ static void udev_input_free(void *data) if (udev->joypad) udev->joypad->destroy(); - if (udev->epfd >= 0) - close(udev->epfd); + if (udev->fd >= 0) + close(udev->fd); - udev->epfd = -1; + udev->fd = -1; for (i = 0; i < udev->num_devices; i++) { @@ -978,14 +1027,23 @@ static void *udev_input_init(const char *joypad_driver) udev->xkb_handling = string_is_equal(ctx_ident.ident, "kms"); #endif +#if defined(HAVE_EPOLL) fd = epoll_create(32); if (fd < 0) { - RARCH_ERR("Failed to create epoll FD.\n"); + RARCH_ERR("Failed to create poll file descriptor.\n"); goto error; } +#elif defined(HAVE_KQUEUE) + fd = kqueue(); + if (fd == -1) + { + RARCH_ERR("Failed to create poll file descriptor.\n"); + goto error; + } +#endif - udev->epfd = fd; + udev->fd = fd; if (!open_devices(udev, UDEV_INPUT_KEYBOARD, udev_handle_keyboard)) { diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index 21ff484568..6fab41d99f 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -87,9 +87,9 @@ static int16_t input_wl_lightgun_state(input_ctx_wayland_data_t *wl, unsigned id case RETRO_DEVICE_ID_LIGHTGUN_TURBO: return wl->mouse.right; case RETRO_DEVICE_ID_LIGHTGUN_START: - return wl->mouse.middle && wl->mouse.right; + return wl->mouse.middle && wl->mouse.right; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return wl->mouse.middle && wl->mouse.left; + return wl->mouse.middle && wl->mouse.left; } return 0; @@ -129,14 +129,14 @@ static int16_t input_wl_analog_pressed(input_ctx_wayland_data_t *wl, input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - if (binds - && binds[id_minus].valid + if (binds + && binds[id_minus].valid && (id_minus < RARCH_BIND_LIST_END) && BIT_GET(wl->key_state, rarch_keysym_lut[binds[id_minus].key]) ) pressed_minus = -0x7fff; - if (binds - && binds[id_plus].valid + if (binds + && binds[id_plus].valid && (id_plus < RARCH_BIND_LIST_END) && BIT_GET(wl->key_state, rarch_keysym_lut[binds[id_plus].key]) ) diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 9673947317..7bf5a752e0 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -105,7 +105,11 @@ static int16_t wiiu_pointer_device_state(wiiu_input_t* wiiu, unsigned id) switch (id) { case RETRO_DEVICE_ID_POINTER_PRESSED: - return (wiiu->joypad->get_buttons(0) & VPAD_BUTTON_TOUCH) ? 1 : 0; + { + retro_bits_t state; + wiiu->joypad->get_buttons(0, &state); + return BIT256_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; + } case RETRO_DEVICE_ID_POINTER_X: return wiiu->joypad->axis(0, 0xFFFF0004UL); case RETRO_DEVICE_ID_POINTER_Y: diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index cd844e838e..2b15c53c1b 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -1,717 +1,857 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include - -#include "../input_driver.h" -#include "../input_keymaps.h" - -#include "../../configuration.h" -#include "../../gfx/video_driver.h" -#include "../../verbosity.h" - -typedef struct -{ - uint8_t keys[256]; -} winraw_keyboard_t; - -typedef struct -{ - HANDLE hnd; - LONG x, y, dlt_x, dlt_y; - LONG whl_u, whl_d; - bool btn_l, btn_m, btn_r, btn_b4, btn_b5; -} winraw_mouse_t; - -typedef struct -{ - bool kbd_mapp_block; - bool mouse_grab; - winraw_keyboard_t keyboard; - HWND window; - winraw_mouse_t *mice; - const input_device_driver_t *joypad; -} winraw_input_t; - -static winraw_keyboard_t *g_keyboard = NULL; -static winraw_mouse_t *g_mice = NULL; -static unsigned g_mouse_cnt = 0; -static bool g_mouse_xy_mapping_ready = false; -static double g_view_abs_ratio_x = 0.0; -static double g_view_abs_ratio_y = 0.0; - -static HWND winraw_create_window(WNDPROC wnd_proc) -{ - HWND wnd; - WNDCLASSA wc = {0}; - - wc.hInstance = GetModuleHandleA(NULL); - - if (!wc.hInstance) - { - RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wc.lpfnWndProc = wnd_proc; - wc.lpszClassName = "winraw-input"; - if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - { - RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, NULL, NULL, NULL); - if (!wnd) - { - RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); - goto error; - } - - return wnd; - -error: - UnregisterClassA(wc.lpszClassName, NULL); - return NULL; -} - -static void winraw_destroy_window(HWND wnd) -{ - BOOL r; - - if (!wnd) - return; - - r = DestroyWindow(wnd); - - if (!r) - { - RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); - } - - r = UnregisterClassA("winraw-input", NULL); - - if (!r) - { - RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); - } -} - -static bool winraw_set_keyboard_input(HWND window) -{ - RAWINPUTDEVICE rid; - BOOL r; - - rid.dwFlags = window ? 0 : RIDEV_REMOVE; - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x06; /* keyboard */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) -{ - UINT r; - unsigned i; - char name[256]; - UINT name_size = sizeof(name); - - for (i = 0; i < mouse_cnt; ++i) - { - r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); - if (r == (UINT)-1 || r == 0) - name[0] = '\0'; - RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); - } -} - -static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) -{ - UINT i; - POINT crs_pos; - winraw_mouse_t *mice_r = NULL; - unsigned mouse_cnt_r = 0; - RAWINPUTDEVICELIST *devs = NULL; - UINT dev_cnt = 0; - UINT r = GetRawInputDeviceList( - NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - - if (r == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); - if (!devs) - goto error; - - dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - if (dev_cnt == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - for (i = 0; i < dev_cnt; ++i) - mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; - - if (mouse_cnt_r) - { - mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); - if (!mice_r) - goto error; - - if (!GetCursorPos(&crs_pos)) - goto error; - - for (i = 0; i < mouse_cnt_r; ++i) - { - mice_r[i].x = crs_pos.x; - mice_r[i].y = crs_pos.y; - } - } - - /* count is already checked, so this is safe */ - for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) - { - if (devs[i].dwType == RIM_TYPEMOUSE) - mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; - } - - winraw_log_mice_info(mice_r, mouse_cnt_r); - - *mice = mice_r; - *mouse_cnt = mouse_cnt_r; - - return true; - -error: - free(devs); - free(mice_r); - *mice = NULL; - *mouse_cnt = 0; - return false; -} - -static bool winraw_set_mouse_input(HWND window, bool grab) -{ - RAWINPUTDEVICE rid; - BOOL r; - - if (window) - rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; - else - rid.dwFlags = RIDEV_REMOVE; - - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x02; /* mouse */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static int16_t winraw_mouse_state(winraw_input_t *wr, - unsigned port, bool abs, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_MOUSE_X: - return abs ? mouse->x : mouse->dlt_x; - case RETRO_DEVICE_ID_MOUSE_Y: - return abs ? mouse->y : mouse->dlt_y; - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4 ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5 ? 1 : 0; - } - - return 0; -} - -static int16_t winraw_joypad_state(winraw_input_t *wr, - rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned id) -{ - const struct retro_keybind *bind = &binds[id]; - unsigned key = rarch_keysym_lut[(enum retro_key)bind->key]; - - if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && wr->keyboard.keys[key]) - return 1; - - return input_joypad_pressed(wr->joypad, joypad_info, port, binds, id); -} - -static void winraw_init_mouse_xy_mapping() -{ - struct video_viewport viewport; - int center_x; - int center_y; - unsigned i; - - if (video_driver_get_viewport_info(&viewport)) - { - center_x = viewport.x + viewport.width / 2; - center_y = viewport.y + viewport.height / 2; - - for (i = 0; i < g_mouse_cnt; ++i) - { - g_mice[i].x = center_x; - g_mice[i].y = center_y; - } - - g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; - g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; - - g_mouse_xy_mapping_ready = true; - } -} - -static int16_t winraw_lightgun_state(winraw_input_t *wr, - unsigned port, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return mouse->dlt_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return mouse->dlt_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return (mouse->btn_m && mouse->btn_r) ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return mouse->btn_m && mouse->btn_l ? 1 : 0; - } - - return 0; -} - -static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) -{ - POINT crs_pos; - - if (state->usFlags & MOUSE_MOVE_ABSOLUTE) - { - if (g_mouse_xy_mapping_ready) - { - state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); - state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); - mouse->x = state->lLastX; - mouse->y = state->lLastY; - } - else - winraw_init_mouse_xy_mapping(); - } - else if (state->lLastX || state->lLastY) - { - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); - - if (!GetCursorPos(&crs_pos)) - { - RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); - } - else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) - { - RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); - } - else - { - mouse->x = crs_pos.x; - mouse->y = crs_pos.y; - } - } - - if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) - mouse->btn_l = true; - else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) - mouse->btn_l = false; - - if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) - mouse->btn_m = true; - else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) - mouse->btn_m = false; - - if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) - mouse->btn_r = true; - else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) - mouse->btn_r = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) - mouse->btn_b4 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) - mouse->btn_b4 = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) - mouse->btn_b5 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) - mouse->btn_b5 = false; - - if (state->usButtonFlags & RI_MOUSE_WHEEL) - { - if ((SHORT)state->usButtonData > 0) - InterlockedExchange(&mouse->whl_u, 1); - else if ((SHORT)state->usButtonData < 0) - InterlockedExchange(&mouse->whl_d, 1); - } -} - -static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) -{ - static uint8_t data[1024]; - UINT r; - unsigned i; - RAWINPUT *ri = (RAWINPUT*)data; - UINT size = sizeof(data); - - if (msg != WM_INPUT) - return DefWindowProcA(wnd, msg, wpar, lpar); - - /* app is in the background */ - if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) - goto end; - - r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, - data, &size, sizeof(RAWINPUTHEADER)); - if (r == (UINT)-1) - { - RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", - GetLastError()); - goto end; - } - - if (ri->header.dwType == RIM_TYPEKEYBOARD) - { - if (ri->data.keyboard.Message == WM_KEYDOWN) - g_keyboard->keys[ri->data.keyboard.VKey] = 1; - else if (ri->data.keyboard.Message == WM_KEYUP) - g_keyboard->keys[ri->data.keyboard.VKey] = 0; - } - else if (ri->header.dwType == RIM_TYPEMOUSE) - { - for (i = 0; i < g_mouse_cnt; ++i) - { - if (g_mice[i].hnd == ri->header.hDevice) - { - winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); - break; - } - } - } - -end: - DefWindowProcA(wnd, msg, wpar, lpar); - return 0; -} - -static void *winraw_init(const char *joypad_driver) -{ - bool r; - winraw_input_t *wr = (winraw_input_t *) - calloc(1, sizeof(winraw_input_t)); - g_keyboard = (winraw_keyboard_t*) - calloc(1, sizeof(winraw_keyboard_t)); - - if (!wr || !g_keyboard) - goto error; - - RARCH_LOG("[WINRAW]: Initializing input driver... \n"); - - input_keymaps_init_keyboard_lut(rarch_key_map_winraw); - - wr->window = winraw_create_window(winraw_callback); - if (!wr->window) - goto error; - - r = winraw_init_devices(&g_mice, &g_mouse_cnt); - if (!r) - goto error; - - if (!g_mouse_cnt) - { - RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); - } - else - { - wr->mice = (winraw_mouse_t*) - malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); - if (!wr->mice) - goto error; - - memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); - } - - r = winraw_set_keyboard_input(wr->window); - if (!r) - goto error; - - r = winraw_set_mouse_input(wr->window, false); - if (!r) - goto error; - - wr->joypad = input_joypad_init_driver(joypad_driver, wr); - - return wr; - -error: - if (wr && wr->window) - { - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - } - free(g_keyboard); - free(g_mice); - if (wr) - free(wr->mice); - free(wr); - return NULL; -} - -static void winraw_poll(void *d) -{ - unsigned i; - winraw_input_t *wr = (winraw_input_t*)d; - - memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); - - /* following keys are not handled by windows raw input api */ - wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - wr->mice[i].x = g_mice[i].x; - wr->mice[i].y = g_mice[i].y; - wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); - wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); - wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); - wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); - wr->mice[i].btn_l = g_mice[i].btn_l; - wr->mice[i].btn_m = g_mice[i].btn_m; - wr->mice[i].btn_r = g_mice[i].btn_r; - wr->mice[i].btn_b4 = g_mice[i].btn_b4; - wr->mice[i].btn_b5 = g_mice[i].btn_b5; - } - - if (wr->joypad) - wr->joypad->poll(); -} - -static int16_t winraw_input_state(void *d, - rarch_joypad_info_t joypad_info, - const struct retro_keybind **binds, - unsigned port, unsigned device, unsigned index, unsigned id) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - switch (device) - { - case RETRO_DEVICE_KEYBOARD: - if (id < RETROK_LAST) - { - unsigned key = rarch_keysym_lut[(enum retro_key)id]; - return wr->keyboard.keys[key]; - } - break; - case RETRO_DEVICE_MOUSE: - return winraw_mouse_state(wr, port, false, id); - case RARCH_DEVICE_MOUSE_SCREEN: - return winraw_mouse_state(wr, port, true, id); - case RETRO_DEVICE_JOYPAD: - return winraw_joypad_state(wr, joypad_info, binds[port], port, id); - case RETRO_DEVICE_ANALOG: - if (binds[port]) - return input_joypad_analog(wr->joypad, joypad_info, - port, index, id, binds[port]); - break; - case RETRO_DEVICE_LIGHTGUN: - return winraw_lightgun_state(wr, port, id); - } - - return 0; -} - -static bool winraw_meta_key_pressed(void *u1, int u2) -{ - return false; -} - -static void winraw_free(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - if (wr->joypad) - wr->joypad->destroy(); - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - free(g_mice); - free(g_keyboard); - free(wr->mice); - free(wr); - - g_mouse_xy_mapping_ready = false; -} - -static uint64_t winraw_get_capabilities(void *u) -{ - return (1 << RETRO_DEVICE_KEYBOARD) | - (1 << RETRO_DEVICE_MOUSE) | - (1 << RETRO_DEVICE_JOYPAD) | - (1 << RETRO_DEVICE_ANALOG) | - (1 << RETRO_DEVICE_LIGHTGUN); -} - -static void winraw_grab_mouse(void *d, bool grab) -{ - bool r = false; - winraw_input_t *wr = (winraw_input_t*)d; - - if (grab == wr->mouse_grab) - return; - - r = winraw_set_mouse_input(wr->window, grab); - if (!r) - return; - - wr->mouse_grab = grab; -} - -static bool winraw_set_rumble(void *d, unsigned port, - enum retro_rumble_effect effect, uint16_t strength) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return input_joypad_set_rumble(wr->joypad, port, effect, strength); -} - -static const input_device_driver_t *winraw_get_joypad_driver(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->joypad; -} - -static bool winraw_keyboard_mapping_is_blocked(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->kbd_mapp_block; -} - -static void winraw_keyboard_mapping_set_block(void *d, bool block) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - wr->kbd_mapp_block = block; -} - -input_driver_t input_winraw = { - winraw_init, - winraw_poll, - winraw_input_state, - winraw_meta_key_pressed, - winraw_free, - NULL, - NULL, - winraw_get_capabilities, - "raw", - winraw_grab_mouse, - NULL, - winraw_set_rumble, - winraw_get_joypad_driver, - NULL, - winraw_keyboard_mapping_is_blocked, - winraw_keyboard_mapping_set_block, -}; +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include "../input_driver.h" +#include "../input_keymaps.h" + +#include "../../configuration.h" +#include "../../gfx/video_driver.h" +#include "../../verbosity.h" + +typedef struct +{ + uint8_t keys[256]; +} winraw_keyboard_t; + +typedef struct +{ + HANDLE hnd; + LONG x, y, dlt_x, dlt_y; + LONG whl_u, whl_d; + bool btn_l, btn_m, btn_r, btn_b4, btn_b5; +} winraw_mouse_t; + +typedef struct +{ + bool kbd_mapp_block; + bool mouse_grab; + winraw_keyboard_t keyboard; + HWND window; + winraw_mouse_t *mice; + const input_device_driver_t *joypad; +} winraw_input_t; + +static winraw_keyboard_t *g_keyboard = NULL; +static winraw_mouse_t *g_mice = NULL; +static unsigned g_mouse_cnt = 0; +static bool g_mouse_xy_mapping_ready = false; +static double g_view_abs_ratio_x = 0.0; +static double g_view_abs_ratio_y = 0.0; + +static HWND winraw_create_window(WNDPROC wnd_proc) +{ + HWND wnd; + WNDCLASSA wc = {0}; + + wc.hInstance = GetModuleHandleA(NULL); + + if (!wc.hInstance) + { + RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wc.lpfnWndProc = wnd_proc; + wc.lpszClassName = "winraw-input"; + if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + { + RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, + HWND_MESSAGE, NULL, NULL, NULL); + if (!wnd) + { + RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); + goto error; + } + + return wnd; + +error: + UnregisterClassA(wc.lpszClassName, NULL); + return NULL; +} + +static void winraw_destroy_window(HWND wnd) +{ + BOOL r; + + if (!wnd) + return; + + r = DestroyWindow(wnd); + + if (!r) + { + RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); + } + + r = UnregisterClassA("winraw-input", NULL); + + if (!r) + { + RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); + } +} + +static bool winraw_set_keyboard_input(HWND window) +{ + RAWINPUTDEVICE rid; + BOOL r; + + rid.dwFlags = window ? 0 : RIDEV_REMOVE; + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x06; /* keyboard */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) +{ + UINT r; + unsigned i; + char name[256]; + UINT name_size = sizeof(name); + + for (i = 0; i < mouse_cnt; ++i) + { + r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); + if (r == (UINT)-1 || r == 0) + name[0] = '\0'; + RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); + } +} + +static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) +{ + UINT i; + POINT crs_pos; + winraw_mouse_t *mice_r = NULL; + unsigned mouse_cnt_r = 0; + RAWINPUTDEVICELIST *devs = NULL; + UINT dev_cnt = 0; + UINT r = GetRawInputDeviceList( + NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + + if (r == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); + if (!devs) + goto error; + + dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + if (dev_cnt == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + for (i = 0; i < dev_cnt; ++i) + mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; + + if (mouse_cnt_r) + { + mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); + if (!mice_r) + goto error; + + if (!GetCursorPos(&crs_pos)) + goto error; + + for (i = 0; i < mouse_cnt_r; ++i) + { + mice_r[i].x = crs_pos.x; + mice_r[i].y = crs_pos.y; + } + } + + /* count is already checked, so this is safe */ + for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) + { + if (devs[i].dwType == RIM_TYPEMOUSE) + mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; + } + + winraw_log_mice_info(mice_r, mouse_cnt_r); + + *mice = mice_r; + *mouse_cnt = mouse_cnt_r; + + return true; + +error: + free(devs); + free(mice_r); + *mice = NULL; + *mouse_cnt = 0; + return false; +} + +static bool winraw_set_mouse_input(HWND window, bool grab) +{ + RAWINPUTDEVICE rid; + BOOL r; + + if (window) + rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; + else + rid.dwFlags = RIDEV_REMOVE; + + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x02; /* mouse */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + if ( !( video_driver_translate_coord_viewport_wrap( + &vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) + { + return 0; + } + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; +} + +static int16_t winraw_mouse_state(winraw_input_t *wr, + unsigned port, bool abs, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + return abs ? mouse->x : mouse->dlt_x; + case RETRO_DEVICE_ID_MOUSE_Y: + return abs ? mouse->y : mouse->dlt_y; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4 ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5 ? 1 : 0; + } + + return 0; +} + +static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key) +{ + unsigned k = rarch_keysym_lut[(enum retro_key)key]; + return wr->keyboard.keys[k]; +} + +static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) +{ + unsigned i; + winraw_mouse_t *mouse = NULL; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d; + } + + return false; +} + +static bool winraw_is_pressed(winraw_input_t *wr, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + + if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) + return true; + if (binds && binds[id].valid) + { + if (winraw_mbutton_pressed(wr, port, bind->mbutton)) + return true; + if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id)) + return true; + } + + return false; +} + +static void winraw_init_mouse_xy_mapping() +{ + struct video_viewport viewport; + int center_x; + int center_y; + unsigned i; + + if (video_driver_get_viewport_info(&viewport)) + { + center_x = viewport.x + viewport.width / 2; + center_y = viewport.y + viewport.height / 2; + + for (i = 0; i < g_mouse_cnt; ++i) + { + g_mice[i].x = center_x; + g_mice[i].y = center_y; + } + + g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; + g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; + + g_mouse_xy_mapping_ready = true; + } +} + +static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_LIGHTGUN_X: + return mouse->dlt_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return mouse->dlt_y; + } + + return 0; +} + +static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) +{ + POINT crs_pos; + + if (state->usFlags & MOUSE_MOVE_ABSOLUTE) + { + if (g_mouse_xy_mapping_ready) + { + state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); + state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); + mouse->x = state->lLastX; + mouse->y = state->lLastY; + } + else + winraw_init_mouse_xy_mapping(); + } + else if (state->lLastX || state->lLastY) + { + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); + + if (!GetCursorPos(&crs_pos)) + { + RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); + } + else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) + { + RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); + } + else + { + mouse->x = crs_pos.x; + mouse->y = crs_pos.y; + } + } + + if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) + mouse->btn_l = true; + else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) + mouse->btn_l = false; + + if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) + mouse->btn_m = true; + else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) + mouse->btn_m = false; + + if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) + mouse->btn_r = true; + else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) + mouse->btn_r = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) + mouse->btn_b4 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) + mouse->btn_b4 = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) + mouse->btn_b5 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) + mouse->btn_b5 = false; + + if (state->usButtonFlags & RI_MOUSE_WHEEL) + { + if ((SHORT)state->usButtonData > 0) + InterlockedExchange(&mouse->whl_u, 1); + else if ((SHORT)state->usButtonData < 0) + InterlockedExchange(&mouse->whl_d, 1); + } +} + +static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) +{ + static uint8_t data[1024]; + UINT r; + unsigned i; + RAWINPUT *ri = (RAWINPUT*)data; + UINT size = sizeof(data); + + if (msg != WM_INPUT) + return DefWindowProcA(wnd, msg, wpar, lpar); + + /* app is in the background */ + if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) + goto end; + + r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, + data, &size, sizeof(RAWINPUTHEADER)); + if (r == (UINT)-1) + { + RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", + GetLastError()); + goto end; + } + + if (ri->header.dwType == RIM_TYPEKEYBOARD) + { + if (ri->data.keyboard.Message == WM_KEYDOWN) + g_keyboard->keys[ri->data.keyboard.VKey] = 1; + else if (ri->data.keyboard.Message == WM_KEYUP) + g_keyboard->keys[ri->data.keyboard.VKey] = 0; + } + else if (ri->header.dwType == RIM_TYPEMOUSE) + { + for (i = 0; i < g_mouse_cnt; ++i) + { + if (g_mice[i].hnd == ri->header.hDevice) + { + winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); + break; + } + } + } + +end: + DefWindowProcA(wnd, msg, wpar, lpar); + return 0; +} + +static void *winraw_init(const char *joypad_driver) +{ + bool r; + winraw_input_t *wr = (winraw_input_t *) + calloc(1, sizeof(winraw_input_t)); + g_keyboard = (winraw_keyboard_t*) + calloc(1, sizeof(winraw_keyboard_t)); + + if (!wr || !g_keyboard) + goto error; + + RARCH_LOG("[WINRAW]: Initializing input driver... \n"); + + input_keymaps_init_keyboard_lut(rarch_key_map_winraw); + + wr->window = winraw_create_window(winraw_callback); + if (!wr->window) + goto error; + + r = winraw_init_devices(&g_mice, &g_mouse_cnt); + if (!r) + goto error; + + if (!g_mouse_cnt) + { + RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); + } + else + { + wr->mice = (winraw_mouse_t*) + malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); + if (!wr->mice) + goto error; + + memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); + } + + r = winraw_set_keyboard_input(wr->window); + if (!r) + goto error; + + r = winraw_set_mouse_input(wr->window, false); + if (!r) + goto error; + + wr->joypad = input_joypad_init_driver(joypad_driver, wr); + + return wr; + +error: + if (wr && wr->window) + { + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + } + free(g_keyboard); + free(g_mice); + if (wr) + free(wr->mice); + free(wr); + return NULL; +} + +static void winraw_poll(void *d) +{ + unsigned i; + winraw_input_t *wr = (winraw_input_t*)d; + + memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); + + /* following keys are not handled by windows raw input api */ + wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + wr->mice[i].x = g_mice[i].x; + wr->mice[i].y = g_mice[i].y; + wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); + wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); + wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); + wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); + wr->mice[i].btn_l = g_mice[i].btn_l; + wr->mice[i].btn_m = g_mice[i].btn_m; + wr->mice[i].btn_r = g_mice[i].btn_r; + wr->mice[i].btn_b4 = g_mice[i].btn_b4; + wr->mice[i].btn_b5 = g_mice[i].btn_b5; + } + + if (wr->joypad) + wr->joypad->poll(); +} + +static int16_t winraw_input_state(void *d, + rarch_joypad_info_t joypad_info, + const struct retro_keybind **binds, + unsigned port, unsigned device, unsigned index, unsigned id) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + switch (device) + { + case RETRO_DEVICE_JOYPAD: + if (id < RARCH_BIND_LIST_END) + return winraw_is_pressed(wr, joypad_info, binds[port], port, id); + break; + case RETRO_DEVICE_KEYBOARD: + return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id); + case RETRO_DEVICE_MOUSE: + return winraw_mouse_state(wr, port, false, id); + case RARCH_DEVICE_MOUSE_SCREEN: + return winraw_mouse_state(wr, port, true, id); + case RETRO_DEVICE_ANALOG: + if (binds[port]) + return input_joypad_analog(wr->joypad, joypad_info, + port, index, id, binds[port]); + break; + case RETRO_DEVICE_LIGHTGUN: + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return winraw_lightgun_aiming_state( wr, port, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return winraw_deprecated_lightgun_state(wr, port, id); + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + } + break; + } + + return 0; +} + +static bool winraw_meta_key_pressed(void *u1, int u2) +{ + return false; +} + +static void winraw_free(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + if (wr->joypad) + wr->joypad->destroy(); + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + free(g_mice); + free(g_keyboard); + free(wr->mice); + free(wr); + + g_mouse_xy_mapping_ready = false; +} + +static uint64_t winraw_get_capabilities(void *u) +{ + return (1 << RETRO_DEVICE_KEYBOARD) | + (1 << RETRO_DEVICE_MOUSE) | + (1 << RETRO_DEVICE_JOYPAD) | + (1 << RETRO_DEVICE_ANALOG) | + (1 << RETRO_DEVICE_LIGHTGUN); +} + +static void winraw_grab_mouse(void *d, bool grab) +{ + bool r = false; + winraw_input_t *wr = (winraw_input_t*)d; + + if (grab == wr->mouse_grab) + return; + + r = winraw_set_mouse_input(wr->window, grab); + if (!r) + return; + + wr->mouse_grab = grab; +} + +static bool winraw_set_rumble(void *d, unsigned port, + enum retro_rumble_effect effect, uint16_t strength) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return input_joypad_set_rumble(wr->joypad, port, effect, strength); +} + +static const input_device_driver_t *winraw_get_joypad_driver(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->joypad; +} + +static bool winraw_keyboard_mapping_is_blocked(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->kbd_mapp_block; +} + +static void winraw_keyboard_mapping_set_block(void *d, bool block) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + wr->kbd_mapp_block = block; +} + +input_driver_t input_winraw = { + winraw_init, + winraw_poll, + winraw_input_state, + winraw_meta_key_pressed, + winraw_free, + NULL, + NULL, + winraw_get_capabilities, + "raw", + winraw_grab_mouse, + NULL, + winraw_set_rumble, + winraw_get_joypad_driver, + NULL, + winraw_keyboard_mapping_is_blocked, + winraw_keyboard_mapping_set_block, +}; diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 40842f0719..9e357870bf 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -30,6 +30,7 @@ #include "../../gfx/video_driver.h" #include "../common/input_x11_common.h" +#include "../../configuration.h" #include "../../verbosity.h" typedef struct x11_input @@ -72,6 +73,78 @@ static void *x_input_init(const char *joypad_driver) return x11; } +static bool x_keyboard_pressed(x11_input_t *x11, unsigned key) +{ + int keycode = XKeysymToKeycode(x11->display, rarch_keysym_lut[(enum retro_key)key]); + return x11->state[keycode >> 3] & (1 << (keycode & 7)); +} + +static bool x_mbutton_pressed(x11_input_t *x11, unsigned port, unsigned key) +{ + bool result; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return x11->mouse_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return x11->mouse_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return x11->mouse_m; +/* case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return x11->mouse_b4;*/ +/* case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return x11->mouse_b5;*/ + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return x_mouse_state_wheel( key ); + +/* case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + result = x11->mouse_hwu; + x11->mouse_hwu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + result = x11->mouse_hwd; + x11->mouse_hwd = false; + return result; +*/ + } + + return false; +} + +static bool x_is_pressed(x11_input_t *x11, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + + if ( (bind->key < RETROK_LAST) && x_keyboard_pressed(x11, bind->key) ) + return true; + + if (binds && binds[id].valid) + { + if (x_mbutton_pressed(x11, port, bind->mbutton)) + return true; + if (input_joypad_pressed(x11->joypad, joypad_info, port, binds, id)) + return true; + } + + return false; +} + static int16_t x_pressed_analog(x11_input_t *x11, const struct retro_keybind *binds, unsigned idx, unsigned id) { @@ -83,7 +156,7 @@ static int16_t x_pressed_analog(x11_input_t *x11, int id_plus_key = 0; unsigned sym = 0; int keycode = 0; - + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); id_minus_key = binds[id_minus].key; @@ -91,15 +164,15 @@ static int16_t x_pressed_analog(x11_input_t *x11, sym = rarch_keysym_lut[(enum retro_key)id_minus_key]; keycode = XKeysymToKeycode(x11->display, sym); - if ( binds[id_minus].valid + if ( binds[id_minus].valid && (id_minus_key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7)))) pressed_minus = -0x7fff; sym = rarch_keysym_lut[(enum retro_key)id_plus_key]; keycode = XKeysymToKeycode(x11->display, sym); - if ( binds[id_plus].valid - && (id_plus_key < RETROK_LAST) + if ( binds[id_plus].valid + && (id_plus_key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7)))) pressed_plus = 0x7fff; @@ -111,6 +184,44 @@ static bool x_input_meta_key_pressed(void *data, int key) return false; } +static int16_t x_lightgun_aiming_state( x11_input_t *x11, unsigned idx, unsigned id ) +{ + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + if (!(video_driver_translate_coord_viewport_wrap(&vp, x11->mouse_x, x11->mouse_y, + &res_x, &res_y, &res_screen_x, &res_screen_y))) + return 0; + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; +} + static int16_t x_mouse_state(x11_input_t *x11, unsigned id) { switch (id) @@ -193,29 +304,6 @@ static int16_t x_pointer_state(x11_input_t *x11, return 0; } -static int16_t x_lightgun_state(x11_input_t *x11, unsigned id) -{ - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return x11->mouse_x - x11->mouse_last_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return x11->mouse_y - x11->mouse_last_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return x11->mouse_l; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return x11->mouse_m; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return x11->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return x11->mouse_m && x11->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return x11->mouse_m && x11->mouse_l; - } - - return 0; -} - static int16_t x_input_state(void *data, rarch_joypad_info_t joypad_info, const struct retro_keybind **binds, unsigned port, @@ -227,23 +315,11 @@ static int16_t x_input_state(void *data, switch (device) { case RETRO_DEVICE_JOYPAD: - { - int keycode = XKeysymToKeycode(x11->display, - rarch_keysym_lut[(enum retro_key)binds[port][id].key]); - ret = (binds[port][id].key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7))); - if (!ret) - ret = input_joypad_pressed(x11->joypad, - joypad_info, port, binds[port], id); - } - return ret; + if (id < RARCH_BIND_LIST_END) + return x_is_pressed(x11, joypad_info, binds[port], port, id); + break; case RETRO_DEVICE_KEYBOARD: - if (id < RETROK_LAST) - { - int keycode = XKeysymToKeycode(x11->display, - rarch_keysym_lut[(enum retro_key)id]); - ret = x11->state[keycode >> 3] & (1 << (keycode & 7)); - } - return ret; + return (id < RETROK_LAST) && x_keyboard_pressed(x11, id); case RETRO_DEVICE_ANALOG: ret = x_pressed_analog(x11, binds[port], idx, id); if (!ret && binds[port]) @@ -263,7 +339,48 @@ static int16_t x_input_state(void *data, device == RARCH_DEVICE_POINTER_SCREEN); break; case RETRO_DEVICE_LIGHTGUN: - return x_lightgun_state(x11, id); + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return x_lightgun_aiming_state( x11, idx, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + return x11->mouse_x - x11->mouse_last_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return x11->mouse_y - x11->mouse_last_y; + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + + } + break; } return 0; @@ -304,9 +421,9 @@ static void x_input_poll_mouse(x11_input_t *x11) { x11->mouse_x = win_x; x11->mouse_y = win_y; - x11->mouse_l = mask & Button1Mask; - x11->mouse_m = mask & Button2Mask; - x11->mouse_r = mask & Button3Mask; + x11->mouse_l = mask & Button1Mask; + x11->mouse_m = mask & Button2Mask; + x11->mouse_r = mask & Button3Mask; /* Somewhat hacky, but seem to do the job. */ if (x11->grab_mouse && video_driver_cb_has_focus()) diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index d6c45a6d8a..a603d0ae62 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -106,7 +106,7 @@ static uint64_t xdk_input_get_capabilities(void *data) return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG); } -/* FIXME - are we sure about treating low frequency motor as the +/* FIXME - are we sure about treating low frequency motor as the * "strong" motor? Does it apply for Xbox too? */ static bool xdk_input_set_rumble(void *data, unsigned port, @@ -119,9 +119,9 @@ static bool xdk_input_set_rumble(void *data, unsigned port, #endif xdk_input_t *xdk = (xdk_input_t*)data; bool val = false; - + (void)xdk; - + #if 0 #if defined(_XBOX360) if (effect == RETRO_RUMBLE_STRONG) diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index e1d1142bb9..f1c933a68e 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 02e4d0d5fb..9946e1f6dc 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -27,6 +27,7 @@ #endif #include +#include #include #ifdef HAVE_DYNAMIC #include @@ -44,13 +45,13 @@ #define LINK_KEY_LEN 16 /* The device name type. */ #define DEVICE_NAME_LEN 248 - + /* Type definitions. */ typedef uint16_t hci_con_handle_t; typedef uint8_t bd_addr_t[BD_ADDR_LEN]; typedef uint8_t link_key_t[LINK_KEY_LEN]; typedef uint8_t device_name_t[DEVICE_NAME_LEN+1]; - + /* Packet handler. */ typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); @@ -62,7 +63,7 @@ typedef enum HCI_POWER_ON, HCI_POWER_SLEEP } HCI_POWER_MODE; - + /* State of BTstack */ typedef enum { @@ -73,14 +74,14 @@ typedef enum HCI_STATE_SLEEPING, HCI_STATE_FALLING_ASLEEP } HCI_STATE; - + typedef enum { RUN_LOOP_POSIX = 1, RUN_LOOP_COCOA, RUN_LOOP_EMBEDDED } RUN_LOOP_TYPE; - + /* compact HCI Command packet description */ typedef struct { @@ -93,7 +94,7 @@ typedef struct linked_item struct linked_item *next; /* <-- next element in list, or NULL */ void *user_data; /* <-- pointer to struct base */ } linked_item_t; - + typedef linked_item_t *linked_list_t; typedef struct data_source @@ -108,7 +109,7 @@ typedef struct data_source typedef struct timer { - linked_item_t item; + linked_item_t item; /* Next timeout. */ struct timeval timeout; #ifdef HAVE_TICK @@ -167,7 +168,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; /* extension for client/server communication */ #define DAEMON_EVENT_PACKET 0x05 - + /* L2CAP data */ #define L2CAP_DATA_PACKET 0x06 @@ -179,7 +180,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; /* Security Manager protocol data */ #define SM_DATA_PACKET 0x09 - + /* debug log messages */ #define LOG_MESSAGE_PACKET 0xFC @@ -228,7 +229,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE 0x03 #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04 #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST 0x05 - + /* last used HCI_EVENT in 2.1 is 0x3d */ /* events 0x50-0x5f are used internally */ @@ -257,7 +258,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define BTSTACK_EVENT_DISCOVERABLE_ENABLED 0x66 /* L2CAP EVENTS */ - + /* data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16) */ #define L2CAP_EVENT_CHANNEL_OPENED 0x70 @@ -277,31 +278,31 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define L2CAP_EVENT_SERVICE_REGISTERED 0x75 /* RFCOMM EVENTS */ - + // data: event(8), len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16) #define RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE 0x80 - + // data: event(8), len(8), rfcomm_cid(16) #define RFCOMM_EVENT_CHANNEL_CLOSED 0x81 - + // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) #define RFCOMM_EVENT_INCOMING_CONNECTION 0x82 - + // data: event (8), len(8), rfcommid (16), ... #define RFCOMM_EVENT_REMOTE_LINE_STATUS 0x83 - + /* data: event(8), len(8), rfcomm_cid(16), credits(8) */ #define RFCOMM_EVENT_CREDITS 0x84 - + /* data: event(8), len(8), status (8), rfcomm server channel id (8) */ #define RFCOMM_EVENT_SERVICE_REGISTERED 0x85 - + /* data: event(8), len(8), status (8), rfcomm server channel id (8) */ #define RFCOMM_EVENT_PERSISTENT_CHANNEL 0x86 - + /* data: event(8), len(8), status(8), service_record_handle(32) */ #define SDP_SERVICE_REGISTERED 0x90 - + /* last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors */ #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED 0x50 @@ -329,14 +330,14 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define L2CAP_CONFIG_RESPONSE_RESULT_REJECTED 0x68 #define L2CAP_CONFIG_RESPONSE_RESULT_UNKNOWN_OPTIONS 0x69 #define L2CAP_SERVICE_ALREADY_REGISTERED 0x6a - + #define RFCOMM_MULTIPLEXER_STOPPED 0x70 #define RFCOMM_CHANNEL_ALREADY_REGISTERED 0x71 #define RFCOMM_NO_OUTGOING_CREDITS 0x72 #define SDP_HANDLE_ALREADY_REGISTERED 0x80 - -/* Default INQ Mode + +/* Default INQ Mode * 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC) **/ #define HCI_INQUIRY_LAP 0x9E8B33L @@ -350,7 +351,7 @@ extern const hci_cmd_t btstack_get_system_bluetooth_enabled; extern const hci_cmd_t btstack_set_system_bluetooth_enabled; extern const hci_cmd_t btstack_set_discoverable; extern const hci_cmd_t btstack_set_bluetooth_enabled; /* only used by btstack config */ - + extern const hci_cmd_t hci_accept_connection_request; extern const hci_cmd_t hci_authentication_requested; extern const hci_cmd_t hci_change_connection_link_key; @@ -425,7 +426,7 @@ extern const hci_cmd_t hci_le_set_scan_response_data; extern const hci_cmd_t hci_le_start_encryption; extern const hci_cmd_t hci_le_test_end; extern const hci_cmd_t hci_le_transmitter_test; - + extern const hci_cmd_t l2cap_accept_connection; extern const hci_cmd_t l2cap_create_channel; extern const hci_cmd_t l2cap_create_channel_mtu; @@ -487,12 +488,12 @@ void run_loop_set_timer_handler(timer_source_t *ts, void (*process)(timer_source_t *_ts)); /* Add timer source. */ -void run_loop_add_timer(timer_source_t *timer); +void run_loop_add_timer(timer_source_t *timer); /* Remove timer source. */ int run_loop_remove_timer(timer_source_t *timer); -/* Init must be called before any other run_loop call. +/* Init must be called before any other run_loop call. * Use RUN_LOOP_EMBEDDED for embedded devices. */ void run_loop_init(RUN_LOOP_TYPE type); @@ -507,7 +508,7 @@ void run_loop_add_data_source(data_source_t *dataSource); /* Remove data source. */ int run_loop_remove_data_source(data_source_t *dataSource); -/* Execute configured run loop. +/* Execute configured run loop. * This function does not return. */ void run_loop_execute(void); @@ -525,7 +526,7 @@ uint32_t embedded_get_ticks(void); /* Connection handle type. */ - + /* helper for BT little endian format. */ #define READ_BT_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8)) #define READ_BT_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16)) @@ -573,18 +574,18 @@ void hexdump(void *data, int size); void printUUID(uint8_t *uuid); /* Deprecated - please use more convenient bd_addr_to_str. */ -void print_bd_addr( bd_addr_t addr); +void print_bd_addr(bd_addr_t addr); char * bd_addr_to_str(bd_addr_t addr); int sscan_bd_addr(uint8_t * addr_string, bd_addr_t addr); - + uint8_t crc8_check(uint8_t *data, uint16_t len, uint8_t check_sum); uint8_t crc8_calc(uint8_t *data, uint16_t len); /* btstack.h */ - + /* Default TCP port for BTstack daemon. */ #define BTSTACK_PORT 13333 @@ -594,13 +595,13 @@ uint8_t crc8_calc(uint8_t *data, uint16_t len); /* Optional * - * If called before bt_open, TCP socket is used + * If called before bt_open, TCP socket is used * instead of local UNIX socket. * - * note: Address is not copied and must be + * note: Address is not copied and must be * valid during bt_open. */ -void bt_use_tcp(const char * address, uint16_t port); +void bt_use_tcp(const char * address, uint16_t port); /* Init BTstack library. */ int bt_open(void); @@ -611,7 +612,7 @@ int bt_close(void); /* Send HCI cmd packet. */ int bt_send_cmd(const hci_cmd_t *cmd, ...); -/* Register packet handler -- channel only valid +/* Register packet handler -- channel only valid for L2CAP and RFCOMM packets. */ btstack_packet_handler_t bt_register_packet_handler( @@ -783,7 +784,7 @@ static void btpad_queue_process_cmd(struct btpad_queue_command *cmd) { if (!cmd) return; - + if (cmd->command == btstack_set_power_mode_ptr) bt_send_cmd_ptr( cmd->command, @@ -808,7 +809,7 @@ static void btpad_queue_process_cmd(struct btpad_queue_command *cmd) cmd->hci_remote_name_request.page_scan_repetition_mode, cmd->hci_remote_name_request.reserved, cmd->hci_remote_name_request.clock_offset); - + else if (cmd->command == hci_pin_code_request_reply_ptr) bt_send_cmd_ptr( cmd->command, @@ -889,7 +890,7 @@ static void btpad_queue_hci_remote_name_request( cmd->command = hci_remote_name_request_ptr; memcpy(cmd->hci_remote_name_request.bd_addr, bd_addr, sizeof(bd_addr_t)); - cmd->hci_remote_name_request.page_scan_repetition_mode = + cmd->hci_remote_name_request.page_scan_repetition_mode = page_scan_repetition_mode; cmd->hci_remote_name_request.reserved = reserved; cmd->hci_remote_name_request.clock_offset = clock_offset; @@ -1024,7 +1025,7 @@ static void btpad_packet_handler(uint8_t packet_type, if (!connection || connection->state != BTPAD_CONNECTED) continue; - if ( connection->channels[0] == channel + if ( connection->channels[0] == channel || connection->channels[1] == channel) pad_connection_packet(&slots[connection->slot], connection->slot, packet, size); } @@ -1036,14 +1037,14 @@ static void btpad_packet_handler(uint8_t packet_type, RARCH_LOG("[BTstack]: HCI State %d.\n", packet[2]); switch (packet[2]) - { + { case HCI_STATE_WORKING: btpad_queue_reset(); btpad_queue_hci_read_bd_addr(cmd); /* TODO: Where did I get 672 for MTU? */ - bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); + bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_INTERRUPT, 672); btpad_queue_hci_inquiry(cmd, HCI_INQUIRY_LAP, 3, 1); @@ -1052,7 +1053,7 @@ static void btpad_packet_handler(uint8_t packet_type, case HCI_STATE_HALTING: btpad_close_all_connections(); - break; + break; } break; @@ -1100,7 +1101,7 @@ static void btpad_packet_handler(uint8_t packet_type, break; case HCI_EVENT_INQUIRY_COMPLETE: - /* This must be turned off during gameplay + /* This must be turned off during gameplay * as it causes a ton of lag. */ inquiry_running = !inquiry_off; @@ -1363,26 +1364,29 @@ static const char *btstack_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t btstack_hid_joypad_get_buttons(void *data, unsigned port) +static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - btstack_hid_t *hid = (btstack_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + btstack_hid_t *hid = (btstack_hid_t*)data; + if (hid) + pad_connection_get_buttons(&hid->slots[port], port, state); + else + BIT256_CLEAR_ALL_PTR(state); } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = btstack_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; + btstack_hid_joypad_get_buttons(data, port, &buttons); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (BIT256_GET(buttons, joykey) != 0); + + return false; } static bool btstack_hid_joypad_rumble(void *data, unsigned pad, diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index e63f3cf7ad..8f4e0cb71b 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -108,21 +108,23 @@ static const char *iohidmanager_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t iohidmanager_hid_joypad_get_buttons(void *data, unsigned port) +static void iohidmanager_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + if (hid) + return pad_connection_get_buttons(&hid->slots[port], port, state); + else + BIT256_CLEAR_ALL_PTR(state); } static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = - iohidmanager_hid_joypad_get_buttons(data, port); - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - unsigned hat_dir = GET_HAT_DIR(joykey); + retro_bits_t buttons; + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + unsigned hat_dir = GET_HAT_DIR(joykey); + + iohidmanager_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (hat_dir) @@ -148,8 +150,9 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0) + return (BIT256_GET(buttons, joykey) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); + return false; } diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 357504e46b..c03004b395 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -16,7 +16,11 @@ #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include @@ -38,7 +42,12 @@ typedef struct libusb_hid libusb_context *ctx; joypad_connection_t *slots; sthread_t *poll_thread; + int can_hotplug; +#if defined(__FreeBSD__) && LIBUSB_API_VERSION <= 0x01000102 + libusb_hotplug_callback_handle hp; +#else int hp; /* libusb_hotplug_callback_handle is just int */ +#endif int quit; } libusb_hid_t; @@ -85,13 +94,13 @@ static void adapter_thread(void *data) int size = 0; slock_lock(adapter->send_control_lock); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, &send_command_size, sizeof(send_command_size)); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, @@ -157,7 +166,13 @@ static void libusb_get_description(struct libusb_device *device, unsigned i, k; struct libusb_config_descriptor *config; - libusb_get_config_descriptor(device, 0, &config); + int desc_ret = libusb_get_config_descriptor(device, 0, &config); + + if (desc_ret != 0) + { + RARCH_ERR("Error %d getting libusb config descriptor\n", desc_ret); + return; + } for (i = 0; i < (int)config->bNumInterfaces; i++) { @@ -165,7 +180,7 @@ static void libusb_get_description(struct libusb_device *device, for(j = 0; j < inter->num_altsetting; j++) { - const struct libusb_interface_descriptor *interdesc = + const struct libusb_interface_descriptor *interdesc = &inter->altsetting[j]; #if 0 @@ -176,13 +191,13 @@ static void libusb_get_description(struct libusb_device *device, for(k = 0; k < (int)interdesc->bNumEndpoints; k++) { - const struct libusb_endpoint_descriptor *epdesc = + const struct libusb_endpoint_descriptor *epdesc = &interdesc->endpoint[k]; - bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_INTERRUPT; - bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT; - bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN; if (is_int) @@ -200,11 +215,12 @@ static void libusb_get_description(struct libusb_device *device, } } } + goto ret; } } - ret: +ret: libusb_free_config_descriptor(config); } @@ -299,7 +315,8 @@ static int add_adapter(void *data, struct libusb_device *dev) if (!pad_connection_has_interface(hid->slots, adapter->slot)) { - RARCH_ERR(" Interface not found (%s).\n", adapter->name); + RARCH_ERR("Interface not found (%s) (VID/PID: %04x:%04x).\n", + adapter->name, desc.idVendor, desc.idProduct); goto error; } @@ -426,18 +443,23 @@ static const char *libusb_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t libusb_hid_joypad_get_buttons(void *data, unsigned port) +static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { libusb_hid_t *hid = (libusb_hid_t*)data; if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + { + pad_connection_get_buttons(&hid->slots[port], port, state); + return; + } + + BIT256_CLEAR_ALL_PTR(state); } static bool libusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = libusb_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; + libusb_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (GET_HAT_DIR(joykey)) @@ -445,7 +467,7 @@ static bool libusb_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); + return (BIT256_GET(buttons, joykey) != 0); return false; } @@ -502,9 +524,11 @@ static void libusb_hid_free(void *data) sthread_join(hid->poll_thread); } - pad_connection_destroy(hid->slots); + if (hid->slots) + pad_connection_destroy(hid->slots); - libusb_hotplug_deregister_callback(hid->ctx, hid->hp); + if (hid->can_hotplug) + libusb_hotplug_deregister_callback(hid->ctx, hid->hp); libusb_exit(hid->ctx); free(hid); @@ -537,8 +561,22 @@ static void *libusb_hid_init(void) if (ret < 0) goto error; - if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) - goto error; +#if LIBUSB_API_VERSION <= 0x01000102 + /* API is too old, so libusb_has_capability function does not exist. + * Since we can't be sure, we assume for now there might be hot-plugging + * capability and continue on until we're told otherwise. + */ + hid->can_hotplug = 1; +#else + /* Ask libusb if it supports hotplug and store the result. + * Note: On Windows this will probably be false, see: + * https://github.com/libusb/libusb/issues/86 + */ + if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) + hid->can_hotplug = 1; + else + hid->can_hotplug = 0; +#endif hid->slots = pad_connection_init(MAX_USERS); @@ -559,22 +597,29 @@ static void *libusb_hid_init(void) if (count > 0) libusb_free_device_list(devices, 1); - ret = libusb_hotplug_register_callback( - hid->ctx, - (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | - LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), - (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, - LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, - libusb_hid_hotplug_callback, - hid, - &hid->hp); - - if (ret != LIBUSB_SUCCESS) + if (hid->can_hotplug) { - RARCH_ERR("Error creating a hotplug callback.\n"); - goto error; + ret = libusb_hotplug_register_callback( + hid->ctx, + (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | + LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), + (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + libusb_hid_hotplug_callback, + hid, + &hid->hp); + + if (ret != LIBUSB_SUCCESS) + { + /* Creating the hotplug callback has failed. We assume libusb + * is still okay to continue and just update our knowledge of + * the situation accordingly. + */ + RARCH_WARN("[libusb] Failed to create a hotplug callback.\n"); + hid->can_hotplug = 0; + } } hid->poll_thread = sthread_create(poll_thread, hid); diff --git a/input/drivers_hid/null_hid.c b/input/drivers_hid/null_hid.c index 10be0ba7c8..ce657d8b90 100644 --- a/input/drivers_hid/null_hid.c +++ b/input/drivers_hid/null_hid.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -38,12 +38,12 @@ static const char *null_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t null_hid_joypad_get_buttons(void *data, unsigned port) +static void null_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { (void)data; (void)port; - return 0; + BIT256_CLEAR_ALL_PTR(state); } static bool null_hid_joypad_button(void *data, unsigned port, uint16_t joykey) diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 8c022a12b8..e50657c64d 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -64,7 +64,7 @@ struct wiiusb_adapter int32_t slot; uint8_t *data; - uint8_t send_control_type; + uint8_t send_control_type; uint8_t *send_control_buffer; uint32_t send_control_size; }; @@ -113,10 +113,10 @@ static int32_t wiiusb_hid_read_cb(int32_t size, void *data) pad_connection_packet(&hid->connections[adapter->slot], adapter->slot, adapter->data-1, size+1); - if (adapter) + if (adapter) adapter->busy = false; - return size; + return size; } static void wiiusb_hid_device_send_control(void *data, @@ -398,7 +398,7 @@ static void wiiusb_hid_scan_for_devices(wiiusb_hid_t *hid) for (i = 0; i < count; i++) { - /* first check the device is not already in our list */ + /* first check the device is not already in our list */ if (!wiiusb_hid_new_device(hid, dev_entries[i].device_id)) continue; @@ -461,11 +461,11 @@ static int wiiusb_hid_change_cb(int result, void *usrdata) return -1; /* As it's not coming from the removal callback - then we detected a new device being inserted */ - if (!hid->removal_cb) - hid->device_detected = true; - else - hid->removal_cb = false; + then we detected a new device being inserted */ + if (!hid->removal_cb) + hid->device_detected = true; + else + hid->removal_cb = false; /* Re-submit the change alert */ USB_DeviceChangeNotifyAsync(USB_CLASS_HID, wiiusb_hid_change_cb, usrdata); @@ -478,33 +478,38 @@ static bool wiiusb_hid_joypad_query(void *data, unsigned pad) return pad < MAX_USERS; } -static uint64_t wiiusb_hid_joypad_get_buttons(void *data, unsigned port) +static void wiiusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - wiiusb_hid_t *hid = (wiiusb_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->connections[port], port); - return 0; + wiiusb_hid_t *hid = (wiiusb_hid_t*)data; + if (hid) + { + pad_connection_get_buttons(&hid->connections[port], port, state); + return; + } + BIT256_CLEAR_ALL_PTR(state); } static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = wiiusb_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + wiiusb_hid_joypad_get_buttons(data, port, &buttons); - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (BIT256_GET(buttons, joykey) != 0); + + return false; } static bool wiiusb_hid_joypad_rumble(void *data, unsigned pad, enum retro_rumble_effect effect, uint16_t strength) { - wiiusb_hid_t *hid = (wiiusb_hid_t*)data; + wiiusb_hid_t *hid = (wiiusb_hid_t*)data; if (!hid) return false; diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index aa1b3efcbe..711b88493d 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -31,7 +31,7 @@ #define MAX_PADS 1 #endif -static uint64_t pad_state; +static uint32_t pad_state; static int16_t analog_state[1][2][2]; extern uint64_t lifecycle_state; @@ -67,12 +67,17 @@ static bool ctr_joypad_button(unsigned port_num, uint16_t key) if (port_num >= MAX_PADS) return false; - return (pad_state & (UINT64_C(1) << key)); + return (pad_state & (1 << key)); } -static uint64_t ctr_joypad_get_buttons(unsigned port_num) +static void ctr_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state; + if ( port_num < MAX_PADS ) + { + BITS_COPY16_PTR( state, pad_state ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -140,20 +145,20 @@ static void ctr_joypad_poll(void) hidTouchRead(&state_tmp_touch); pad_state = 0; - pad_state |= (state_tmp & KEY_DLEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - pad_state |= (state_tmp & KEY_DDOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; - pad_state |= (state_tmp & KEY_DRIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - pad_state |= (state_tmp & KEY_DUP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - pad_state |= (state_tmp & KEY_START) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0; - pad_state |= (state_tmp & KEY_SELECT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0; - pad_state |= (state_tmp & KEY_X) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0; - pad_state |= (state_tmp & KEY_Y) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0; - pad_state |= (state_tmp & KEY_B) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0; - pad_state |= (state_tmp & KEY_A) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0; - pad_state |= (state_tmp & KEY_R) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0; - pad_state |= (state_tmp & KEY_L) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0; - pad_state |= (state_tmp & KEY_ZR) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0; - pad_state |= (state_tmp & KEY_ZL) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0; + pad_state |= (state_tmp & KEY_DLEFT) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + pad_state |= (state_tmp & KEY_DDOWN) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + pad_state |= (state_tmp & KEY_DRIGHT) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + pad_state |= (state_tmp & KEY_DUP) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + pad_state |= (state_tmp & KEY_START) ? (1 << RETRO_DEVICE_ID_JOYPAD_START) : 0; + pad_state |= (state_tmp & KEY_SELECT) ? (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0; + pad_state |= (state_tmp & KEY_X) ? (1 << RETRO_DEVICE_ID_JOYPAD_X) : 0; + pad_state |= (state_tmp & KEY_Y) ? (1 << RETRO_DEVICE_ID_JOYPAD_Y) : 0; + pad_state |= (state_tmp & KEY_B) ? (1 << RETRO_DEVICE_ID_JOYPAD_B) : 0; + pad_state |= (state_tmp & KEY_A) ? (1 << RETRO_DEVICE_ID_JOYPAD_A) : 0; + pad_state |= (state_tmp & KEY_R) ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0; + pad_state |= (state_tmp & KEY_L) ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0; + pad_state |= (state_tmp & KEY_ZR) ? (1 << RETRO_DEVICE_ID_JOYPAD_R2) : 0; + pad_state |= (state_tmp & KEY_ZL) ? (1 << RETRO_DEVICE_ID_JOYPAD_L2) : 0; analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = ctr_joypad_fix_range(state_tmp_left_analog.dx); analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -ctr_joypad_fix_range(state_tmp_left_analog.dy); diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 4793d83256..c92d9179ad 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -34,6 +34,7 @@ #include "../input_driver.h" #include "../input_keymaps.h" #include "../../verbosity.h" +#include "dinput_joypad.h" struct dinput_joypad { @@ -63,6 +64,32 @@ extern bool g_xinput_block_pads; extern int g_xinput_pad_indexes[MAX_USERS]; extern LPDIRECTINPUT8 g_dinput_ctx; +bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(g_xinput_pad_indexes); i++) + { + if (index == g_xinput_pad_indexes[i]) + { + RARCH_LOG("[DINPUT]: Found XInput pad at index %d (DINPUT index %d)\n", index, i); + + if (vid) + *vid = g_pads[i].vid; + + if (pid) + *pid = g_pads[i].pid; + + if (dinput_index) + *dinput_index = i; + + return true; + } + } + + return false; +} + static void dinput_joypad_destroy(void) { unsigned i; @@ -74,7 +101,7 @@ static void dinput_joypad_destroy(void) IDirectInputDevice8_Unacquire(g_pads[i].joypad); IDirectInputDevice8_Release(g_pads[i].joypad); } - + free(g_pads[i].joy_name); g_pads[i].joy_name = NULL; free(g_pads[i].joy_friendly_name); @@ -114,11 +141,11 @@ static bool guid_is_xinput_device(const GUID* product_guid) unsigned i, num_raw_devs = 0; PRAWINPUTDEVICELIST raw_devs = NULL; - /* Check for well known XInput device GUIDs, + /* Check for well known XInput device GUIDs, * thereby removing the need for the IG_ check. - * This lets us skip RAWINPUT for popular devices. + * This lets us skip RAWINPUT for popular devices. * - * Also, we need to do this for the Valve Streaming Gamepad + * Also, we need to do this for the Valve Streaming Gamepad * because it's virtualized and doesn't show up in the device list. */ for (i = 0; i < ARRAY_SIZE(common_xinput_guids); ++i) diff --git a/input/drivers_joypad/dinput_joypad.h b/input/drivers_joypad/dinput_joypad.h new file mode 100644 index 0000000000..12d491f3b9 --- /dev/null +++ b/input/drivers_joypad/dinput_joypad.h @@ -0,0 +1,31 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __DINPUT_JOYPAD_H +#define __DINPUT_JOYPAD_H + +#include +#include +#include + +RETRO_BEGIN_DECLS + +bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index); + +RETRO_END_DECLS + +#endif diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 348884e833..392cb602a9 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -162,9 +162,14 @@ static bool gx_joypad_button(unsigned port, uint16_t key) return (pad_state[port] & (UINT64_C(1) << key)); } -static uint64_t gx_joypad_get_buttons(unsigned port) +static void gx_joypad_get_buttons(unsigned port, retro_bits_t *state) { - return pad_state[port]; + if (port < MAX_PADS) + { + BITS_COPY16_PTR( state, pad_state[port] ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t gx_joypad_axis(unsigned port, uint32_t joyaxis) @@ -501,8 +506,8 @@ static void gx_joypad_destroy(void) int i; for (i = 0; i < MAX_PADS; i++) { - /* Commenting this out fixes the Wii - * remote not reconnecting after + /* Commenting this out fixes the Wii + * remote not reconnecting after * core load, exit, etc. */ WPAD_Flush(i); WPADDisconnect(i); diff --git a/input/drivers_joypad/hid_joypad.c b/input/drivers_joypad/hid_joypad.c index 94eaaef7b6..203a272922 100644 --- a/input/drivers_joypad/hid_joypad.c +++ b/input/drivers_joypad/hid_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -44,7 +44,7 @@ static void hid_joypad_free(void) if (generic_hid->free) generic_hid->free((void*)hid_driver_get_data()); - + generic_hid = NULL; } @@ -55,11 +55,12 @@ static bool hid_joypad_button(unsigned port, uint16_t joykey) return false; } -static uint64_t hid_joypad_get_buttons(unsigned port) +static void hid_joypad_get_buttons(unsigned port, retro_bits_t *state) { if (generic_hid && generic_hid->get_buttons) - return generic_hid->get_buttons((void*)hid_driver_get_data(), port); - return 0; + generic_hid->get_buttons((void*)hid_driver_get_data(), port, state); + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index 4178ffe188..4d852f406b 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -41,7 +41,7 @@ struct linuxraw_joypad { int fd; - uint64_t buttons; + uint32_t buttons; int16_t axes[NUM_AXES]; char *ident; @@ -55,7 +55,7 @@ static bool linuxraw_hotplug = false; static void linuxraw_poll_pad(struct linuxraw_joypad *pad) { struct js_event event; - + while (read(pad->fd, &event, sizeof(event)) == (ssize_t)sizeof(event)) { unsigned type = event.type & ~JS_EVENT_INIT; @@ -66,9 +66,9 @@ static void linuxraw_poll_pad(struct linuxraw_joypad *pad) if (event.number < NUM_BUTTONS) { if (event.value) - BIT64_SET(pad->buttons, event.number); + BIT32_SET(pad->buttons, event.number); else - BIT64_CLEAR(pad->buttons, event.number); + BIT32_CLEAR(pad->buttons, event.number); } break; @@ -200,7 +200,7 @@ retry: input_config_set_device_name(idx, NULL); } } - /* Sometimes, device will be created before + /* Sometimes, device will be created before * access to it is established. */ else if (event->mask & (IN_CREATE | IN_ATTRIB)) { @@ -210,7 +210,7 @@ retry: snprintf(path, sizeof(path), "/dev/input/%s", event->name); - if ( !string_is_empty(linuxraw_pads[idx].ident) + if ( !string_is_empty(linuxraw_pads[idx].ident) && linuxraw_joypad_init_pad(path, &linuxraw_pads[idx])) { if (!input_autoconfigure_connect( @@ -251,7 +251,7 @@ static bool linuxraw_joypad_init(void *data) pad->fd = -1; pad->ident = input_device_names[i]; - + snprintf(path, sizeof(path), "/dev/input/js%u", i); if (!input_autoconfigure_connect( @@ -323,15 +323,18 @@ static bool linuxraw_joypad_button(unsigned port, uint16_t joykey) const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*) &linuxraw_pads[port]; - return joykey < NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); + return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); } -static uint64_t linuxraw_joypad_get_buttons(unsigned port) +static void linuxraw_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*) - &linuxraw_pads[port]; - - return pad->buttons; + const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; + if (pad) + { + BITS_COPY16_PTR(state, pad->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index ef6f025746..94f56b2147 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -221,9 +221,9 @@ static bool apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey) return false; } -static uint64_t apple_gamecontroller_joypad_get_buttons(unsigned port) +static void apple_gamecontroller_joypad_get_buttons(unsigned port, retro_bits_t *state) { - return mfi_buttons[port]; + BITS_COPY16_PTR(state, mfi_buttons[port]); } static int16_t apple_gamecontroller_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/null_joypad.c b/input/drivers_joypad/null_joypad.c index c3377a45d6..058d01d5b3 100644 --- a/input/drivers_joypad/null_joypad.c +++ b/input/drivers_joypad/null_joypad.c @@ -37,9 +37,9 @@ static bool null_joypad_button(unsigned port_num, uint16_t joykey) return false; } -static uint64_t null_joypad_get_buttons(unsigned port_num) +static void null_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return 0; + BIT256_CLEAR_ALL_PTR(state); } static int16_t null_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index c3bc156db3..e236a36fc5 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -40,7 +40,7 @@ struct parport_joypad { int fd; - uint64_t buttons; + uint32_t buttons; bool button_enable[PARPORT_NUM_BUTTONS]; char saved_data; char saved_control; @@ -97,22 +97,22 @@ static void parport_poll_pad(struct parport_joypad *pad) for (i = 0; i < 8; i++) { if (!(data & UINT8_C(1 << i)) && pad->button_enable[i]) - BIT64_SET(pad->buttons, i); + BIT32_SET(pad->buttons, i); else - BIT64_CLEAR(pad->buttons, i); + BIT32_CLEAR(pad->buttons, i); } for (i = 3; i < 8; i++) { if (!(status & UINT8_C(1 << i)) && pad->button_enable[i + 5]) - BIT64_SET(pad->buttons, i + 5); + BIT32_SET(pad->buttons, i + 5); else - BIT64_CLEAR(pad->buttons, i + 5); + BIT32_CLEAR(pad->buttons, i + 5); } - if (BIT64_GET(pad->buttons, 12) && pad->button_enable[12]) - BIT64_CLEAR(pad->buttons, 12); + if (BIT32_GET(pad->buttons, 12) && pad->button_enable[12]) + BIT32_CLEAR(pad->buttons, 12); else - BIT64_SET(pad->buttons, 12); + BIT32_SET(pad->buttons, 12); } static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) @@ -268,7 +268,7 @@ static bool parport_joypad_init(void *data) for (j = 0; j < PARPORT_NUM_BUTTONS; j++) { - if (!(BIT64_GET(pad->buttons, j))) + if (!(BIT32_GET(pad->buttons, j))) { pad->button_enable[j] = true; found_enabled_button = true; @@ -337,13 +337,18 @@ static void parport_joypad_destroy(void) static bool parport_joypad_button(unsigned port, uint16_t joykey) { const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; - return joykey < PARPORT_NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); + return joykey < PARPORT_NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); } -static uint64_t parport_joypad_get_buttons(unsigned port) +static void parport_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; - return pad->buttons; + const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; + if (pad) + { + BITS_COPY16_PTR(state, pad->buttons); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index 35fc7dadc9..a85a23fcf9 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -68,9 +68,14 @@ static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) return pad_state[port_num] & (UINT64_C(1) << joykey); } -static uint64_t ps3_joypad_get_buttons(unsigned port_num) +static void ps3_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if (port_num < MAX_PADS) + { + BITS_COPY16_PTR( state, pad_state[port_num] ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -142,7 +147,7 @@ static void ps3_joypad_poll(void) ps3_joypad_autodetect_add(port); } } - + if (pads_connected[port] == 0) continue; diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 9e569eeca2..d9cb4dd65a 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -124,9 +124,14 @@ static bool psp_joypad_button(unsigned port_num, uint16_t key) return (pad_state[port_num] & (UINT64_C(1) << key)); } -static uint64_t psp_joypad_get_buttons(unsigned port_num) +static void psp_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if (port_num < PSP_MAX_PADS) + { + BITS_COPY16_PTR( state, pad_state[port_num] ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -236,10 +241,10 @@ static void psp_joypad_poll(void) if (curr_ctrl_info.port[p] == SCE_CTRL_TYPE_UNPAIRED) continue; #elif defined(SN_TARGET_PSP2) - /* Dumb hack, but here's the explanation - + /* Dumb hack, but here's the explanation - * sceCtrlPeekBufferPositive's port parameter * can be 0 or 1 to read the first controller on - * a PSTV, but HAS to be 0 for a real VITA and 2 + * a PSTV, but HAS to be 0 for a real VITA and 2 * for the 2nd controller on a PSTV */ unsigned p = (player > 0) ? player+1 : player; #else @@ -256,12 +261,12 @@ static void psp_joypad_poll(void) continue; #endif #if defined(VITA) - if (psp2_model == SCE_KERNEL_MODEL_VITA + if (psp2_model == SCE_KERNEL_MODEL_VITA && settings->bools.input_backtouch_enable) { unsigned i; SceTouchData touch_surface = {0}; - sceTouchPeek(settings->bools.input_backtouch_toggle + sceTouchPeek(settings->bools.input_backtouch_toggle ? SCE_TOUCH_PORT_FRONT : SCE_TOUCH_PORT_BACK, &touch_surface, 1); for (i = 0; i < touch_surface.reportNum; i++) diff --git a/input/drivers_joypad/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index fa141059e0..05ccfad1a5 100644 --- a/input/drivers_joypad/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2014-2017 - Higor Euripedes - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index ce3ad8617d..03188ccff3 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -82,6 +82,12 @@ struct udev_joypad int32_t pid; }; +struct joypad_udev_entry +{ + const char *devnode; + struct udev_list_entry *item; +}; + static struct udev *udev_joypad_fd = NULL; static struct udev_monitor *udev_joypad_mon = NULL; static struct udev_joypad udev_pads[MAX_USERS]; @@ -204,7 +210,7 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char i = ABS_HAT3Y; continue; } - + if (test_bit(i, absbit)) { struct input_absinfo *abs = &pad->absinfo[axes]; @@ -420,11 +426,11 @@ static bool udev_set_rumble(unsigned i, static bool udev_joypad_poll_hotplug_available(struct udev_monitor *dev) { - struct pollfd fds; + struct pollfd fds; - fds.fd = udev_monitor_get_fd(dev); - fds.events = POLLIN; - fds.revents = 0; + fds.fd = udev_monitor_get_fd(dev); + fds.events = POLLIN; + fds.revents = 0; return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN); } @@ -526,12 +532,22 @@ static void udev_joypad_poll(void) } } +/* Used for sorting devnodes to appear in the correct order */ +static int sort_devnodes(const void *a, const void *b) +{ + const struct joypad_udev_entry *aa = a; + const struct joypad_udev_entry *bb = b; + return strcmp(aa->devnode, bb->devnode); +} + static bool udev_joypad_init(void *data) { unsigned i; + unsigned sorted_count = 0; struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; struct udev_enumerate *enumerate = NULL; + struct joypad_udev_entry sorted[MAX_USERS]; (void)data; @@ -564,6 +580,26 @@ static bool udev_joypad_init(void *data) struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name); const char *devnode = udev_device_get_devnode(dev); + if (devnode != NULL) { + sorted[sorted_count].devnode = devnode; + sorted[sorted_count].item = item; + sorted_count++; + } else { + udev_device_unref(dev); + } + } + + /* Sort the udev entries by devnode name so that they are + * created in the proper order */ + qsort(sorted, sorted_count, + sizeof(struct joypad_udev_entry), sort_devnodes); + + for (i = 0; i < sorted_count; i++) + { + const char *name = udev_list_entry_get_name(sorted[i].item); + struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name); + const char *devnode = udev_device_get_devnode(dev); + if (devnode) udev_check_device(dev, devnode); udev_device_unref(dev); @@ -604,10 +640,15 @@ static bool udev_joypad_button(unsigned port, uint16_t joykey) return joykey < UDEV_NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); } -static uint64_t udev_joypad_get_buttons(unsigned port) +static void udev_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; - return pad->buttons; + const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; + if (pad) + { + BITS_COPY16_PTR( state, pad->buttons ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 8fac55d0ae..b7c46b995f 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -21,7 +21,9 @@ #include #include -#include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#if defined(ENABLE_CONTROLLER_PATCHER) + #include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#endif #include "../input_driver.h" @@ -33,8 +35,12 @@ #include "wiiu_dbg.h" -#ifndef MAX_PADS -#define MAX_PADS 16 +#if !defined(MAX_PADS) + #if defined(ENABLE_CONTROLLER_PATCHER) + #define MAX_PADS 16 + #else + #define MAX_PADS 5 + #endif #endif #define WIIUINPUT_TYPE_WIIMOTE 0x00 @@ -45,22 +51,27 @@ #define GAMEPAD_COUNT 1 #define KPAD_COUNT 4 -#define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT) #define GAMEPAD_OFFSET 0 #define KPAD_OFFSET (GAMEPAD_OFFSET + GAMEPAD_COUNT) -#define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT) + +#if defined(ENABLE_CONTROLLER_PATCHER) + #define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT) + #define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT) +#endif static uint64_t pad_state[MAX_PADS]; static uint8_t pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE}; +#if defined(ENABLE_CONTROLLER_PATCHER) static uint8_t hid_status[HID_COUNT]; static InputData hid_data[HID_COUNT]; +static char hidName[HID_COUNT][255]; +#endif + /* 3 axis - one for touch/future IR support? */ static int16_t analog_state[MAX_PADS][3][2]; static bool wiiu_pad_inited = false; -static char hidName[HID_COUNT][255]; - static const char* wiiu_joypad_name(unsigned pad) { if (pad > MAX_PADS) return "N/A"; @@ -91,12 +102,14 @@ static const char* wiiu_joypad_name(unsigned pad) } } - if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT) - { - s32 hid_index = pad - HID_OFFSET; - sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad); - return hidName[hid_index]; - } + #if defined(ENABLE_CONTROLLER_PATCHER) + if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT) + { + s32 hid_index = pad - HID_OFFSET; + sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad); + return hidName[hid_index]; + } + #endif //defined(ENABLE_CONTROLLER_PATCHER) return "unknown"; } @@ -122,9 +135,14 @@ static bool wiiu_joypad_button(unsigned port_num, uint16_t key) return (pad_state[port_num] & (UINT64_C(1) << key)); } -static uint64_t wiiu_joypad_get_buttons(unsigned port_num) +static void wiiu_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if (port_num < MAX_PADS) + { + BITS_COPY16_PTR( state, pad_state[port_num] ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -190,9 +208,12 @@ static int16_t scaleTP(int16_t oldMin, int16_t oldMax, int16_t newMin, int16_t n static void wiiu_joypad_poll(void) { - int i, c, result; + int i, c; VPADStatus vpad; VPADReadError vpadError; + #if defined(ENABLE_CONTROLLER_PATCHER) + int result; + #endif VPADRead(0, &vpad, 1, &vpadError); @@ -307,41 +328,46 @@ static void wiiu_joypad_poll(void) } } - memset(hid_data,0,sizeof(hid_data)); - result = gettingInputAllDevices(hid_data,HID_COUNT); + #if defined(ENABLE_CONTROLLER_PATCHER) + memset(hid_data,0,sizeof(hid_data)); + result = gettingInputAllDevices(hid_data,HID_COUNT); - if (result + HID_OFFSET > MAX_PADS) - result = MAX_PADS - HID_OFFSET; + if (result + HID_OFFSET > MAX_PADS) + result = MAX_PADS - HID_OFFSET; - for(i = HID_OFFSET;i < result + HID_OFFSET; i++) - { - int hid_index = i-HID_OFFSET; - uint8_t old_status = hid_status[hid_index]; - uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */ - - if (old_status == 1 || new_status == 1) + for(i = HID_OFFSET;i < result + HID_OFFSET; i++) { - hid_status[hid_index] = new_status; - if (old_status == 0 && new_status == 1) /* Pad was attached */ - wiiu_joypad_autodetect_add(i); - else if (old_status == 1 && new_status == 0) /* Pad was detached */ - input_autoconfigure_disconnect(i, wiiu_joypad.ident); - else if (old_status == 1 && new_status == 1) /* Pad still connected */ + int hid_index = i-HID_OFFSET; + uint8_t old_status = hid_status[hid_index]; + uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */ + + if (old_status == 1 || new_status == 1) { - pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */ - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0; + hid_status[hid_index] = new_status; + if (old_status == 0 && new_status == 1) /* Pad was attached */ + wiiu_joypad_autodetect_add(i); + else if (old_status == 1 && new_status == 0) /* Pad was detached */ + input_autoconfigure_disconnect(i, wiiu_joypad.ident); + else if (old_status == 1 && new_status == 1) /* Pad still connected */ + { + pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */ + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0; + } } } - } + #endif //defined(ENABLE_CONTROLLER_PATCHER) } static bool wiiu_joypad_init(void* data) { wiiu_joypad_autodetect_add(0); - memset(hid_status,0,sizeof(hid_status)); + + #if defined(ENABLE_CONTROLLER_PATCHER) + memset(hid_status,0,sizeof(hid_status)); + #endif wiiu_joypad_poll(); wiiu_pad_inited = true; diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index 6bdb3d25b3..517ddaa972 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,7 +19,7 @@ #include "../input_driver.h" #include "../../tasks/tasks_internal.h" -static uint64_t pad_state[MAX_PADS]; +static uint32_t pad_state[MAX_PADS]; static int16_t analog_state[MAX_PADS][2][2]; #ifdef _XBOX1 static HANDLE gamepads[MAX_PADS]; @@ -73,12 +73,17 @@ static bool xdk_joypad_button(unsigned port_num, uint16_t joykey) if (port_num >= MAX_PADS) return false; - return pad_state[port_num] & (UINT64_C(1) << joykey); + return pad_state[port_num] & (1 << joykey); } -static uint64_t xdk_joypad_get_buttons(unsigned port_num) +static void xdk_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if (port_num < MAX_PADS) + { + BITS_COPY16_PTR( state, pad_state[port_num] ); + } + else + BIT256_CLEAR_ALL_PTR(state); } static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -154,7 +159,7 @@ static void xdk_joypad_poll(void) if(bRemoved[port]) { - /* if the controller was removed after + /* if the controller was removed after * XGetDeviceChanges but before * XInputOpen, the device handle will be NULL. */ if(gamepads[port]) @@ -178,14 +183,14 @@ static void xdk_joypad_poll(void) m_pollingParameters.bOutputInterval = 8; gamepads[port] = XInputOpen(XDEVICE_TYPE_GAMEPAD, port, XDEVICE_NO_SLOT, NULL); - + xdk_joypad_autodetect_add(port); } if (!gamepads[port]) continue; - /* if the controller is removed after + /* if the controller is removed after * XGetDeviceChanges but before XInputOpen, * the device handle will be NULL. */ #endif diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index d753a889dc..77a9680d52 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2015 - pinumbernumber * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -40,6 +40,10 @@ #include "../../verbosity.h" +#ifdef HAVE_DINPUT +#include "dinput_joypad.h" +#endif + /* Check if the definitions do not already exist. * Official and mingw xinput headers have different include guards. */ @@ -92,12 +96,8 @@ typedef struct #define ERROR_DEVICE_NOT_CONNECTED 1167 #endif -#ifndef HAVE_DINPUT -#error Cannot compile xinput without dinput. -#endif - -/* Due to 360 pads showing up under both XInput and DirectInput, - * and since we are going to have to pass through unhandled +/* Due to 360 pads showing up under both XInput and DirectInput, + * and since we are going to have to pass through unhandled * joypad numbers to DirectInput, a slightly ugly * hack is required here. dinput_joypad_init will fill this. * @@ -157,6 +157,8 @@ static const char* const XBOX_ONE_CONTROLLER_NAMES[4] = const char *xinput_joypad_name(unsigned pad) { int xuser = pad_index_to_xuser_index(pad); + +#ifdef HAVE_DINPUT /* Use the real controller name for XBOX One controllers since they are slightly different */ if (xuser < 0) @@ -164,6 +166,7 @@ const char *xinput_joypad_name(unsigned pad) if (strstr(dinput_joypad.name(pad), "Xbox One For Windows")) return XBOX_ONE_CONTROLLER_NAMES[xuser]; +#endif return XBOX_CONTROLLER_NAMES[xuser]; } @@ -188,7 +191,7 @@ static bool xinput_joypad_init(void *data) * success anyway. */ - g_xinput_dll = dylib_load("xinput1_4.dll"); + g_xinput_dll = dylib_load("xinput1_4.dll"); if (!g_xinput_dll) { g_xinput_dll = dylib_load("xinput1_3.dll"); @@ -251,15 +254,12 @@ static bool xinput_joypad_init(void *data) (!g_xinput_states[2].connected) && (!g_xinput_states[3].connected)) return false; -#if (1) - else - { - RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + - g_xinput_states[1].connected + g_xinput_states[2].connected + g_xinput_states[3].connected); - } -#endif + + RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + + g_xinput_states[1].connected + g_xinput_states[2].connected + g_xinput_states[3].connected); g_xinput_block_pads = true; +#ifdef HAVE_DINPUT /* We're going to have to be buddies with dinput if we want to be able * to use XInput and non-XInput controllers together. */ if (!dinput_joypad.init(data)) @@ -267,19 +267,36 @@ static bool xinput_joypad_init(void *data) g_xinput_block_pads = false; return false; } +#endif for (j = 0; j < MAX_USERS; j++) { - RARCH_LOG("[XInput]: Attempting autoconf for, user #%u\n", j); + if (xinput_joypad_name(j)) + RARCH_LOG("[XInput]: Attempting autoconf for \"%s\", user #%u\n", xinput_joypad_name(j), j); + else + RARCH_LOG("[XInput]: Attempting autoconf for user #%u\n", j); + if (pad_index_to_xuser_index(j) > -1) { + int32_t vid = 0; + int32_t pid = 0; +#ifdef HAVE_DINPUT + int32_t dinput_index = 0; + bool success = dinput_joypad_get_vidpid_from_xinput_index((int32_t)pad_index_to_xuser_index(j), (int32_t*)&vid, (int32_t*)&pid, + (int32_t*)&dinput_index); + + if (success) + RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", + vid, pid, dinput_index, xinput_joypad_name(j), j); +#endif + if (!input_autoconfigure_connect( xinput_joypad_name(j), NULL, xinput_joypad.ident, j, - 0, - 0)) + vid, + pid)) input_config_set_device_name(j, xinput_joypad_name(j)); } } @@ -292,7 +309,11 @@ static bool xinput_joypad_query_pad(unsigned pad) int xuser = pad_index_to_xuser_index(pad); if (xuser > -1) return g_xinput_states[xuser].connected; +#ifdef HAVE_DINPUT return dinput_joypad.query_pad(pad); +#else + return false; +#endif } static void xinput_joypad_destroy(void) @@ -308,7 +329,9 @@ static void xinput_joypad_destroy(void) g_XInputGetStateEx = NULL; g_XInputSetState = NULL; +#ifdef HAVE_DINPUT dinput_joypad.destroy(); +#endif g_xinput_block_pads = false; } @@ -327,7 +350,7 @@ static const uint16_t button_index_to_bitmap_code[] = { XINPUT_GAMEPAD_BACK, XINPUT_GAMEPAD_LEFT_THUMB, XINPUT_GAMEPAD_RIGHT_THUMB, - XINPUT_GAMEPAD_GUIDE + XINPUT_GAMEPAD_GUIDE }; static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) @@ -337,8 +360,10 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) unsigned hat_dir = 0; int xuser = pad_index_to_xuser_index(port_num); +#ifdef HAVE_DINPUT if (xuser == -1) return dinput_joypad.button(port_num, joykey); +#endif if (!(g_xinput_states[xuser].connected)) return false; @@ -386,14 +411,16 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) xuser = pad_index_to_xuser_index(port_num); +#ifdef HAVE_DINPUT if (xuser == -1) return dinput_joypad.axis(port_num, joyaxis); +#endif if (!(g_xinput_states[xuser].connected)) return 0; /* triggers (axes 4,5) cannot be negative */ - if (AXIS_NEG_GET(joyaxis) <= 3) + if (AXIS_NEG_GET(joyaxis) <= 3) { axis = AXIS_NEG_GET(joyaxis); is_neg = true; @@ -448,14 +475,16 @@ static void xinput_joypad_poll(void) { if (g_xinput_states[i].connected) { - if (g_XInputGetStateEx(i, - &(g_xinput_states[i].xstate)) + if (g_XInputGetStateEx(i, + &(g_xinput_states[i].xstate)) == ERROR_DEVICE_NOT_CONNECTED) g_xinput_states[i].connected = false; } } +#ifdef HAVE_DINPUT dinput_joypad.poll(); +#endif } static bool xinput_joypad_rumble(unsigned pad, @@ -465,8 +494,10 @@ static bool xinput_joypad_rumble(unsigned pad, if (xuser == -1) { +#ifdef HAVE_DINPUT if (dinput_joypad.set_rumble) return dinput_joypad.set_rumble(pad, effect, strength); +#endif return false; } @@ -476,7 +507,7 @@ static bool xinput_joypad_rumble(unsigned pad, else if (effect == RETRO_RUMBLE_WEAK) g_xinput_rumble_states[xuser].wRightMotorSpeed = strength; - return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser]) + return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser]) == 0); } diff --git a/input/drivers_keyboard/keyboard_event_android.c b/input/drivers_keyboard/keyboard_event_android.c index cd7b7e27dd..6c2f95bec8 100644 --- a/input/drivers_keyboard/keyboard_event_android.c +++ b/input/drivers_keyboard/keyboard_event_android.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,7 +19,7 @@ #define AKEYCODE_ASSIST 219 -#define LAST_KEYCODE AKEYCODE_ASSIST +#define LAST_KEYCODE AKEYCODE_ASSIST #define MAX_KEYS ((LAST_KEYCODE + 7) / 8) diff --git a/input/drivers_keyboard/keyboard_event_android.h b/input/drivers_keyboard/keyboard_event_android.h index d80fb2f606..27e77f78a4 100644 --- a/input/drivers_keyboard/keyboard_event_android.h +++ b/input/drivers_keyboard/keyboard_event_android.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_dos.c b/input/drivers_keyboard/keyboard_event_dos.c index f9b76ad4a6..62f23feff9 100644 --- a/input/drivers_keyboard/keyboard_event_dos.c +++ b/input/drivers_keyboard/keyboard_event_dos.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_dos.h b/input/drivers_keyboard/keyboard_event_dos.h index 0cecb85576..0239f5087d 100644 --- a/input/drivers_keyboard/keyboard_event_dos.h +++ b/input/drivers_keyboard/keyboard_event_dos.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_xkb.c b/input/drivers_keyboard/keyboard_event_xkb.c index eae2f1e4c0..b406d12e73 100644 --- a/input/drivers_keyboard/keyboard_event_xkb.c +++ b/input/drivers_keyboard/keyboard_event_xkb.c @@ -152,7 +152,7 @@ void handle_xkb_state_mask(uint32_t depressed, xkb_state_update_mask(xkb_state, depressed, latched, locked, 0, 0, group); } -/* FIXME: Don't handle composed and dead-keys properly. +/* FIXME: Don't handle composed and dead-keys properly. * Waiting for support in libxkbcommon ... */ int handle_xkb(int code, int value) { diff --git a/input/include/GameController/GCController.h b/input/include/GameController/GCController.h index 5eab6264ce..7a7980338e 100644 --- a/input/include/GameController/GCController.h +++ b/input/include/GameController/GCController.h @@ -9,23 +9,23 @@ /** Use these constants with NSNotificationCenter to listen to connection and disconnection events. - + Use GCControllerDidConnectNotification for observing connections of controllers. Use GCControllerDidDisconnectNotification for observing disconnections of controllers. - + Connections and disconnections of controllers will also be reflected in the controllers array of the GCController class. - + The 'object' property of the notification will contain the GCController that was connected or disconnected. For example: - + - (void)controllerDidConnect:(NSNotification *)note { - + GCController *controller = note.object; - + .... } - + @see NSNotificationCenter @see GCController.controllers */ @@ -44,10 +44,10 @@ enum { /** Controllers are available to an application that links to GameController.framework. There are 2 ways to access controllers paired to the system, adopt both to ensure the best user experience: - + 1: Querying for the the current array or controllers using [GCController controllers]. 2: Registering for Connection/Disconnection notifications from NSNotificationCenter. - + Only controllers that support one of the allowed profiles, such as GCGamepad, will be enumerated. Check for the profile supported before using a controller in your application. Ignore a controller that doesn't support a profile that suits your application, as the user will expect their controller to either be fully supported or not supported at all. @@ -59,11 +59,11 @@ GAMECONTROLLER_EXPORT Set this block to be notified when a user intendeds to suspend or resume the current game state. A controller will have a button dedicated to suspending and resuming play and invoking context sensitive actions. During event handling the system will notify the application using this block such that the application can handle the suspension and resumption from the given controller. - + Use this to implement your canonical transition to a pause menu for example if that is your application's desired handling of suspension in play. You may pause and resume base don game state as well so the event is only called each time the pause/resume button is pressed. - + @param controller the controller that is suspending or resuming play. */ @property (copy) void (^controllerPausedHandler)(GCController *controller); @@ -84,29 +84,29 @@ GAMECONTROLLER_EXPORT /** A player index for the controller, defaults to GCControllerPlayerIndexUnset, unless the controller previously had a player index assigned to it on the current user's system. - + This can be set both for the application to keep track of controllers and as a signal to make a controller display a player index on a set of LEDs or some other mechanism. - + A controller is not guranteed to have a visual display of the playerIndex, but the API will keep track of the playerIndex for a controller while connected and in between being disconnected and connected again. Thus playerIndex persists for a controller with regards to a system. This makes it useful for persisting player-controller assignments across game sessions. - + Negative values less than GCControllerPlayerIndexUnset will just map back to GCControllerPlayerIndexUnset when read back. */ @property (nonatomic) NSInteger playerIndex; /** Gets the profile for the controller that suits current application. - + There are only two supported profiles. Each controller may be able to map its inputs into all profiles or just one kind of profile. Query for the controller profile that suits your game, the simplest kind will be supported by the broadest variety of controllers. A controller supporting the Extended Gamepad profile for example supports the Gamepad profile and more. As such it can always be used just in the Gamepad profile if that suits the game. - + A physical controller that supports a profile must support it completely. That means that all buttons and axis inputs must be valid inputs that a developer can utilize. - + If a controller does not support the given profile the returned value will be nil. Use this to filter controllers if the application requires a specific kind of profile. */ @@ -115,7 +115,7 @@ GAMECONTROLLER_EXPORT /** Get a list of controllers currently attached to the system. - + @see GCControllerDidConnectNotification @see GCControllerDidDisconnectNotification */ @@ -126,21 +126,21 @@ GAMECONTROLLER_EXPORT will get called once no more devices can be found. If there are already multiple controllers available for use, there may be little reason to automatically start discovery of new wireless controllers. In this situation it may be best to allow the user to start discovery manually via in-game UI. - + Once discovery has started new controllers will notify themselves as connected via GCControllerDidConnectNotification. As the notification arrives the controller is also available in the controllers array. The completionHandler could be used to update UI and/or game state to indicate that no more controllers will be found and the current set of controllers is what is available for use in the game. - + If a completionHandler was provided, it will be called once when discovery stops. Either from an explicit call to stopWirelessControllerDiscovery or from timing out or stopping in its natural course of operation. Thus the completionHandler will at most be called once per call to startWirelessControllerDiscoveryWithCompletionHandler:. - + The completionHandler may also not get called at all, if for example startWirelessControllerDiscoveryWithCompletionHandler: is called multiple times during dicovery. For this case the net effect is that the completionHandler is replaced with each call and only the last one set before discovery stops will be called. - + @param completionHandler an optional handler that is called when discovery stops. (may be nil, in which case you will not be notified when discovery stops) @see stopWirelessControllerDiscovery @see controllers @@ -152,7 +152,7 @@ GAMECONTROLLER_EXPORT process can be stopped. Calling stopWirelessControllerDiscovery when no discovery is currently in progress will return immediately without any effect, thus it is safe to call even if the completionHandler of startWirelessControllerDiscoveryWithCompletionHandler: has been called. - + @see startWirelessControllerDiscoveryWithCompletionHandler: */ + (void)stopWirelessControllerDiscovery; diff --git a/input/include/GameController/GCControllerAxisInput.h b/input/include/GameController/GCControllerAxisInput.h index 1bb95f3003..7fab120c55 100644 --- a/input/include/GameController/GCControllerAxisInput.h +++ b/input/include/GameController/GCControllerAxisInput.h @@ -12,7 +12,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this axis changes. - + @param axis the element that has been modified. @param value the value the axis was set to at the time the valueChangedHandler fired. */ diff --git a/input/include/GameController/GCControllerButtonInput.h b/input/include/GameController/GCControllerButtonInput.h index 65e977cee4..735bceb9f3 100644 --- a/input/include/GameController/GCControllerButtonInput.h +++ b/input/include/GameController/GCControllerButtonInput.h @@ -12,7 +12,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this button changes. - + @param button the element that has been modified. @param value the value the button was set to at the time the valueChangedHandler fired. @param pressed the pressed state of the button at the time the valueChangedHandler fired. @@ -28,7 +28,7 @@ typedef void (^GCControllerButtonValueChangedHandler)(GCControllerButtonInput *b /** Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of interpreting the value. - + As a general guideline a button is pressed if the value exceeds 25%. However there may be hysterisis applied to counter noisy input values, thus incidental values around the threshold value may not trigger a change in pressed state. diff --git a/input/include/GameController/GCControllerDirectionPad.h b/input/include/GameController/GCControllerDirectionPad.h index afb15b3c6d..5bb1398d15 100644 --- a/input/include/GameController/GCControllerDirectionPad.h +++ b/input/include/GameController/GCControllerDirectionPad.h @@ -16,7 +16,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this axis changes. - + @param dpad the direction pad collection whose axis have been modified. @param xValue the value the x axis was set to at the time the valueChangedHandler fired. @param yValue the value the y axis was set to at the time the valueChangedHandler fired. diff --git a/input/include/GameController/GCExtendedGamepad.h b/input/include/GameController/GCExtendedGamepad.h index 00e4fcb0de..e293ce24e8 100644 --- a/input/include/GameController/GCExtendedGamepad.h +++ b/input/include/GameController/GCExtendedGamepad.h @@ -12,12 +12,12 @@ /** Extended Gamepad profile. Has all the physical features of a Standard Gamepad and more. - + In comparison to the Standard gamepad, The directional pad on an Extended gamepad is optionally analog as the two thumbsticks provided are required to be analog. - + All controller profiles provide a base level of information about the controller they belong to. - + A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for and depend on, no matter the underlying hardware. */ @@ -37,7 +37,7 @@ GAMECONTROLLER_EXPORT Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus will only call this once with the collection as the element. - + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. @param element the element that has been modified. */ @@ -48,7 +48,7 @@ typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent format that can be serialized and used at a later date. This is useful for features such as quality assurance, save game or replay functionality among many. - + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as a snapshot will not change based on user input once it is taken. */ @@ -62,13 +62,13 @@ typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, /** All face buttons are required to be analog in the Extended profile. These must be arranged in the diamond pattern given below: - + Y / \ X B \ / A - + */ @property (readonly) GCControllerButtonInput *buttonA; @property (readonly) GCControllerButtonInput *buttonB; diff --git a/input/include/GameController/GCExtendedGamepadSnapshot.h b/input/include/GameController/GCExtendedGamepadSnapshot.h index 8f6cd125f1..e8500d25fb 100644 --- a/input/include/GameController/GCExtendedGamepadSnapshot.h +++ b/input/include/GameController/GCExtendedGamepadSnapshot.h @@ -10,10 +10,10 @@ /** A GCExtendedGamepadSnapshot snapshot is a concrete GCExtendedGamepad implementation. It can be used directly in an application to implement controller input replays. It is also returned as the result of polling a controller. - + The current snapshotData is readily available to access as NSData. A developer can serialize this to any destination necessary using the NSData API. - + The data contains some version of a GCExtendedGamepadSnapShotData structure. @see -[GCExtendedGamepad saveSnapshot] @@ -32,12 +32,12 @@ typedef struct { // Standard information uint16_t version; //0x0100 uint16_t size; //sizeof(GCExtendedGamepadSnapShotDataV100) or larger - + // Extended gamepad data // Axes in the range [-1.0, 1.0] float_t dpadX; float_t dpadY; - + // Buttons in the range [0.0, 1.0] float_t buttonA; float_t buttonB; @@ -51,7 +51,7 @@ typedef struct { float_t leftThumbstickY; float_t rightThumbstickX; float_t rightThumbstickY; - + // Buttons in the range [0.0, 1.0] float_t leftTrigger; float_t rightTrigger; @@ -60,7 +60,7 @@ typedef struct { #pragma pack(pop) /**Fills out a v100 snapshot from any compatible NSData source - + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. */ GAMECONTROLLER_EXPORT @@ -68,7 +68,7 @@ BOOL GCExtendedGamepadSnapShotDataV100FromNSData(GCExtendedGamepadSnapShotDataV1 /**Creates an NSData object from a v100 snapshot. If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCExtendedGamepadSnapShotDataV100) set as the values implicitly. - + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCExtendedGamepadSnapshot.snapshotData */ GAMECONTROLLER_EXPORT diff --git a/input/include/GameController/GCGamepad.h b/input/include/GameController/GCGamepad.h index 74de5c3558..2c318fcb69 100644 --- a/input/include/GameController/GCGamepad.h +++ b/input/include/GameController/GCGamepad.h @@ -12,9 +12,9 @@ /** Standard Gamepad profile. - + All controller profiles provide a base level of information about the controller they belong to. - + A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for and depend on, no matter the underlying hardware. */ @@ -34,7 +34,7 @@ GAMECONTROLLER_EXPORT Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus will only call this once with the collection as the element. - + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. @param element the element that has been modified. */ @@ -45,7 +45,7 @@ typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerEle Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent format that can be serialized and used at a later date. This is useful for features such as quality assurance, save game or replay functionality among many. - + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as a snapshot will not change based on user input once it is taken. */ @@ -59,13 +59,13 @@ typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerEle /** All face buttons are required to be analog in the Standard profile. These must be arranged in the diamond pattern given below: - + Y / \ X B \ / A - + */ @property (readonly) GCControllerButtonInput *buttonA; @property (readonly) GCControllerButtonInput *buttonB; diff --git a/input/include/GameController/GCGamepadSnapshot.h b/input/include/GameController/GCGamepadSnapshot.h index b81922483c..117efdc9c5 100644 --- a/input/include/GameController/GCGamepadSnapshot.h +++ b/input/include/GameController/GCGamepadSnapshot.h @@ -11,12 +11,12 @@ A GCGamepadSnapshot snapshot is a concrete GCGamepad implementation. It can be used directly in an application to implement controller input replays. It is also returned as the result of polling a controller. - + The current snapshotData is readily available to access as NSData. A developer can serialize this to any destination necessary using the NSData API. - + The data contains some version of a GCGamepadSnapShotData structure. - + @see -[GCGamepad saveSnapshot] */ GAMECONTROLLER_EXPORT @@ -33,12 +33,12 @@ typedef struct { // Standard information uint16_t version; //0x0100 uint16_t size; //sizeof(GCGamepadSnapShotDataV100) or larger - + // Standard gamepad data // Axes in the range [-1.0, 1.0] float_t dpadX; float_t dpadY; - + // Buttons in the range [0.0, 1.0] float_t buttonA; float_t buttonB; @@ -46,12 +46,12 @@ typedef struct { float_t buttonY; float_t leftShoulder; float_t rightShoulder; - + } GCGamepadSnapShotDataV100; #pragma pack(pop) /**Fills out a v100 snapshot from any compatible NSData source - + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. */ GAMECONTROLLER_EXPORT @@ -59,7 +59,7 @@ BOOL GCGamepadSnapShotDataV100FromNSData(GCGamepadSnapShotDataV100 *snapshotData /**Creates an NSData object from a v100 snapshot. If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCGamepadSnapShotDataV100) set as the values implicitly. - + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData */ GAMECONTROLLER_EXPORT diff --git a/input/include/blissbox.h b/input/include/blissbox.h new file mode 100644 index 0000000000..4ec18e500d --- /dev/null +++ b/input/include/blissbox.h @@ -0,0 +1,101 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __BLISSBOX_H +#define __BLISSBOX_H + +#include + +#define BLISSBOX_VID 0x16d0 /* requires firmware 2.0 */ +#define BLISSBOX_PID 0x0d04 /* first of 4 controllers, each one increments PID by 1 */ +#define BLISSBOX_UPDATE_MODE_PID 0x0a5f +#define BLISSBOX_OLD_PID 0x0a60 +#define BLISSBOX_MAX_PADS 4 +#define BLISSBOX_MAX_PAD_INDEX (BLISSBOX_MAX_PADS - 1) + +#define BLISSBOX_USB_FEATURE_REPORT_ID 17 + +RETRO_BEGIN_DECLS + +typedef struct { + const char *name; + int index; +} blissbox_pad_type_t; + +const blissbox_pad_type_t blissbox_pad_types[] = +{ + {"A5200", 6}, + {"A5200_TB", 50}, + {"A7800", 4}, + {"ATARI_KEYPAD", 43}, + {"ATARI", 0}, + {"ATMARK", 10}, + {"BALLY", 42}, + {"CD32", 24}, + {"CDI", 33}, + {"COL", 1}, + {"DC_ASCI", 15}, + {"DC_PAD", 16}, + {"FC_ARKANOID", 53}, + {"FC_NES", 52}, + {"GC", 9}, + {"GC_WHEEL", 18}, + {"GEN_3", 20}, + {"GEN_6", 21}, + {"GRAVIS_EX", 38}, + {"gx4000", 2}, + {"HAMMERHEAD", 40}, + {"HPD", 7}, + {"INTELI", 14}, + {"JAG", 11}, + {"MSSW", 39}, + {"N64", 19}, + {"NEO", 49}, + {"NES", 17}, + {"PADDLES", 41}, + {"PC_FX", 26}, + {"PC_GAMEPAD", 46}, + {"PSX_DIGITAL", 65}, + {"PSX_DS", 115}, + {"PSX_DS2", 121}, + {"PSX_FS", 83}, + {"PSX_NEGCON", 51}, + {"PSX_WHEEL", 12}, + {"SAC", 34}, + {"SATURN_ANALOG", 8}, + {"SATURN_DIGITAL", 3}, + {"SMS", 22}, + {"SPEEK", 45}, + {"TG16", 23}, + {"THREE_DO", 25}, + {"THREE_DO_ANALOG", 37}, + {"VEC", 5}, + {"WII_NUNCHUK", 13}, + {"ZXSINC", 44}, + {"NES_ARKANOID", 30}, + {"NES_GUN", 28}, + {"NES_POWERPAD", 36}, + {"SNES", 27}, + {"V_BOY", 29}, + {"WII_CLASSIC", 31}, + {"WII_MPLUS", 32}, + {NULL, 0}, /* used to mark unconnected ports, do not remove */ +}; + +RETRO_END_DECLS + +#endif diff --git a/input/input_autodetect_builtin.c b/input/input_autodetect_builtin.c index ba55e1ecbd..e9fb439510 100644 --- a/input/input_autodetect_builtin.c +++ b/input/input_autodetect_builtin.c @@ -361,58 +361,61 @@ DECL_AXIS(r_y_plus, -3) \ DECL_AXIS(r_y_minus, +3) #define GXINPUT_WIIMOTE_DEFAULT_BINDS \ -DECL_BTN(a, 31) \ -DECL_BTN(b, 30) \ -DECL_BTN(x, 29) \ -DECL_BTN(y, 28) \ -DECL_BTN(start, 32) \ -DECL_BTN(select, 33) \ -DECL_BTN(up, 35) \ -DECL_BTN(down, 36) \ -DECL_BTN(left, 37) \ -DECL_BTN(right, 38) +DECL_BTN_EX(a, 31, "2") \ +DECL_BTN_EX(b, 30, "1") \ +DECL_BTN_EX(x, 29, "B") \ +DECL_BTN_EX(y, 28, "A") \ +DECL_BTN_EX(start, 32, "+") \ +DECL_BTN_EX(select, 33, "-") \ +DECL_BTN_EX(menu_toggle, 34, "Home") \ +DECL_BTN_EX(up, 35, "D-Pad Up") \ +DECL_BTN_EX(down, 36, "D-Pad Down") \ +DECL_BTN_EX(left, 37, "D-Pad Left") \ +DECL_BTN_EX(right, 38, "D-Pad right") #define GXINPUT_NUNCHUK_DEFAULT_BINDS \ -DECL_BTN(a, 28) \ -DECL_BTN(b, 29) \ -DECL_BTN(x, 30) \ -DECL_BTN(y, 31) \ -DECL_BTN(start, 32) \ -DECL_BTN(select, 33) \ -DECL_BTN(up, 35) \ -DECL_BTN(down, 36) \ -DECL_BTN(left, 37) \ -DECL_BTN(right, 38) \ -DECL_BTN(l, 39) \ -DECL_BTN(r, 40) \ -DECL_AXIS(l_x_plus, +0) \ -DECL_AXIS(l_x_minus, -0) \ -DECL_AXIS(l_y_plus, +1) \ -DECL_AXIS(l_y_minus, -1) +DECL_BTN_EX(a, 28, "A") \ +DECL_BTN_EX(b, 29, "B") \ +DECL_BTN_EX(x, 30, "1") \ +DECL_BTN_EX(y, 31, "2") \ +DECL_BTN_EX(start, 32, "+") \ +DECL_BTN_EX(select, 33, "-") \ +DECL_BTN_EX(menu_toggle, 34, "Home") \ +DECL_BTN_EX(up, 35, "D-Pad Up" ) \ +DECL_BTN_EX(down, 36, "D-Pad Down") \ +DECL_BTN_EX(left, 37, "D-Pad Left") \ +DECL_BTN_EX(right, 38, "D-Pad right") \ +DECL_BTN_EX(l, 39, "Z") \ +DECL_BTN_EX(r, 40, "C") \ +DECL_AXIS_EX(l_x_plus, +0, "Stick Right") \ +DECL_AXIS_EX(l_x_minus, -0, "Stick Left") \ +DECL_AXIS_EX(l_y_plus, +1, "Stick Down") \ +DECL_AXIS_EX(l_y_minus, -1, "Stick Up") #define GXINPUT_CLASSIC_DEFAULT_BINDS \ -DECL_BTN(a, 13) \ -DECL_BTN(b, 14) \ -DECL_BTN(x, 15) \ -DECL_BTN(y, 16) \ -DECL_BTN(start, 17) \ -DECL_BTN(select, 18) \ -DECL_BTN(up, 24) \ -DECL_BTN(down, 25) \ -DECL_BTN(left, 26) \ -DECL_BTN(right, 27) \ -DECL_BTN(l, 20) \ -DECL_BTN(r, 21) \ -DECL_BTN(l2, 22) \ -DECL_BTN(r2, 23) \ -DECL_AXIS(l_x_plus, +0) \ -DECL_AXIS(l_x_minus, -0) \ -DECL_AXIS(l_y_plus, +1) \ -DECL_AXIS(l_y_minus, -1) \ -DECL_AXIS(r_x_plus, +2) \ -DECL_AXIS(r_x_minus, -2) \ -DECL_AXIS(r_y_plus, -3) \ -DECL_AXIS(r_y_minus, +3) +DECL_BTN_EX(a, 13, "A") \ +DECL_BTN_EX(b, 14, "B") \ +DECL_BTN_EX(x, 15, "X") \ +DECL_BTN_EX(y, 16, "Y") \ +DECL_BTN_EX(start, 17, "+") \ +DECL_BTN_EX(select, 18, "-") \ +DECL_BTN_EX(menu_toggle, 19, "Home") \ +DECL_BTN_EX(up, 24, "D-Pad Up") \ +DECL_BTN_EX(down, 25, "D-Pad Down") \ +DECL_BTN_EX(left, 26, "D-Pad left") \ +DECL_BTN_EX(right, 27, "D-Pad right") \ +DECL_BTN_EX(l, 20, "L") \ +DECL_BTN_EX(r, 21, "R") \ +DECL_BTN_EX(l2, 22, "ZL") \ +DECL_BTN_EX(r2, 23, "ZR") \ +DECL_AXIS_EX(l_x_plus, +0, "L-Stick Right") \ +DECL_AXIS_EX(l_x_minus, -0, "L-Stick Left") \ +DECL_AXIS_EX(l_y_plus, +1, "L-Stick Down") \ +DECL_AXIS_EX(l_y_minus, -1, "L-Stick Up") \ +DECL_AXIS_EX(r_x_plus, +2, "R-Stick Right") \ +DECL_AXIS_EX(r_x_minus, -2, "R-Stick Left") \ +DECL_AXIS_EX(r_y_plus, +3, "R-Stick Down") \ +DECL_AXIS_EX(r_y_minus, -3, "R-Stick Up") #define PS3INPUT_DEFAULT_BINDS \ DECL_BTN(a, 8) \ @@ -544,16 +547,16 @@ const char* const input_builtin_autoconfs[] = #endif #ifdef WIIU DECL_AUTOCONF_DEVICE("WIIU Gamepad", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), - DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("WIIU Pro Controller", "wiiu", WIIUINPUT_PRO_CONTROLLER_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Wiimote Controller", "wiiu", WIIUINPUT_WIIMOTE_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Nunchuk Controller", "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Classic Controller", "wiiu", WIIUINPUT_CLASSIC_CONTROLLER_DEFAULT_BINDS), + #if defined(ENABLE_CONTROLLER_PATCHER) + DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), + #endif #endif #ifdef __CELLOS_LV2__ DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS), #endif NULL }; - - diff --git a/input/input_defines.h b/input/input_defines.h index 2d1d88d3f3..3255a85180 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -18,6 +18,7 @@ #define __INPUT_DEFINES__H #include +#include #include @@ -25,7 +26,11 @@ RETRO_BEGIN_DECLS #define MAX_USERS 16 +#define MAX_INPUT_DEVICES 16 + #define RARCH_FIRST_CUSTOM_BIND 16 +#define RARCH_FIRST_LIGHTGUN_BIND RARCH_ANALOG_BIND_LIST_END +#define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END #define RARCH_FIRST_META_KEY RARCH_CUSTOM_BIND_LIST_END /* RetroArch specific bind IDs. */ @@ -42,9 +47,24 @@ enum RARCH_ANALOG_RIGHT_X_MINUS, RARCH_ANALOG_RIGHT_Y_PLUS, RARCH_ANALOG_RIGHT_Y_MINUS, + RARCH_ANALOG_BIND_LIST_END, + + /* Lightgun */ + RARCH_LIGHTGUN_TRIGGER = RARCH_FIRST_LIGHTGUN_BIND, + RARCH_LIGHTGUN_RELOAD, + RARCH_LIGHTGUN_AUX_A, + RARCH_LIGHTGUN_AUX_B, + RARCH_LIGHTGUN_AUX_C, + RARCH_LIGHTGUN_START, + RARCH_LIGHTGUN_SELECT, + RARCH_LIGHTGUN_DPAD_UP, + RARCH_LIGHTGUN_DPAD_DOWN, + RARCH_LIGHTGUN_DPAD_LEFT, + RARCH_LIGHTGUN_DPAD_RIGHT, + RARCH_LIGHTGUN_BIND_LIST_END, /* Turbo */ - RARCH_TURBO_ENABLE, + RARCH_TURBO_ENABLE = RARCH_FIRST_MISC_CUSTOM_BIND, RARCH_CUSTOM_BIND_LIST_END, diff --git a/input/input_driver.c b/input/input_driver.c index 522f6caab8..3765d39916 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -233,7 +233,7 @@ static const uint8_t buttons[] = { static uint16_t input_config_vid[MAX_USERS]; static uint16_t input_config_pid[MAX_USERS]; -char input_device_names[MAX_USERS][64]; +char input_device_names[MAX_INPUT_DEVICES][64]; struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; const struct retro_keybind *libretro_input_binds[MAX_USERS]; @@ -267,6 +267,18 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), + DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), + DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), + DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), + DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), + DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), + DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), + DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), + DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), + DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), + DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), + DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), + DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), @@ -324,8 +336,8 @@ struct input_keyboard_line size_t ptr; size_t size; - /** Line complete callback. - * Calls back after return is + /** Line complete callback. + * Calls back after return is * pressed with the completed line. * Line can be NULL. **/ @@ -381,6 +393,7 @@ static const void *hid_data = NULL; #define check_input_driver_block_hotkey(normal_bind, autoconf_bind) \ ( \ (((normal_bind)->key != RETROK_UNKNOWN) \ + || ((normal_bind)->mbutton != NO_BTN) \ || ((normal_bind)->joykey != NO_BTN) \ || ((normal_bind)->joyaxis != AXIS_NONE) \ || ((autoconf_bind)->key != RETROK_UNKNOWN ) \ @@ -467,9 +480,9 @@ const input_device_driver_t *input_driver_get_joypad_driver(void) const input_device_driver_t *input_driver_get_sec_joypad_driver(void) { - if (!current_input || !current_input->get_sec_joypad_driver) - return NULL; - return current_input->get_sec_joypad_driver(current_input_data); + if (!current_input || !current_input->get_sec_joypad_driver) + return NULL; + return current_input->get_sec_joypad_driver(current_input_data); } uint64_t input_driver_get_capabilities(void) @@ -486,7 +499,7 @@ void input_driver_set(const input_driver_t **input, void **input_data) *input = current_input; *input_data = current_input_data; } - + input_driver_set_own_driver(); } @@ -535,7 +548,7 @@ void input_poll(void) size_t i; settings_t *settings = config_get_ptr(); uint8_t max_users = (uint8_t)input_driver_max_users; - + current_input->poll(current_input_data); input_driver_turbo_btns.count++; @@ -544,7 +557,7 @@ void input_poll(void) { input_driver_turbo_btns.frame_enable[i] = 0; - if (!input_driver_block_libretro_input && + if (!input_driver_block_libretro_input && libretro_input_binds[i][RARCH_TURBO_ENABLE].valid) { rarch_joypad_info_t joypad_info; @@ -595,7 +608,7 @@ void input_poll(void) * * Input state callback function. * - * Returns: Non-zero if the given key (identified by @id) + * Returns: Non-zero if the given key (identified by @id) * was pressed by the user (assigned to @port). **/ int16_t input_state(unsigned port, unsigned device, @@ -614,7 +627,7 @@ int16_t input_state(unsigned port, unsigned device, bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL); } - if ( !input_driver_flushing_input + if ( !input_driver_flushing_input && !input_driver_block_libretro_input) { settings_t *settings = config_get_ptr(); @@ -682,8 +695,8 @@ int16_t input_state(unsigned port, unsigned device, * * If turbo button is held, all buttons pressed except * for D-pad will go into a turbo mode. Until the button is - * released again, the input state will be modulated by a - * periodic pulse defined by the configured duty cycle. + * released again, the input state will be modulated by a + * periodic pulse defined by the configured duty cycle. */ if (res && input_driver_turbo_btns.frame_enable[port]) input_driver_turbo_btns.enable[port] |= (1 << id); @@ -693,7 +706,7 @@ int16_t input_state(unsigned port, unsigned device, if (input_driver_turbo_btns.enable[port] & (1 << id)) { /* if turbo button is enabled for this key ID */ - res = res && ((input_driver_turbo_btns.count + res = res && ((input_driver_turbo_btns.count % settings->uints.input_turbo_period) < settings->uints.input_turbo_duty_cycle); } @@ -790,16 +803,19 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *binds_norm = NULL; const struct retro_keybind *binds_auto = NULL; uint8_t max_users = (uint8_t)input_driver_max_users; - uint8_t port_max = - settings->bools.input_all_users_control_menu - ? max_users : 1; + uint8_t port_max = + settings->bools.input_all_users_control_menu + ? max_users : 1; - RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); + joypad_info.joy_idx = 0; + joypad_info.auto_binds = NULL; + + BIT256_CLEAR_ALL_PTR(p_new_state); input_driver_block_libretro_input = false; input_driver_block_hotkey = false; - if (current_input->keyboard_mapping_is_blocked + if (current_input->keyboard_mapping_is_blocked && current_input->keyboard_mapping_is_blocked(current_input_data)) input_driver_block_hotkey = true; @@ -824,7 +840,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.axis_threshold = input_driver_axis_threshold; - if (htkey->valid + if (htkey->valid && current_input->input_state(current_input_data, joypad_info, &binds[0], port, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) { @@ -846,9 +862,9 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) || !input_driver_block_hotkey)) ) { - const input_device_driver_t *first = current_input->get_joypad_driver + const input_device_driver_t *first = current_input->get_joypad_driver ? current_input->get_joypad_driver(current_input_data) : NULL; - const input_device_driver_t *sec = current_input->get_sec_joypad_driver + const input_device_driver_t *sec = current_input->get_sec_joypad_driver ? current_input->get_sec_joypad_driver(current_input_data) : NULL; for (port = 0; port < port_max; port++) @@ -867,9 +883,9 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joykey = (input_config_binds[port][i].joykey != NO_BTN) ? input_config_binds[port][i].joykey : joypad_info.auto_binds[i].joykey; - joyaxis = (input_config_binds[port][i].joyaxis != AXIS_NONE) + joyaxis = (input_config_binds[port][i].joyaxis != AXIS_NONE) ? input_config_binds[port][i].joyaxis : joypad_info.auto_binds[i].joyaxis; - + if (sec) { if ((uint16_t)joykey == NO_BTN || !sec->button(joypad_info.joy_idx, (uint16_t)joykey)) @@ -896,7 +912,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (pressed) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -906,7 +922,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) { if (current_input->meta_key_pressed(current_input_data, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -914,7 +930,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_OVERLAY if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -929,7 +945,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -938,7 +954,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_NETWORKGAMEPAD if (input_driver_remote && input_remote_key_pressed(i, 0)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -952,7 +968,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (!menu_input_dialog_get_display_kb()) { - unsigned ids[13][2]; + unsigned ids[14][2]; const struct retro_keybind *quitkey = &input_config_binds[0][RARCH_QUIT_KEY]; const struct retro_keybind *fskey = &input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY]; @@ -982,6 +998,8 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) ids[11][1] = RETRO_DEVICE_ID_JOYPAD_B; ids[12][0] = RETROK_RETURN; ids[12][1] = RETRO_DEVICE_ID_JOYPAD_A; + ids[13][0] = RETROK_DELETE; + ids[13][1] = RETRO_DEVICE_ID_JOYPAD_Y; if (settings->bools.input_menu_swap_ok_cancel_buttons) { @@ -989,11 +1007,12 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B; } - for (i = 0; i < 13; i++) + for (i = 0; i < 14; i++) { - if (current_input->input_state(current_input_data, joypad_info, binds, 0, + if (current_input->input_state(current_input_data, + joypad_info, binds, 0, RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, ids[i][1]); + BIT256_SET_PTR(p_new_state, ids[i][1]); } } } @@ -1020,16 +1039,16 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *enable_hotkey = &input_config_binds[0][RARCH_ENABLE_HOTKEY]; bool game_focus_toggle_valid = false; - RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); + BIT256_CLEAR_ALL_PTR(p_new_state); joypad_info.joy_idx = settings->uints.input_joypad_map[0]; joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.axis_threshold = input_driver_axis_threshold; - + input_driver_block_libretro_input = false; input_driver_block_hotkey = false; - if ( current_input->keyboard_mapping_is_blocked + if ( current_input->keyboard_mapping_is_blocked && current_input->keyboard_mapping_is_blocked(current_input_data)) input_driver_block_hotkey = true; @@ -1039,14 +1058,14 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) && current_input->input_state( current_input_data, joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) - input_driver_block_libretro_input = true; - else - input_driver_block_hotkey = true; + input_driver_block_libretro_input = true; + else + input_driver_block_hotkey = true; } game_focus_toggle_valid = binds[RARCH_GAME_FOCUS_TOGGLE].valid; - /* Allows rarch_focus_toggle hotkey to still work + /* Allows rarch_focus_toggle hotkey to still work * even though every hotkey is blocked */ if (check_input_driver_block_hotkey( focus_normal, focus_binds_auto) && game_focus_toggle_valid) @@ -1060,29 +1079,29 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) { if ( ((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) - || !input_driver_block_hotkey) && + || !input_driver_block_hotkey) && binds[i].valid && current_input->input_state(current_input_data, joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, i) ) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } if ((i >= RARCH_FIRST_META_KEY) && current_input->meta_key_pressed(current_input_data, i) - ) + ) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #ifdef HAVE_OVERLAY - if (overlay_ptr && + if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -1097,17 +1116,17 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } #endif #ifdef HAVE_NETWORKGAMEPAD - if (input_driver_remote && + if (input_driver_remote && input_remote_key_pressed(i, 0)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -1304,7 +1323,7 @@ bool input_driver_init_command(void) } input_driver_command = command_new(); - + if (command_network_new( input_driver_command, stdin_cmd_enable && !grab_stdin, @@ -1484,7 +1503,7 @@ const char* config_get_joypad_driver_options(void) * * Initialize a joypad driver of name @ident. * - * If ident points to NULL or a zero-length string, + * If ident points to NULL or a zero-length string, * equivalent to calling input_joypad_init_first(). * * Returns: joypad driver if found, otherwise NULL. @@ -1535,7 +1554,7 @@ const input_device_driver_t *input_joypad_init_first(void *data) } /** - * input_joypad_name: + * input_joypad_name: * @drv : Input device driver handle. * @port : Joystick number. * @@ -1569,7 +1588,7 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv, if (!input_config_get_bind_idx(port, &joy_idx)) return false; - + if (!drv || !drv->set_rumble) return false; @@ -1581,7 +1600,7 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv, * @drv : Input device driver handle. * @port : User number. * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -1600,108 +1619,108 @@ int16_t input_joypad_analog(const input_device_driver_t *drv, unsigned port, unsigned idx, unsigned ident, const struct retro_keybind *binds) { - int16_t res; + int16_t res; - if ( idx == RETRO_DEVICE_INDEX_ANALOG_BUTTON ) - { - /* A RETRO_DEVICE_JOYPAD button? */ - if ( ident < RARCH_FIRST_CUSTOM_BIND ) - { - uint32_t axis = 0; - const struct retro_keybind *bind = NULL; + if ( idx == RETRO_DEVICE_INDEX_ANALOG_BUTTON ) + { + /* A RETRO_DEVICE_JOYPAD button? */ + if ( ident < RARCH_FIRST_CUSTOM_BIND ) + { + uint32_t axis = 0; + const struct retro_keybind *bind = NULL; - bind = &binds[ ident ]; - if (!bind->valid) - return 0; + bind = &binds[ ident ]; + if (!bind->valid) + return 0; - axis = bind->joyaxis; - if ( axis == AXIS_NONE ) - axis = joypad_info.auto_binds[ ident ].joyaxis; + axis = bind->joyaxis; + if ( axis == AXIS_NONE ) + axis = joypad_info.auto_binds[ ident ].joyaxis; - /* Analog button. */ - res = abs( drv->axis( joypad_info.joy_idx, axis ) ); + /* Analog button. */ + res = abs( drv->axis( joypad_info.joy_idx, axis ) ); - /* If the result is zero, it's got a digital button attached to it */ - if ( res == 0 ) - { - uint64_t key = bind->joykey; + /* If the result is zero, it's got a digital button attached to it */ + if ( res == 0 ) + { + uint64_t key = bind->joykey; - if ( key == NO_BTN ) - key = joypad_info.auto_binds[ ident ].joykey; + if ( key == NO_BTN ) + key = joypad_info.auto_binds[ ident ].joykey; - if ( drv->button(joypad_info.joy_idx, (uint16_t)key)) - res = 0x7fff; - } - } - else - { - /* not a suitable button */ - res = 0; - } - } - else - { - /* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT - * or RETRO_DEVICE_INDEX_ANALOG_RIGHT */ + if ( drv->button(joypad_info.joy_idx, (uint16_t)key)) + res = 0x7fff; + } + } + else + { + /* not a suitable button */ + res = 0; + } + } + else + { + /* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT + * or RETRO_DEVICE_INDEX_ANALOG_RIGHT */ - uint32_t axis_minus, axis_plus; - int16_t pressed_minus, pressed_plus; - unsigned ident_minus = 0; - unsigned ident_plus = 0; - const struct retro_keybind *bind_minus = NULL; - const struct retro_keybind *bind_plus = NULL; + uint32_t axis_minus, axis_plus; + int16_t pressed_minus, pressed_plus; + unsigned ident_minus = 0; + unsigned ident_plus = 0; + const struct retro_keybind *bind_minus = NULL; + const struct retro_keybind *bind_plus = NULL; - input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); + input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); - bind_minus = &binds[ident_minus]; - bind_plus = &binds[ident_plus]; + bind_minus = &binds[ident_minus]; + bind_plus = &binds[ident_plus]; - if (!bind_minus->valid || !bind_plus->valid) - return 0; + if (!bind_minus->valid || !bind_plus->valid) + return 0; - axis_minus = bind_minus->joyaxis; - axis_plus = bind_plus->joyaxis; + axis_minus = bind_minus->joyaxis; + axis_plus = bind_plus->joyaxis; - if (axis_minus == AXIS_NONE) - axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; - if (axis_plus == AXIS_NONE) - axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; + if (axis_minus == AXIS_NONE) + axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; + if (axis_plus == AXIS_NONE) + axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; - pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); - pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); - res = pressed_plus - pressed_minus; + pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); + pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); + res = pressed_plus - pressed_minus; - if (res == 0) - { - int16_t digital_left = 0; - int16_t digital_right = 0; - uint64_t key_minus = bind_minus->joykey; - uint64_t key_plus = bind_plus->joykey; + if (res == 0) + { + int16_t digital_left = 0; + int16_t digital_right = 0; + uint64_t key_minus = bind_minus->joykey; + uint64_t key_plus = bind_plus->joykey; - if (key_minus == NO_BTN) - key_minus = joypad_info.auto_binds[ident_minus].joykey; - if (key_plus == NO_BTN) - key_plus = joypad_info.auto_binds[ident_plus].joykey; + if (key_minus == NO_BTN) + key_minus = joypad_info.auto_binds[ident_minus].joykey; + if (key_plus == NO_BTN) + key_plus = joypad_info.auto_binds[ident_plus].joykey; - if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) - digital_left = -0x7fff; - if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) - digital_right = 0x7fff; + if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) + digital_left = -0x7fff; + if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) + digital_right = 0x7fff; - return digital_right + digital_left; - } - } + return digital_right + digital_left; + } + } - return res; + return res; } /** - * input_joypad_axis_raw: + * input_joypad_axis_raw: * @drv : Input device driver handle. * @port : Joystick number. * @axis : Identifier of axis. * - * Checks if axis (@axis) was being pressed by user + * Checks if axis (@axis) was being pressed by user * with joystick number @port. * * Returns: true (1) if axis was pressed, otherwise @@ -1744,10 +1763,43 @@ bool input_joypad_hat_raw(const input_device_driver_t *drv, return drv->button(port, HAT_MAP(hat, hat_dir)); } +/** + * input_mouse_button_raw: + * @port : Mouse number. + * @button : Identifier of key (libretro mouse constant). + * + * Checks if key (@button) was being pressed by user + * with mouse number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_mouse_button_raw(unsigned port, unsigned id) +{ + int16_t res; + rarch_joypad_info_t joypad_info; + settings_t *settings = config_get_ptr(); + + /*ignore axes*/ + if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) + return false; + + joypad_info.axis_threshold = input_driver_axis_threshold; + joypad_info.joy_idx = settings->uints.input_joypad_map[port]; + joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; + + res = current_input->input_state(current_input_data, + joypad_info, libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id); + + if (res) + return true; + return false; +} + /** * input_conv_analog_id_to_bind_id: * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -1903,7 +1955,7 @@ static bool input_keyboard_line_event( const char *word = NULL; char c = character >= 128 ? '?' : character; - /* Treat extended chars as ? as we cannot support + /* Treat extended chars as ? as we cannot support * printable characters for unicode stuff. */ if (c == '\r' || c == '\n') @@ -1978,8 +2030,8 @@ bool input_keyboard_line_append(const char *word) unsigned i = 0; unsigned len = (unsigned)strlen(word); char *newbuf = (char*) - realloc(g_keyboard_line->buffer, - g_keyboard_line->size + len*2); + realloc(g_keyboard_line->buffer, + g_keyboard_line->size + len*2); if (!newbuf) return false; @@ -2017,8 +2069,8 @@ bool input_keyboard_line_append(const char *word) * * Sets function pointer for keyboard line handle. * - * The underlying buffer can be reallocated at any time - * (or be NULL), but the pointer to it remains constant + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant * throughout the objects lifetime. * * Returns: underlying buffer of the keyboard line. @@ -2161,7 +2213,7 @@ static const void *input_config_bind_map_get(unsigned i) bool input_config_bind_map_get_valid(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return false; @@ -2170,7 +2222,7 @@ bool input_config_bind_map_get_valid(unsigned i) unsigned input_config_bind_map_get_meta(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return 0; @@ -2179,7 +2231,7 @@ unsigned input_config_bind_map_get_meta(unsigned i) const char *input_config_bind_map_get_base(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return NULL; @@ -2188,7 +2240,7 @@ const char *input_config_bind_map_get_base(unsigned i) const char *input_config_bind_map_get_desc(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return NULL; @@ -2234,7 +2286,7 @@ const char *input_config_get_prefix(unsigned user, bool meta) const char *prefix = bind_user_prefix[user]; if (user == 0) - return meta ? "input" : prefix; + return meta ? "input" : prefix; if (!meta) return prefix; @@ -2278,7 +2330,7 @@ enum retro_key input_config_translate_str_to_rk(const char *str) * * Translate string representation to bind ID. * - * Returns: Bind ID value on success, otherwise + * Returns: Bind ID value on success, otherwise * RARCH_BIND_LIST_END on not found. **/ unsigned input_config_translate_str_to_bind_id(const char *str) @@ -2410,6 +2462,74 @@ void input_config_parse_joy_axis(void *data, const char *prefix, } } +void input_config_parse_mouse_button(void *data, const char *prefix, + const char *btn, struct retro_keybind *bind) +{ + int val; + char str[256]; + char tmp[64]; + char key[64]; + config_file_t *conf = (config_file_t*)data; + + str[0] = tmp[0] = key[0] = '\0'; + + fill_pathname_join_delim(str, prefix, btn, + '_', sizeof(str)); + fill_pathname_join_delim(key, str, + "mbtn", '_', sizeof(key)); + + if ( bind && config_get_array(conf, key, tmp, sizeof(tmp)) ) + { + bind->mbutton = NO_BTN; + + if ( tmp[0]=='w' ) + { + switch ( tmp[1] ) + { + case 'u': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELUP; + break; + case 'd': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELDOWN; + break; + case 'h': + switch ( tmp[2] ) + { + case 'u': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP; + break; + case 'd': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN; + break; + } + break; + } + } + else + { + val = atoi(tmp); + switch ( val ) + { + case 1: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_LEFT; + break; + case 2: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_RIGHT; + break; + case 3: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_MIDDLE; + break; + case 4: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_4; + break; + case 5: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_5; + break; + } + } + } +} + static void input_config_get_bind_string_joykey( char *buf, const char *prefix, const struct retro_keybind *bind, size_t size) @@ -2452,9 +2572,9 @@ static void input_config_get_bind_string_joykey( { if (bind->joykey_label && !string_is_empty(bind->joykey_label) && label_show) - snprintf(buf, size, "%s%s (btn) ", prefix, bind->joykey_label); + snprintf(buf, size, "%s%s (btn)", prefix, bind->joykey_label); else - snprintf(buf, size, "%s%u (%s) ", prefix, (unsigned)bind->joykey, + snprintf(buf, size, "%s%u (%s)", prefix, (unsigned)bind->joykey, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)); } } @@ -2465,7 +2585,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, settings_t *settings = config_get_ptr(); if (bind->joyaxis_label && - !string_is_empty(bind->joyaxis_label) + !string_is_empty(bind->joyaxis_label) && settings->bools.input_descriptor_label_show) snprintf(buf, size, "%s%s (axis) ", prefix, bind->joyaxis_label); else @@ -2482,7 +2602,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, dir = '+'; axis = AXIS_POS_GET(bind->joyaxis); } - snprintf(buf, size, "%s%c%u (%s) ", prefix, dir, axis, + snprintf(buf, size, "%s%c%u (%s)", prefix, dir, axis, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)); } } @@ -2490,6 +2610,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size) { + int delim = 0; #ifndef RARCH_CONSOLE char key[64]; char keybuf[64]; @@ -2507,21 +2628,81 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, else if (auto_bind && auto_bind->joyaxis != AXIS_NONE) input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size); + if (*buf) + delim = 1; + #ifndef RARCH_CONSOLE input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key)); if (string_is_equal(key, file_path_str(FILE_PATH_NUL))) *key = '\0'; /*empty?*/ - if ( *key != '\0' ) { - snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key); - strlcat(buf, keybuf, size); + if (*key != '\0') + { + if (delim ) + strlcat(buf, ", ", size); + snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key); + strlcat(buf, keybuf, size); + delim = 1; } #endif - /*completely empty?*/ - if ( *buf == '\0' ) { - strlcat(buf, "---", size); + if ( bind->mbutton != NO_BTN ) + { + int tag = 0; + switch ( bind->mbutton ) + { + case RETRO_DEVICE_ID_MOUSE_LEFT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT; + break; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT; + break; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN; + break; + } /* switch ( bind->mbutton ) */ + + if (tag != 0) + { + if (delim) + strlcat(buf, ", ", size); + strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size ); + } } + + /*completely empty?*/ + if ( *buf == '\0' ) + strlcat(buf, "---", size); +} + +unsigned input_config_get_device_count() +{ + unsigned num_devices; + for ( num_devices = 0; num_devices < MAX_INPUT_DEVICES; ++num_devices ) + { + const char *device_name = input_config_get_device_name(num_devices); + if ( string_is_empty(device_name) ) + break; + } + return num_devices; } const char *input_config_get_device_name(unsigned port) @@ -2538,12 +2719,15 @@ void input_config_set_device_name(unsigned port, const char *name) strlcpy(input_device_names[port], name, sizeof(input_device_names[port])); + + input_autoconfigure_joypad_reindex_devices(); } } void input_config_clear_device_name(unsigned port) { input_device_names[port][0] = '\0'; + input_autoconfigure_joypad_reindex_devices(); } unsigned *input_config_get_device_ptr(unsigned port) @@ -2578,7 +2762,8 @@ bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real) return true; } -const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id) +const struct retro_keybind *input_config_get_bind_auto( + unsigned port, unsigned id) { settings_t *settings = config_get_ptr(); unsigned joy_idx = settings->uints.input_joypad_map[port]; @@ -2620,7 +2805,7 @@ void input_config_reset(void) for (i = 1; i < MAX_USERS; i++) memcpy(input_config_binds[i], retro_keybinds_rest, sizeof(retro_keybinds_rest)); - + for (i = 0; i < MAX_USERS; i++) { input_config_vid[i] = 0; diff --git a/input/input_driver.h b/input/input_driver.h index d760e6fe43..1f7b711917 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -79,7 +79,7 @@ enum rarch_input_keyboard_ctl_state RARCH_INPUT_KEYBOARD_CTL_LINE_FREE, /* - * Waits for keys to be pressed (used for binding + * Waits for keys to be pressed (used for binding * keys in the menu). * Callback returns false when all polling is done. **/ @@ -96,19 +96,21 @@ struct retro_keybind enum msg_hash_enums enum_idx; enum retro_key key; - /* Joypad key. Joypad POV (hats) + uint16_t mbutton; + + /* Joypad key. Joypad POV (hats) * are embedded into this key as well. */ uint64_t joykey; - /* Default key binding value - + /* Default key binding value - * for resetting bind to default */ uint64_t def_joykey; - /* Joypad axis. Negative and positive axes + /* Joypad axis. Negative and positive axes * are embedded into this variable. */ uint32_t joyaxis; - /* Default joy axis binding value - + /* Default joy axis binding value - * for resetting bind to default */ uint32_t def_joyaxis; @@ -128,7 +130,7 @@ typedef struct rarch_joypad_info typedef struct input_driver { - /* Inits input driver. + /* Inits input driver. */ void *(*init)(const char *joypad_driver); @@ -172,7 +174,7 @@ struct rarch_joypad_driver bool (*query_pad)(unsigned); void (*destroy)(void); bool (*button)(unsigned, uint16_t); - uint64_t (*get_buttons)(unsigned); + void (*get_buttons)(unsigned, retro_bits_t *); int16_t (*axis)(unsigned, uint32_t); void (*poll)(void); bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t); @@ -187,7 +189,7 @@ struct hid_driver bool (*query_pad)(void *, unsigned); void (*free)(void *); bool (*button)(void *, unsigned, uint16_t); - uint64_t (*get_buttons)(void *, unsigned); + void (*get_buttons)(void *, unsigned, retro_bits_t *); int16_t (*axis)(void *, unsigned, uint32_t); void (*poll)(void *); bool (*set_rumble)(void *, unsigned, enum retro_rumble_effect, uint16_t); @@ -334,26 +336,6 @@ void input_poll(void); int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id); -#define RARCH_INPUT_STATE_BIT_SET(a,bit) ((a).data [((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) ((a)->data[((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET(a,bit) ((a).data [((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) ((a)->data[((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_CLEAR(a) memset(&a, 0, sizeof(a)); -#define RARCH_INPUT_STATE_CLEAR_PTR(a) memset(a, 0, sizeof(retro_bits_t)); -#define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ - ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) -#define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ - ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) -#define RARCH_INPUT_STATE_CLEAR_BITS(a,b) \ - ((a).data[0])&=(~((b).data[0])); \ - ((a).data[1])&=(~((b).data[1])); \ - ((a).data[2])&=(~((b).data[2])); \ - ((a).data[3])&=(~((b).data[3])); \ - ((a).data[4])&=(~((b).data[4])); \ - ((a).data[5])&=(~((b).data[5])); \ - ((a).data[6])&=(~((b).data[6])); \ - ((a).data[7])&=(~((b).data[7])); - void input_keys_pressed(void *data, retro_bits_t* new_state); #ifdef HAVE_MENU @@ -465,7 +447,7 @@ const char* config_get_joypad_driver_options(void); * * Initialize a joypad driver of name @ident. * - * If ident points to NULL or a zero-length string, + * If ident points to NULL or a zero-length string, * equivalent to calling input_joypad_init_first(). * * Returns: joypad driver if found, otherwise NULL. @@ -484,7 +466,7 @@ const input_device_driver_t *input_joypad_init_first(void *data); /** * input_conv_analog_id_to_bind_id: * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -523,7 +505,7 @@ static INLINE bool input_joypad_pressed( /* Auto-binds are per joypad, not per user. */ uint64_t joykey = (binds[key].joykey != NO_BTN) ? binds[key].joykey : joypad_info.auto_binds[key].joykey; - uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) + uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; if ((uint16_t)joykey != NO_BTN && drv->button(joypad_info.joy_idx, (uint16_t)joykey)) @@ -538,7 +520,7 @@ static INLINE bool input_joypad_pressed( * @drv : Input device driver handle. * @port : User number. * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * - RETRO_DEVICE_INDEX_ANALOG_BUTTON @@ -573,12 +555,12 @@ bool input_joypad_set_rumble(const input_device_driver_t *driver, unsigned port, enum retro_rumble_effect effect, uint16_t strength); /** - * input_joypad_axis_raw: + * input_joypad_axis_raw: * @drv : Input device driver handle. * @port : Joystick number. * @axis : Identifier of axis. * - * Checks if axis (@axis) was being pressed by user + * Checks if axis (@axis) was being pressed by user * with joystick number @port. * * Returns: true (1) if axis was pressed, otherwise @@ -606,7 +588,20 @@ bool input_joypad_hat_raw(const input_device_driver_t *driver, unsigned joypad, unsigned hat_dir, unsigned hat); /** - * input_joypad_name: + * input_mouse_button_raw: + * @port : Mouse number. + * @button : Identifier of key (libretro mouse constant). + * + * Checks if key (@button) was being pressed by user + * with mouse number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_mouse_button_raw(unsigned port, unsigned button); + +/** + * input_joypad_name: * @drv : Input device driver handle. * @port : Joystick number. * @@ -659,7 +654,7 @@ const hid_driver_t *input_hid_init_first(void); const void *hid_driver_get_data(void); #endif -/** Line complete callback. +/** Line complete callback. * Calls back after return is pressed with the completed line. * Line can be NULL. **/ @@ -696,8 +691,8 @@ bool input_keyboard_line_append(const char *word); * * Sets function pointer for keyboard line handle. * - * The underlying buffer can be reallocated at any time - * (or be NULL), but the pointer to it remains constant + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant * throughout the objects lifetime. * * Returns: underlying buffer of the keyboard line. @@ -744,7 +739,7 @@ const char *input_config_get_prefix(unsigned user, bool meta); * * Translate string representation to bind ID. * - * Returns: Bind ID value on success, otherwise + * Returns: Bind ID value on success, otherwise * RARCH_BIND_LIST_END on not found. **/ unsigned input_config_translate_str_to_bind_id(const char *str); @@ -759,10 +754,15 @@ void input_config_parse_joy_button(void *data, const char *prefix, void input_config_parse_joy_axis(void *data, const char *prefix, const char *axis, struct retro_keybind *bind); +void input_config_parse_mouse_button(void *data, const char *prefix, + const char *btn, struct retro_keybind *bind); + void input_config_set_device_name(unsigned port, const char *name); void input_config_clear_device_name(unsigned port); +unsigned input_config_get_device_count(); + unsigned *input_config_get_device_ptr(unsigned port); unsigned input_config_get_device(unsigned port); diff --git a/input/input_keymaps.c b/input/input_keymaps.c index ddd900a45f..ef4345e8c3 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -250,7 +250,7 @@ const struct input_key_map input_config_key_map[] = { { "rctrl", RETROK_RCTRL }, { "ralt", RETROK_RALT }, - /* Keys not referenced in any keyboard mapping + /* Keys not referenced in any keyboard mapping * (except perhaps rarch_key_map_apple_hid) */ { "caret", RETROK_CARET }, { "underscore", RETROK_UNDERSCORE }, @@ -932,7 +932,7 @@ const struct rarch_key_map rarch_key_map_x11[] = { /*{ ?, RETROK_POWER },*/ { XK_EuroSign, RETROK_EURO }, { XK_Undo, RETROK_UNDO }, - /* FIXME(shizeeg): RetroArch can't handle these buttons atm. + /* FIXME(shizeeg): RetroArch can't handle these buttons atm. * Do we really need RETROK_KP_INSERT, RETROK_KP_END, * RETROK_KP_DOWN, RETROK_KP_PAGEDOWN ??? * @@ -1681,7 +1681,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym) * @buf : Buffer. * @size : Size of @buf. * - * Translates a retro key identifier to a human-readable + * Translates a retro key identifier to a human-readable * identifier string. **/ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size) diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 1950436454..11757f2f68 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -42,7 +42,7 @@ struct apple_key_name_map_entry const char* const keyname; const uint32_t hid_id; }; - + extern const struct apple_key_name_map_entry apple_key_name_map[]; #endif @@ -86,7 +86,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); * @buf : Buffer. * @size : Size of @buf. * - * Translates a retro key identifier to a human-readable + * Translates a retro key identifier to a human-readable * identifier string. **/ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); diff --git a/input/input_mapper.c b/input/input_mapper.c index 0cfd365c30..decfea1716 100644 --- a/input/input_mapper.c +++ b/input/input_mapper.c @@ -127,9 +127,9 @@ void input_mapper_state( if (id < RETROK_LAST) { /* - RARCH_LOG("State: UDLR %u %u %u %u\n", - MAPPER_GET_KEY(handle, RETROK_UP), - MAPPER_GET_KEY(handle, RETROK_DOWN), + RARCH_LOG("State: UDLR %u %u %u %u\n", + MAPPER_GET_KEY(handle, RETROK_UP), + MAPPER_GET_KEY(handle, RETROK_DOWN), MAPPER_GET_KEY(handle, RETROK_LEFT), MAPPER_GET_KEY(handle, RETROK_RIGHT) );*/ diff --git a/input/input_mapper.h b/input/input_mapper.h index 500faab4a0..c50519acd8 100644 --- a/input/input_mapper.h +++ b/input/input_mapper.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Andrés Suárez - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/input_overlay.c b/input/input_overlay.c index 01bea5f40c..384d589015 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -40,7 +40,7 @@ typedef struct input_overlay_state { /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4]; + int16_t analog[4]; uint32_t keys[RETROK_LAST / 32 + 1]; /* This is a bitmask of (1 << key_bind_id). */ uint64_t buttons; @@ -144,7 +144,7 @@ static void input_overlay_set_vertex_geom(input_overlay_t *ol) void input_overlay_set_scale_factor(input_overlay_t *ol, float scale) { size_t i; - + if (!ol) return; @@ -231,7 +231,7 @@ static void input_overlay_enable(input_overlay_t *ol, bool enable) * Check whether the given @x and @y coordinates of the overlay * descriptor @desc is inside the overlay descriptor's hitbox. * - * Returns: true (1) if X, Y coordinates are inside a hitbox, otherwise false (0). + * Returns: true (1) if X, Y coordinates are inside a hitbox, otherwise false (0). **/ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) { @@ -250,7 +250,7 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) } case OVERLAY_HITBOX_RECT: - return + return (fabs(x - desc->x) <= desc->range_x_mod) && (fabs(y - desc->y) <= desc->range_y_mod); } @@ -348,7 +348,7 @@ static void input_overlay_poll( * input_overlay_update_desc_geom: * @ol : overlay handle. * @desc : overlay descriptors handle. - * + * * Update input overlay descriptors' vertex geometry. **/ static void input_overlay_update_desc_geom(input_overlay_t *ol, @@ -735,9 +735,9 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret, case RETRO_DEVICE_KEYBOARD: if (id < RETROK_LAST) { - /*RARCH_LOG("UDLR %u %u %u %u\n", - OVERLAY_GET_KEY(ol_state, RETROK_UP), - OVERLAY_GET_KEY(ol_state, RETROK_DOWN), + /*RARCH_LOG("UDLR %u %u %u %u\n", + OVERLAY_GET_KEY(ol_state, RETROK_UP), + OVERLAY_GET_KEY(ol_state, RETROK_DOWN), OVERLAY_GET_KEY(ol_state, RETROK_LEFT), OVERLAY_GET_KEY(ol_state, RETROK_RIGHT) );*/ @@ -765,7 +765,7 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret, * @port : the user to show the inputs of * * Adds inputs from current_input to the overlay, so it's displayed - * returns true if an input that is pressed will change the overlay + * returns true if an input that is pressed will change the overlay */ static bool input_overlay_add_inputs(input_overlay_t *ol, unsigned port, unsigned analog_dpad_mode) @@ -788,7 +788,7 @@ static bool input_overlay_add_inputs(input_overlay_t *ol, case OVERLAY_TYPE_BUTTONS: mask = desc->key_mask; id = RETRO_DEVICE_ID_JOYPAD_B; - /* Need to check all bits in the mask, + /* Need to check all bits in the mask, * multiple ones can be pressed */ current_button_pressed = false; while(mask) @@ -823,7 +823,7 @@ static bool input_overlay_add_inputs(input_overlay_t *ol, { float analog_x, analog_y; float dx, dy; - unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? + unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT; analog_x = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_X); diff --git a/input/input_overlay.h b/input/input_overlay.h index ba81955f38..cac2269388 100644 --- a/input/input_overlay.h +++ b/input/input_overlay.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -34,13 +34,13 @@ RETRO_BEGIN_DECLS #define KEY_ANALOG_LEFT 0x56b92e81U #define KEY_ANALOG_RIGHT 0x2e4dc654U -/* Overlay driver acts as a medium between input drivers +/* Overlay driver acts as a medium between input drivers * and video driver. * - * Coordinates are fetched from input driver, and an + * Coordinates are fetched from input driver, and an * overlay with pressable actions are displayed on-screen. * - * This interface requires that the video driver has support + * This interface requires that the video driver has support * for the overlay interface. */ @@ -236,7 +236,7 @@ void input_overlay_next(input_overlay_t *ol, float opacity); /* * input_poll_overlay: - * @ol : pointer to overlay + * @ol : pointer to overlay * * Poll pressed buttons/keys on currently active overlay. **/ diff --git a/input/input_remapping.c b/input/input_remapping.c index 68e0d7363e..5830565e09 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "input_driver.h" @@ -90,15 +91,15 @@ bool input_remapping_load_file(void *data, const char *path) if (config_get_int(conf, keymapper_ident[j], &key_remap)) { settings->uints.input_keymapper_ids[j] = key_remap; -#if 0 +#if 0 RARCH_LOG ("%s: %u\n", keymapper_ident[j], settings->uints.input_keymapper_ids[j]); #endif } - else + else settings->uints.input_keymapper_ids[j] = RETROK_UNKNOWN; } - - + + } for (j = 0; j < 4; j++) @@ -241,10 +242,10 @@ bool input_remapping_remove_file(const char *path) fill_pathname_noext(remap_file, buf, ".rmp", path_size); - ret = path_file_remove(remap_file) == 0 ? true : false;; + ret = filestream_delete(remap_file) == 0 ? true : false; free(buf); free(remap_file); - return ret; + return ret; } void input_remapping_set_defaults(bool deinit) @@ -252,7 +253,7 @@ void input_remapping_set_defaults(bool deinit) unsigned i, j; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - + if (!global) return; @@ -273,7 +274,7 @@ void input_remapping_set_defaults(bool deinit) if (keybind) settings->uints.input_remap_ids[i][j] = keybind->id; settings->uints.input_keymapper_ids[j] = RETROK_UNKNOWN; - + } for (j = 0; j < 4; j++) settings->uints.input_remap_ids[i][RARCH_FIRST_CUSTOM_BIND + j] = j; diff --git a/input/input_remote.c b/input/input_remote.c index e66b8f5ae0..d74529c7d2 100644 --- a/input/input_remote.c +++ b/input/input_remote.c @@ -66,7 +66,7 @@ struct input_remote typedef struct input_remote_state { /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4][MAX_USERS]; + int16_t analog[4][MAX_USERS]; /* This is a bitmask of (1 << key_bind_id). */ uint64_t buttons[MAX_USERS]; } input_remote_state_t; @@ -230,7 +230,7 @@ void input_remote_poll(input_remote_t *handle, unsigned max_users) unsigned user; settings_t *settings = config_get_ptr(); input_remote_state_t *input_state = input_remote_get_state_ptr(); - + for(user = 0; user < max_users; user++) { if (settings->bools.network_remote_enable_user[user]) diff --git a/input/input_remote.h b/input/input_remote.h index 861cea9149..a80185a724 100644 --- a/input/input_remote.h +++ b/input/input_remote.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 142ffad5d7..8879be108e 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "编译器" ) @@ -682,6 +682,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右摇杆Y- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右摇杆Y+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "启用自动配置") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -744,6 +766,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y键(左侧)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(键: %s)") /*FIXME:"(Key: %s)"*/ +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "键盘控制器映射类型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3161,3 +3201,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 9e13d1de7d..33c9c5947d 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "編譯器" ) @@ -682,6 +682,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右搖桿Y- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右搖桿Y+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "啟用自動設定") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -744,6 +766,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y鍵(左側)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(鍵: %s)") /*FIXME:"(Key: %s)"*/ +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "鍵盤控制器映射類型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3161,3 +3201,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_de.c b/intl/msg_hash_de.c index 333f191a49..6f56a0dd5a 100644 --- a/intl/msg_hash_de.c +++ b/intl/msg_hash_de.c @@ -904,13 +904,19 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) break; case MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS: snprintf(s, len, + " \n" + ); + { + /* Work around C89 limitations */ + const char * t = "Für diesen durchgang skalieren. \n" " \n" "Der Skalierungsfaktor wird multipliziert, \n" "d.h. 2x im ersten durchgang und 2x im \n" "zweiten durchgang bedeute eine 4x Gesamt- \n" "Skalierung." - " \n" + " \n"; + const char * u = "Wenn es im letzten durchgang einen \n" "Skalierungsfaktor gibt, wird das Ergebnis \n" "mit dem als 'Standardfilter' eingestellten \n" @@ -919,8 +925,10 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Wenn 'Ignorieren' eingestellt ist, wird \n" "entweder einfache Skalierung oder Vollbild- \n" "Streckung verwendet - abhängig davon, ob \n" - "es der letzte durchgang ist oder nicht." - ); + "es der letzte durchgang ist oder nicht."; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES: snprintf(s, len, @@ -1133,7 +1141,9 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Verwendet für Inhalt, der auf mehreren Datenträgern ausgeliefert wird. "); break; case MENU_ENUM_LABEL_ENABLE_HOTKEY: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Andere Tastenkürzel aktivieren. \n" " \n" "Wenn dieses Tastenkürzel entweder einer\n" @@ -1141,14 +1151,18 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Controller-Achse zugeordnet ist, werden alle \n" "anderen Tastenkürzel nur aktiviert, wenn dieses \n" "Tastenkürzel zur gleichen Zeit gehalten wird. \n" - " \n" + " \n"; + const char * u = "Dies ist hilfreich für Implementierungen, die auf \n" "RETRO_KEYBOARD ausgelegt sind und eine große \n" "Fläche auf der Tastatur benötigen, wo es nicht \n" "gewünscht ist, dass es zu Kollisionen mit Tastenkürzeln kommt \n." " \n" "Alternativ können auch alle Tastatur-Kürzel durch \n" - "den Benutzer deaktiviert werden."); + "den Benutzer deaktiviert werden."; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_REWIND_ENABLE: snprintf(s, len, @@ -1165,7 +1179,9 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Libretro-Core-Implementierungen gesucht wird."); break; case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Bildwiederholrate.\n" " \n" "Die genaue Bildwiederholrate deines Bildschirms (Hz).\n" @@ -1174,14 +1190,19 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "audio_input_rate = Spiel-Eingaberate * Bildschirm- \n" "Wiederholrate / Spiel-Wiederholrate\n" - " \n" + " \n"; + const char * u = "Wenn die Implementierung keinen Wert liefert, \n" "werden aus Kompatiblitätsgründen die Werte für NTSC \n" "angenommen.\n" " \n" "Dieser Wert sollte nahe 60Hz liegen, um Tonsprünge zu vermeiden. \n" "Wenn dein Bildschirm nicht auf 60Hz oder einem ähnlichen Wert läuft, \n" - "deaktiviere VSync und lasse diese Einstellung unverändert. \n"); + "deaktiviere VSync und lasse diese Einstellung unverändert. \n"; + ; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_VIDEO_ROTATION: snprintf(s, len, @@ -1594,20 +1615,26 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "tritt keine Netplay-Verzögerung auf.\n"); break; case MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Die Frequenz in Einzelbildern, mit der Netplay \n" "sicherstellen wird, dass Host und Clients \n" "synchronisiert sind. \n" " \n" - "Bei den meisten Cores wird diese Einstellungen \n" - "keine sichtbaren Auswirkungen haben und kann ignoriert werden. \n" - "Bei nichtdeterministischen Cores legt dieser Wert fest, \n" - "wie oft die Netplay-Mitglieder miteinander synchronisiert \n" - "werden. Bei fehlerhaften Cores wird ein \n" - "anderer Wert als 0 für diese Einstellung erhebliche \n" - "Leistungsprobleme verursachen. Auf 0 setzen, um keine \n" - "Überprüfungen durchzuführen. Diese Einstellung wird nur \n" - "auf dem Netplay-Host verwendet. \n"); + "Bei den meisten Cores wird diese Einstellungen \n" + "keine sichtbaren Auswirkungen haben und kann ignoriert werden. \n"; + const char *u = + "Bei nichtdeterministischen Cores legt dieser Wert fest, \n" + "wie oft die Netplay-Mitglieder miteinander synchronisiert \n" + "werden. Bei fehlerhaften Cores wird ein \n" + "anderer Wert als 0 für diese Einstellung erhebliche \n" + "Leistungsprobleme verursachen. Auf 0 setzen, um keine \n" + "Überprüfungen durchzuführen. Diese Einstellung wird nur \n" + "auf dem Netplay-Host verwendet. \n"; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN: snprintf(s, len, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 44c710daff..26ac4331ac 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -687,6 +687,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Rechter Analogstick Y- (nach oben)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Rechter Analogstick Y+ (nach unten)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Automatische Konfiguration aktivieren") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -751,6 +773,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y-Knopf (links)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Taste: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Typ der Keyboard-Controller-Abbildung") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3271,3 +3311,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_BLUE, "Blau-Anteil der Bildschirmmeldungen") MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, "Zeige die aktuelle Anzahl an Einzelbildern an") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index c17db311bb..d5d1d0258b 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -598,6 +598,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfig Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -660,6 +682,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3024,3 +3064,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index fa1094a768..7fe0883274 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -681,6 +681,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analogique droit Y- (haut)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analogique droit Y+ (bas)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Activer l'autoconfiguration") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -745,6 +767,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Bouton Y (gauche)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Touche : %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Type de mappage manette/clavier") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3193,3 +3233,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 2ebdad385b..d6b420f08b 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -687,6 +687,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analogico Destro Y- (su)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analogico Destro Y+ (giù)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Abilita Autoconfigurazione") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -751,6 +773,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Pulsante Y (sinistro)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tasto: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo di mappatura del gamepad della tastiera") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3251,3 +3291,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password corretta.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password non corretta.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Aggiungi automaticamente il contenuto alla playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Esegue automaticamente la scansione dei contenuti caricati in modo che vengano visualizzati all'interno delle playlist.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scansione del file completata") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 3c772118af..ab498da29b 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -1,4 +1,4 @@ -#if defined(_MSC_VER) && !defined(_XBOX) +#if defined(_MSC_VER) && !defined(_XBOX) /* https://support.microsoft.com/en-us/kb/980263 */ #pragma execution_character_set("utf-8") #endif @@ -438,6 +438,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_HARDCORE_MODE_ENABLE, "ハードコアモード" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_LEADERBOARDS_ENABLE, + "ランキング" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_BADGES_ENABLE, + "実績バッジ" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_LOCKED_ACHIEVEMENTS, "解除された実績:" @@ -466,6 +474,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY, "解除されている" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY_HARDCORE, + "解除されている(ハードコア)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CLOSE_CONTENT, "閉じる" @@ -705,6 +717,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右アナログY- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右アナログY+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "自動コンフィグを有効") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -769,6 +803,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Yボタン(左)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(キー: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "キーボードのゲームパッドマッピング式") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -2474,6 +2526,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "ボケ") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "スノーフレーク") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "ルーム表を更新") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, @@ -3203,3 +3257,11 @@ MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, "ゲームの優先ファイルをロードしました。") MSG_HASH(MSG_CORE_REMAP_FILE_LOADED, "コアの優先ファイルをロードしました。") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + "ウィンドウの不透明性") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index f4e980e451..46c001d5aa 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "컴파일러" ) @@ -669,6 +669,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "우 아날로그 Y- (상)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "우 아날로그 Y+ (하)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "자동설정 사용") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -731,6 +753,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y 버튼 (좌)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(키: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "키보드 게임패드 설정 형식") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3156,3 +3196,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 32cd47b828..bc5721bce0 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1375,3 +1375,7 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE, "video_msg_color_blue") MSG_HASH(MENU_ENUM_LABEL_FRAMECOUNT_SHOW, "framecount_show") +MSG_HASH(MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "automatically_add_content_to_playlist") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, + "video_window_opacity") diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index d414566d66..f2a3b58f4b 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -598,6 +598,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfiguratie Activeren") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -660,6 +682,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y knop (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -2273,6 +2313,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "Bokeh") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "Sneeuwvlok") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, @@ -3024,3 +3066,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Wachtwoord correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Verkeerde wachtwoord.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_pl.c b/intl/msg_hash_pl.c index a20415a68d..6aceda10d8 100644 --- a/intl/msg_hash_pl.c +++ b/intl/msg_hash_pl.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms diff --git a/intl/msg_hash_pt_br.c b/intl/msg_hash_pt_br.c index 37f690c57d..3f60fba684 100644 --- a/intl/msg_hash_pt_br.c +++ b/intl/msg_hash_pt_br.c @@ -28,7 +28,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) { uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); - + if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) { snprintf(s, len, @@ -36,7 +36,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) ); return 0; } - + if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN) { unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN; @@ -1069,7 +1069,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) case MENU_ENUM_LABEL_LIBRETRO_LOG_LEVEL: snprintf(s, len, "Define o nível de registro de eventos dos \n" - "núcleos libretro. (GET_LOG_INTERFACE) \n" + "núcleos libretro. (GET_LOG_INTERFACE) \n" " \n" " Se o nível do registro de evento emitido \n" " pelo núcleo libretro for abaixo do nível \n" @@ -1491,7 +1491,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) case MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL: snprintf(s, len, "Intervalo de Troca da Sincronia Vertical \n" - "(V-Sync). \n" + "(V-Sync). \n" " \n" "Usa um intervalo de troca personalizado \n" "para V-Sync. Defina para reduzir \n" @@ -1583,7 +1583,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Habilitar controle do menu por toque."); break; case MENU_ENUM_LABEL_MENU_WALLPAPER: - snprintf(s, len, + snprintf(s, len, "Selecionar uma imagem para definir como \n" "plano de fundo."); break; @@ -2059,7 +2059,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Você pode alterar a transparência de \n" "gamepad virtual indo em \n" - "'%s' -> '%s'. \n" + "'%s' -> '%s'. \n" " \n" "De lá você pode alterar a transparência, \n" "mudar o tamanho e opacidade dos botões, etc. \n" diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index dcaeaebd75..c2b0ae58f5 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -661,6 +661,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analógico Direito Y+ (baixo)" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gatinho da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Recarregar Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Aux A da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Aux B da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Aux C da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Start da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Select da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "D-pad Cima da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "D-pad Baixo da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "D-pad Esquerdo da Pistola") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "D-pad Direito da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Habilitar Autoconfiguração" ) @@ -757,6 +779,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Roda do Mouse para Cima") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Roda do Mouse para Baixo") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Roda do Mouse para Esquerda") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Roda do Mouse para Diretira") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento para Gamepad no Teclado" ) @@ -857,10 +897,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, "Câmera Lenta" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, - "Posição do Estado de Jogo -" + "Compartimento do Estado de Jogo -" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, - "Posição do Estado de Jogo +" + "Compartimento do Estado de Jogo +" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, "Volume -" @@ -1664,7 +1704,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_START_VIDEO_PROCESSOR, "Iniciar Processador de Vídeo" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_STATE_SLOT, - "Posição do Estado de Jogo" + "Compartimento do Estado de Jogo" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_STATUS, "Condição" @@ -2735,7 +2775,7 @@ MSG_HASH(MSG_FOUND_FIRST_DATA_TRACK_ON_FILE, "Encontrada primeira faixa de dados no arquivo" ) MSG_HASH(MSG_FOUND_LAST_STATE_SLOT, - "Encontrada última posição de Estado de Jogo" + "Encontrada último compartimento de Estado de Jogo" ) MSG_HASH(MSG_FOUND_SHADER, "Shader encontrado" @@ -2804,10 +2844,10 @@ MSG_HASH(MSG_LIBRETRO_FRONTEND, "Frontend para Libretro" ) MSG_HASH(MSG_LOADED_STATE_FROM_SLOT, - "Estado de Jogo carregado da posição #%d." + "Estado de Jogo carregado do compartimento #%d." ) MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, - "Estado de Jogo carregado da posição #-1 (automático)." + "Estado de Jogo carregado do compartimento #-1 (automático)." ) MSG_HASH(MSG_LOADING, "Carregando" @@ -2933,10 +2973,10 @@ MSG_HASH(MSG_SAVED_NEW_CONFIG_TO, "Nova configuração salva em" ) MSG_HASH(MSG_SAVED_STATE_TO_SLOT, - "Estado de Jogo salvo na posição #%d." + "Estado de Jogo salvo no compartimento #%d." ) MSG_HASH(MSG_SAVED_STATE_TO_SLOT_AUTO, - "Estado de Jogo salvo na posição #-1 (automático)." + "Estado de Jogo salvo no compartimento #-1 (automático)." ) MSG_HASH(MSG_SAVED_SUCCESSFULLY_TO, "Salvo com sucesso em" @@ -2990,7 +3030,7 @@ MSG_HASH(MSG_STATE_SIZE, "Tamanho do Estado de Jogo" ) MSG_HASH(MSG_STATE_SLOT, - "Posição do Estado de Jogo" + "Compartimento do Estado de Jogo" ) MSG_HASH(MSG_TAKING_SCREENSHOT, "Fazendo captura de tela" @@ -3596,10 +3636,10 @@ MSG_HASH(MENU_ENUM_SUBLABEL_CLOSE_CONTENT, "Fecha o conteúdo atual. Alterações não salvas serão perdidas." ) MSG_HASH(MENU_ENUM_SUBLABEL_LOAD_STATE, - "Carregar um Estado de Jogo da posição selecionado atualmente." + "Carregar um Estado de Jogo do compartimento selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_SAVE_STATE, - "Salvar um Estado de Jogo na posição selecionado atualmente." + "Salvar um Estado de Jogo no compartimento selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_RESUME, "Retomar a execução do conteúdo atual e sair do Menu Rápido." @@ -3608,7 +3648,7 @@ MSG_HASH(MENU_ENUM_SUBLABEL_RESUME_CONTENT, "Retomar a execução do conteúdo atual e sair do Menu Rápido." ) MSG_HASH(MENU_ENUM_SUBLABEL_STATE_SLOT, - "Altera a posição do Estado de Jogo selecionado atualmente." + "Altera o compartimento do Estado de Jogo selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_UNDO_LOAD_STATE, "Se um Estado de Jogo for carregado, o conteúdo voltará ao estado anterior ao carregamento." @@ -4141,3 +4181,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 800463bdc5..b48e9717cd 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -669,6 +669,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analógico Direito Y- (cima)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analógico Direito Y+ (baixo)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Habilitar Auto-configuração") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -731,6 +753,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Botão Y (esquerda)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento do Gamepad no Teclado") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3131,3 +3171,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_ru.c b/intl/msg_hash_ru.c index 6bfec695cc..9a48e61b7e 100644 --- a/intl/msg_hash_ru.c +++ b/intl/msg_hash_ru.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index f2e9a9826a..4eac6397c2 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -1,4 +1,4 @@ -#if defined(_MSC_VER) && !defined(_XBOX) +#if defined(_MSC_VER) && !defined(_XBOX) /* https://support.microsoft.com/en-us/kb/980263 */ #pragma execution_character_set("utf-8") #endif @@ -690,6 +690,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Правый аналоговый стик - ось Y- (вверх)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Правый аналоговый стик - ось Y+ (вниз)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Автоматическая настройка включена") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -754,6 +776,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Кнопка Y") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Клавиша: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Тип отображения клавиатуры для геймпада") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3214,3 +3254,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Пароль верен.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Пароль неверен.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 1cbd3d133f..e7ad35b7cc 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -699,6 +699,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfig Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -763,6 +785,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -2502,6 +2542,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "Bokeh") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "Snowflake") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, @@ -3293,3 +3335,11 @@ MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, "Game remap file loaded.") MSG_HASH(MSG_CORE_REMAP_FILE_LOADED, "Core remap file loaded.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + "Window Opacity") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index ca95e43315..9c68ac8d89 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "Compiler" ) @@ -681,6 +681,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Kích hoạt Autoconfig") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, @@ -743,6 +765,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "Mouse 1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "Mouse 2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "Mouse 3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "Mouse 4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "Mouse 5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "Wheel Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "Wheel Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "Wheel Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, @@ -3185,3 +3225,9 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/lakka.h b/lakka.h index f1659d2ef8..60d117cbdb 100644 --- a/lakka.h +++ b/lakka.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2014-2016 - Jean-André Santoni - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/libretro-common/audio/audio_mix.c b/libretro-common/audio/audio_mix.c index ac1dc1e25d..bd40ccb63c 100644 --- a/libretro-common/audio/audio_mix.c +++ b/libretro-common/audio/audio_mix.c @@ -56,7 +56,7 @@ void audio_mix_volume_SSE2(float *out, const float *in, float vol, size_t sample unsigned j; __m128 input[4]; __m128 additive[4]; - + input[0] = _mm_loadu_ps(out + 0); input[1] = _mm_loadu_ps(out + 4); input[2] = _mm_loadu_ps(out + 8); @@ -132,7 +132,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate) goto error; } - /* numsamples does not know or care about + /* numsamples does not know or care about * multiple channels, but we need space for 2 */ chunk->upsample_buf = (int16_t*)memalign_alloc(128, chunk->rwav->numsamples * 2 * sizeof(int16_t)); @@ -204,7 +204,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate) info.data_in = (const float*)chunk->float_buf; info.data_out = chunk->float_resample_buf; - /* a 'frame' consists of two channels, so we set this + /* a 'frame' consists of two channels, so we set this * to the number of samples irrespective of channel count */ info.input_frames = chunk->rwav->numsamples; info.output_frames = 0; diff --git a/libretro-common/audio/audio_mixer.c b/libretro-common/audio/audio_mixer.c index e6bc09eff2..3e912cb974 100644 --- a/libretro-common/audio/audio_mixer.c +++ b/libretro-common/audio/audio_mixer.c @@ -57,7 +57,7 @@ struct audio_mixer_sound { enum audio_mixer_type type; - + union { struct @@ -66,7 +66,7 @@ struct audio_mixer_sound unsigned frames; const float* pcm; } wav; - + #ifdef HAVE_STB_VORBIS struct { @@ -94,14 +94,14 @@ struct audio_mixer_voice float volume; audio_mixer_sound_t *sound; audio_mixer_stop_cb_t stop_cb; - + union { struct { unsigned position; } wav; - + #ifdef HAVE_STB_VORBIS struct { @@ -142,12 +142,12 @@ static bool wav2float(const rwav_t* wav, float** pcm, size_t samples_out) /* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes */ float *f = (float*)memalign_alloc(16, ((samples_out + 15) & ~15) * sizeof(float)); - + if (!f) return false; - + *pcm = f; - + if (wav->bitspersample == 8) { float sample = 0.0f; @@ -221,7 +221,7 @@ static bool one_shot_resample(const float* in, size_t samples_in, if (!retro_resampler_realloc(&data, &resampler, NULL, ratio)) return false; - + /* * Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We * add four more samples in the formula below just as safeguard, because @@ -233,7 +233,7 @@ static bool one_shot_resample(const float* in, size_t samples_in, *samples_out = samples_in * ratio + 4; *out = (float*)memalign_alloc(16, ((*samples_out + 15) & ~15) * sizeof(float)); - + if (*out == NULL) return false; @@ -251,12 +251,12 @@ static bool one_shot_resample(const float* in, size_t samples_in, void audio_mixer_init(unsigned rate) { unsigned i; - + s_rate = rate; - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++) s_voices[i].type = AUDIO_MIXER_TYPE_NONE; - + #ifdef HAVE_THREADS s_locker = slock_new(); #endif @@ -265,13 +265,13 @@ void audio_mixer_init(unsigned rate) void audio_mixer_done(void) { unsigned i; - + #ifdef HAVE_THREADS /* Dont call audio mixer functions after this point */ slock_free(s_locker); s_locker = NULL; #endif - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++) s_voices[i].type = AUDIO_MIXER_TYPE_NONE; } @@ -289,12 +289,12 @@ audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size) if (rwav_ret != RWAV_ITERATE_DONE) return NULL; - + samples = wav.numsamples * 2; - + if (!wav2float(&wav, &pcm, samples)) return NULL; - + if (wav.samplerate != s_rate) { float* resampled = NULL; @@ -302,23 +302,23 @@ audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size) if (!one_shot_resample(pcm, samples, wav.samplerate, &resampled, &samples)) return NULL; - + memalign_free((void*)pcm); pcm = resampled; } - + sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); - + if (!sound) { memalign_free((void*)pcm); return NULL; } - + sound->type = AUDIO_MIXER_TYPE_WAV; sound->types.wav.frames = (unsigned)(samples / 2); sound->types.wav.pcm = pcm; - + rwav_free(&wav); return sound; @@ -328,14 +328,14 @@ audio_mixer_sound_t* audio_mixer_load_ogg(void *buffer, int32_t size) { #ifdef HAVE_STB_VORBIS audio_mixer_sound_t* sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); - + if (!sound) return NULL; sound->type = AUDIO_MIXER_TYPE_OGG; sound->types.ogg.size = size; sound->types.ogg.data = buffer; - + return sound; #else return NULL; @@ -390,7 +390,7 @@ void audio_mixer_destroy(audio_mixer_sound_t* sound) case AUDIO_MIXER_TYPE_NONE: break; } - + free(sound); } @@ -424,11 +424,11 @@ static bool audio_mixer_play_ogg( return false; info = stb_vorbis_get_info(stb_vorbis); - + if (info.sample_rate != s_rate) { ratio = (double)s_rate / (double)info.sample_rate; - + if (!retro_resampler_realloc(&resampler_data, &resamp, NULL, ratio)) goto error; @@ -538,7 +538,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, if (!sound) return NULL; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif @@ -569,7 +569,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, break; } - + if (res) { voice->type = sound->type; @@ -592,22 +592,22 @@ void audio_mixer_stop(audio_mixer_voice_t* voice) { audio_mixer_stop_cb_t stop_cb = NULL; audio_mixer_sound_t* sound = NULL; - + if (voice) { stop_cb = voice->stop_cb; sound = voice->sound; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif voice->type = AUDIO_MIXER_TYPE_NONE; - + #ifdef HAVE_THREADS slock_unlock(s_locker); #endif - + if (stop_cb) stop_cb(sound, AUDIO_MIXER_SOUND_STOPPED); } @@ -620,11 +620,11 @@ static void audio_mixer_mix_wav(float* buffer, size_t num_frames, int i; unsigned buf_free = (unsigned)(num_frames * 2); const audio_mixer_sound_t* sound = voice->sound; - unsigned pcm_available = sound->types.wav.frames + unsigned pcm_available = sound->types.wav.frames * 2 - voice->types.wav.position; - const float* pcm = sound->types.wav.pcm + + const float* pcm = sound->types.wav.pcm + voice->types.wav.position; - + again: if (pcm_available < buf_free) { @@ -668,7 +668,7 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames, unsigned buf_free = num_frames * 2; unsigned temp_samples = 0; float* pcm = NULL; - + if (voice->types.ogg.position == voice->types.ogg.samples) { again: @@ -790,7 +790,7 @@ again: else { int i; - for (i = buf_free; i != 0; --i ) + for (i = buf_free; i != 0; --i ) { samplei = *pcm++ * volume; samplef = (float)((int)samplei + 32768) / 65535.0f; @@ -810,11 +810,11 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo size_t j = 0; float* sample = NULL; audio_mixer_voice_t* voice = s_voices; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++) { float volume = (override) ? volume_override : voice->volume; @@ -838,11 +838,11 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo break; } } - + #ifdef HAVE_THREADS slock_unlock(s_locker); #endif - + for (j = 0, sample = buffer; j < num_frames; j++, sample++) { if (*sample < -1.0f) diff --git a/libretro-common/audio/conversion/float_to_s16.c b/libretro-common/audio/conversion/float_to_s16.c index 3010cb798a..bb97945971 100644 --- a/libretro-common/audio/conversion/float_to_s16.c +++ b/libretro-common/audio/conversion/float_to_s16.c @@ -42,7 +42,7 @@ void convert_float_s16_asm(int16_t *out, const float *in, size_t samples); * @in : input buffer * @samples : size of samples to be converted * - * Converts floating point + * Converts floating point * to signed integer 16-bit. * * C implementation callback function. @@ -72,7 +72,7 @@ void convert_float_to_s16(int16_t *out, #elif defined(__ALTIVEC__) int samples_in = samples; - /* Unaligned loads/store is a bit expensive, + /* Unaligned loads/store is a bit expensive, * so we optimize for the good path (very likely). */ if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0) { @@ -106,7 +106,7 @@ void convert_float_to_s16(int16_t *out, #elif defined(_MIPS_ARCH_ALLEGREX) #ifdef DEBUG - /* Make sure the buffers are 16 byte aligned, this should be + /* Make sure the buffers are 16 byte aligned, this should be * the default behaviour of malloc in the PSPSDK. * Assume alignment. */ retro_assert(((uintptr_t)in & 0xf) == 0); diff --git a/libretro-common/audio/conversion/s16_to_float.c b/libretro-common/audio/conversion/s16_to_float.c index ff727913d3..814ddd8261 100644 --- a/libretro-common/audio/conversion/s16_to_float.c +++ b/libretro-common/audio/conversion/s16_to_float.c @@ -73,7 +73,7 @@ void convert_s16_to_float(float *out, #elif defined(__ALTIVEC__) size_t samples_in = samples; - /* Unaligned loads/store is a bit expensive, so we + /* Unaligned loads/store is a bit expensive, so we * optimize for the good path (very likely). */ if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0) { @@ -115,7 +115,7 @@ void convert_s16_to_float(float *out, #elif defined(_MIPS_ARCH_ALLEGREX) #ifdef DEBUG - /* Make sure the buffer is 16 byte aligned, this should be the + /* Make sure the buffer is 16 byte aligned, this should be the * default behaviour of malloc in the PSPSDK. * Only the output buffer can be assumed to be 16-byte aligned. */ retro_assert(((uintptr_t)out & 0xf) == 0); @@ -169,7 +169,7 @@ void convert_s16_to_float(float *out, gain = gain / 0x8000; for (; i < samples; i++) - out[i] = (float)in[i] * gain; + out[i] = (float)in[i] * gain; } /** diff --git a/libretro-common/audio/dsp_filter.c b/libretro-common/audio/dsp_filter.c index 0b695ec87e..7f428eee12 100644 --- a/libretro-common/audio/dsp_filter.c +++ b/libretro-common/audio/dsp_filter.c @@ -186,7 +186,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) dspfilter_get_implementation_t cb; const struct dspfilter_implementation *impl = NULL; struct retro_dsp_plug *new_plugs = NULL; - dylib_t lib = + dylib_t lib = dylib_load(list->elems[i].data); if (!lib) @@ -221,7 +221,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) } /* Found plug. */ - + dsp->plugs = new_plugs; dsp->plugs[dsp->num_plugs].lib = lib; dsp->plugs[dsp->num_plugs].impl = impl; @@ -233,7 +233,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) #endif retro_dsp_filter_t *retro_dsp_filter_new( - const char *filter_config, + const char *filter_config, void *string_data, float sample_rate) { diff --git a/libretro-common/audio/dsp_filters/chorus.c b/libretro-common/audio/dsp_filters/chorus.c index d48c346fb0..54d9aa715a 100644 --- a/libretro-common/audio/dsp_filters/chorus.c +++ b/libretro-common/audio/dsp_filters/chorus.c @@ -88,7 +88,7 @@ static void chorus_process(void *data, struct dspfilter_output *output, r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; - /* Lerp introduces aliasing of the chorus component, + /* Lerp introduces aliasing of the chorus component, * but doing full polyphase here is probably overkill. */ chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; diff --git a/libretro-common/audio/dsp_filters/eq.c b/libretro-common/audio/dsp_filters/eq.c index 4033aa6512..a3defe77e1 100644 --- a/libretro-common/audio/dsp_filters/eq.c +++ b/libretro-common/audio/dsp_filters/eq.c @@ -149,7 +149,7 @@ static void generate_response(fft_complex_t *response, gains++; } - /* Create a response by linear interpolation between + /* Create a response by linear interpolation between * known frequency sample points. */ for (i = 0; i <= samples; i++) { @@ -213,9 +213,9 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, fft_process_inverse(fft, time_filter, eq->filter, 1); /* ifftshift() to create the correct linear phase filter. - * The filter response was designed with zero phase, which + * The filter response was designed with zero phase, which * won't work unless we compensate - * for the repeating property of the FFT here + * for the repeating property of the FFT here * by flipping left and right blocks. */ for (i = 0; i < half_block_size; i++) { diff --git a/libretro-common/audio/dsp_filters/iir.c b/libretro-common/audio/dsp_filters/iir.c index 801e908569..748d0b8c1e 100644 --- a/libretro-common/audio/dsp_filters/iir.c +++ b/libretro-common/audio/dsp_filters/iir.c @@ -212,7 +212,7 @@ static void iir_filter_init(struct iir_data *iir, a1 = -2.0 * cs; a2 = 1.0 - a1pha; break; - case NOTCH: + case NOTCH: b0 = 1.0; b1 = -2.0 * cs; b2 = 1.0; @@ -253,7 +253,7 @@ static void iir_filter_init(struct iir_data *iir, make_poly_from_roots(zeros, 2, b); make_poly_from_roots(poles, 2, a); } - + b0 = b[0]; b1 = b[1]; b2 = b[2]; @@ -272,15 +272,15 @@ static void iir_filter_init(struct iir_data *iir, b0 *= g; b1 *= g; b2 *= g; break; } - case PEQ: + case PEQ: b0 = 1.0 + a1pha * A; b1 = -2.0 * cs; b2 = 1.0 - a1pha * A; a0 = 1.0 + a1pha / A; a1 = -2.0 * cs; a2 = 1.0 - a1pha / A; - break; - case BBOOST: + break; + case BBOOST: beta = sqrt((A * A + 1) / 1.0 - (pow((A - 1), 2))); b0 = A * ((A + 1) - (A - 1) * cs + beta * sn); b1 = 2 * A * ((A - 1) - (A + 1) * cs); diff --git a/libretro-common/audio/dsp_filters/panning.c b/libretro-common/audio/dsp_filters/panning.c index 52935bb88e..da1cbc3d10 100644 --- a/libretro-common/audio/dsp_filters/panning.c +++ b/libretro-common/audio/dsp_filters/panning.c @@ -76,7 +76,7 @@ static void *panning_init(const struct dspfilter_info *info, config->get_float_array(userdata, "right_mix", &right, &num_right, default_right, 2); - memcpy(pan->left, (num_left == 2) ? + memcpy(pan->left, (num_left == 2) ? left : default_left, sizeof(pan->left)); memcpy(pan->right, (num_right == 2) ? right : default_right, sizeof(pan->right)); diff --git a/libretro-common/audio/resampler/audio_resampler.c b/libretro-common/audio/resampler/audio_resampler.c index a7cc0c2f47..0a4b8b3ff8 100644 --- a/libretro-common/audio/resampler/audio_resampler.c +++ b/libretro-common/audio/resampler/audio_resampler.c @@ -146,7 +146,7 @@ static bool resampler_append_plugs(void **re, * @ident : Identifier name for resampler we want. * @bw_ratio : Bandwidth ratio. * - * Reallocates resampler. Will free previous handle before + * Reallocates resampler. Will free previous handle before * allocating a new one. If ident is NULL, first resampler will be used. * * Returns: true (1) if successful, otherwise false (0). diff --git a/libretro-common/audio/resampler/drivers/nearest_resampler.c b/libretro-common/audio/resampler/drivers/nearest_resampler.c index c5244851a6..65ced854f6 100644 --- a/libretro-common/audio/resampler/drivers/nearest_resampler.c +++ b/libretro-common/audio/resampler/drivers/nearest_resampler.c @@ -23,14 +23,14 @@ #include #include #include - + #include