From 6904101c4430b8cd213453fbfb0480838ccc958e Mon Sep 17 00:00:00 2001 From: gblues Date: Mon, 11 Dec 2017 23:55:31 -0800 Subject: [PATCH] Clean up trailing whitespace == DETAILS Really simple code cleanup, because my editor flags trailing whitespaces and it's pretty annoying. --- audio/audio_driver.c | 76 +- audio/audio_driver.h | 6 +- audio/audio_thread_wrapper.c | 10 +- audio/audio_thread_wrapper.h | 2 +- audio/drivers/alsa.c | 4 +- audio/drivers/alsa_qsa.c | 10 +- audio/drivers/alsathread.c | 6 +- audio/drivers/coreaudio.c | 20 +- audio/drivers/ctr_csnd_audio.c | 6 +- audio/drivers/dsound.c | 14 +- audio/drivers/gx_audio.c | 6 +- audio/drivers/jack.c | 6 +- audio/drivers/nullaudio.c | 2 +- audio/drivers/openal.c | 2 +- audio/drivers/opensl.c | 4 +- audio/drivers/oss.c | 4 +- audio/drivers/ps3_audio.c | 6 +- audio/drivers/psp_audio.c | 8 +- audio/drivers/pulse.c | 12 +- audio/drivers/roar.c | 2 +- audio/drivers/rsound.c | 2 +- audio/drivers/rsound.h | 72 +- audio/drivers/rwebaudio.c | 2 +- audio/drivers/sdl_audio.c | 6 +- audio/drivers/tinyalsa.c | 10 +- audio/drivers/wasapi.c | 24 +- audio/drivers/xaudio.c | 56 +- audio/drivers/xaudio.h | 44 +- audio/drivers/xenon360_audio.c | 4 +- audio/drivers_resampler/cc_resampler.c | 4 +- audio/librsound.c | 40 +- autosave.h | 2 +- bootstrap/psp1/kernel_functions_prx/main.c | 2 +- bootstrap/vita/threading.c | 10 +- camera/camera_driver.c | 14 +- camera/camera_driver.h | 2 +- camera/drivers/android.c | 8 +- camera/drivers/nullcamera.c | 2 +- camera/drivers/rwebcam.c | 2 +- camera/drivers/video4linux2.c | 2 +- cheevos/badges.c | 110 +- cheevos/badges.h | 58 +- cheevos/cheevos.c | 4 +- cheevos/var.c | 4 +- command.c | 12 +- command.h | 2 +- configuration.h | 2 +- core.h | 8 +- core_info.c | 28 +- core_info.h | 2 +- core_type.h | 4 +- cores/dynamic_dummy.c | 2 +- cores/internal_cores.h | 2 +- cores/libretro-ffmpeg/ffmpeg_core.c | 42 +- cores/libretro-ffmpeg/ffmpeg_fft.c | 14 +- .../gl_shaders/ffmpeg_es.glsl.frag.h | 2 +- .../gl_shaders/fft_heightmap.glsl.vert.h | 2 +- cores/libretro-imageviewer/image_core.c | 8 +- .../video_processor_v4l2.c | 16 +- defaults.h | 4 +- defines/d3d_defines.h | 4 +- defines/gx_defines.h | 2 +- defines/ps3_defines.h | 2 +- deps/7zip/7z.h | 414 +- deps/7zip/7zBuf.c | 74 +- deps/7zip/7zBuf.h | 54 +- deps/7zip/7zCrc.c | 152 +- deps/7zip/7zCrc.h | 58 +- deps/7zip/7zCrcOpt.c | 76 +- deps/7zip/7zDec.c | 720 +-- deps/7zip/7zFile.c | 570 +-- deps/7zip/7zFile.h | 174 +- deps/7zip/7zIn.c | 2742 ++++++------ deps/7zip/7zStream.c | 346 +- deps/7zip/7zVersion.h | 14 +- deps/7zip/Bcj2.c | 298 +- deps/7zip/Bcj2.h | 76 +- deps/7zip/Bra.c | 268 +- deps/7zip/Bra.h | 136 +- deps/7zip/Bra86.c | 172 +- deps/7zip/CpuArch.h | 142 +- deps/7zip/LzFind.c | 58 +- deps/7zip/LzFind.h | 4 +- deps/7zip/Lzma2Dec.c | 694 +-- deps/7zip/Lzma2Dec.h | 170 +- deps/7zip/LzmaDec.c | 2080 ++++----- deps/7zip/LzmaDec.h | 440 +- deps/7zip/LzmaEnc.c | 56 +- deps/SPIRV-Cross/GLSL.std.450.h | 2 +- deps/glslang/glslang/SPIRV/GLSL.std.450.h | 2 +- deps/glslang/glslang/SPIRV/SPVRemapper.h | 10 +- deps/glslang/glslang/SPIRV/SpvBuilder.h | 2 +- deps/glslang/glslang/SPIRV/doc.h | 2 +- deps/glslang/glslang/SPIRV/spvIR.h | 10 +- deps/glslang/glslang/StandAlone/Worklist.h | 10 +- .../glslang/glslang/Include/BaseTypes.h | 4 +- deps/glslang/glslang/glslang/Include/Common.h | 8 +- .../glslang/glslang/Include/ConstantUnion.h | 42 +- .../glslang/glslang/Include/InfoSink.h | 10 +- .../glslang/glslang/Include/PoolAlloc.h | 28 +- .../glslang/glslang/Include/ResourceLimits.h | 2 +- .../glslang/glslang/Include/ShHandle.h | 16 +- deps/glslang/glslang/glslang/Include/Types.h | 4 +- .../glslang/glslang/Include/intermediate.h | 18 +- .../glslang/MachineIndependent/Initialize.h | 4 +- .../glslang/MachineIndependent/ParseHelper.h | 2 +- .../glslang/glslang/MachineIndependent/Scan.h | 2 +- .../glslang/MachineIndependent/SymbolTable.h | 22 +- .../MachineIndependent/glslang_tab.cpp.h | 10 +- .../MachineIndependent/localintermediate.h | 10 +- .../preprocessor/PpContext.h | 18 +- .../preprocessor/PpTokens.h | 4 +- .../glslang/MachineIndependent/reflection.h | 6 +- .../glslang/glslang/Public/ShaderLang.h | 12 +- deps/glslang/glslang/gtests/TestFixture.h | 4 +- deps/glslang/glslang/hlsl/hlslGrammar.h | 2 +- deps/glslang/glslang/hlsl/hlslParseHelper.h | 2 +- deps/glslang/glslang/hlsl/hlslParseables.h | 2 +- deps/glslang/glslang/hlsl/hlslTokens.h | 2 +- deps/ibxm/ibxm.c | 3844 ++++++++--------- deps/libvita2d/source/vita2d_texture.c | 2 +- deps/mbedtls/ecjpake.c | 2 +- deps/mbedtls/mbedtls/ecp_internal.h | 2 +- deps/mbedtls/mbedtls/rsa.h | 8 +- deps/mbedtls/mbedtls/ssl_ciphersuites.h | 2 +- deps/mbedtls/ssl_cli.c | 4 +- deps/mbedtls/ssl_srv.c | 8 +- deps/mbedtls/x509_crt.c | 2 +- deps/stb/stb_image.h | 4 +- deps/stb/stb_rect_pack.h | 6 +- deps/stb/stb_truetype.h | 48 +- deps/stb/stb_vorbis.h | 160 +- dirs.c | 4 +- dirs.h | 2 +- driver.c | 24 +- driver.h | 6 +- dynamic.c | 54 +- dynamic.h | 6 +- file_path_str.c | 2 +- frontend/drivers/platform_ctr.c | 4 +- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_ps3.c | 6 +- frontend/drivers/platform_qnx.c | 2 +- frontend/drivers/platform_unix.c | 18 +- frontend/drivers/platform_unix.h | 4 +- frontend/drivers/platform_wii.c | 8 +- frontend/drivers/platform_win32.c | 36 +- frontend/drivers/platform_xdk.c | 20 +- frontend/frontend.c | 2 +- frontend/frontend.h | 4 +- frontend/frontend_salamander.c | 8 +- gfx/common/d3d_common.c | 14 +- gfx/common/d3d_common.h | 4 +- gfx/common/dbus_common.c | 4 +- gfx/common/dbus_common.h | 2 +- gfx/common/drm_common.c | 2 +- gfx/common/drm_common.h | 2 +- gfx/common/egl_common.c | 4 +- gfx/common/egl_common.h | 2 +- gfx/common/gl_common.c | 2 +- gfx/common/gl_common.h | 2 +- gfx/common/vita2d_common.h | 14 +- gfx/common/vksym.h | 2 +- gfx/common/vulkan_common.c | 60 +- gfx/common/vulkan_common.h | 2 +- gfx/common/wayland_common.h | 2 +- gfx/common/win32_common.c | 6 +- gfx/common/win32_common.h | 2 +- gfx/common/x11_common.c | 12 +- gfx/common/x11_common.h | 2 +- gfx/common/xinerama_common.c | 2 +- gfx/common/xinerama_common.h | 2 +- gfx/drivers/ctr_gfx.c | 4 +- gfx/drivers/d3d.c | 26 +- gfx/drivers/d3d.h | 2 +- gfx/drivers/dispmanx_gfx.c | 146 +- gfx/drivers/drm_gfx.c | 206 +- gfx/drivers/exynos_gfx.c | 8 +- gfx/drivers/gdi_gfx.c | 4 +- gfx/drivers/gl.c | 14 +- .../gl_shaders/pipeline_snowflake.glsl.frag.h | 24 +- .../pipeline_xmb_ribbon_simple.cg.h | 2 +- gfx/drivers/gx_gfx.c | 30 +- gfx/drivers/gx_gfx_vi_encoder.c | 826 ++-- gfx/drivers/nullgfx.c | 2 +- gfx/drivers/omap_gfx.c | 8 +- gfx/drivers/psp1_gfx.c | 34 +- gfx/drivers/psp1_gfx.h | 2 +- gfx/drivers/sdl2_gfx.c | 8 +- gfx/drivers/sdl_gfx.c | 6 +- gfx/drivers/sunxi_gfx.c | 58 +- gfx/drivers/vga_gfx.c | 2 +- gfx/drivers/vita2d_gfx.c | 44 +- gfx/drivers/vulkan.c | 86 +- gfx/drivers/xenon360_gfx.c | 4 +- gfx/drivers/xshm_gfx.c | 54 +- gfx/drivers/xvideo.c | 52 +- gfx/drivers_context/android_ctx.c | 8 +- gfx/drivers_context/cgl_ctx.c | 18 +- gfx/drivers_context/d3d_ctx.c | 4 +- gfx/drivers_context/drm_ctx.c | 36 +- gfx/drivers_context/gdi_ctx.c | 4 +- gfx/drivers_context/gfx_null_ctx.c | 4 +- gfx/drivers_context/khr_display_ctx.c | 4 +- gfx/drivers_context/mali_fbdev_ctx.c | 4 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 4 +- gfx/drivers_context/ps3_ctx.c | 16 +- gfx/drivers_context/sdl_gl_ctx.c | 2 +- gfx/drivers_context/vc_egl_ctx.c | 24 +- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 10 +- gfx/drivers_context/wgl_ctx.c | 12 +- gfx/drivers_context/x_ctx.c | 26 +- gfx/drivers_context/xegl_ctx.c | 22 +- gfx/drivers_font/caca_font.c | 2 +- gfx/drivers_font/ctr_font.c | 2 +- gfx/drivers_font/d3d_w32_font.c | 2 +- gfx/drivers_font/gdi_font.c | 2 +- gfx/drivers_font/gl_raster_font.c | 4 +- gfx/drivers_font/ps_libdbgfont.c | 4 +- gfx/drivers_font/vga_font.c | 2 +- gfx/drivers_font/vita2d_font.c | 12 +- gfx/drivers_font/vulkan_raster_font.c | 14 +- gfx/drivers_font/xdk1_xfonts.c | 4 +- gfx/drivers_font_renderer/bitmap.h | 2 +- gfx/drivers_font_renderer/bitmapfont.c | 12 +- gfx/drivers_font_renderer/coretext.c | 10 +- gfx/drivers_font_renderer/freetype.c | 4 +- gfx/drivers_font_renderer/stb_unicode.c | 2 +- gfx/drivers_renderchain/d3d8_renderchain.c | 20 +- .../d3d9_hlsl_renderchain.c | 26 +- gfx/drivers_renderchain/gl1_renderchain.c | 4 +- gfx/drivers_renderchain/gl2_renderchain.c | 66 +- gfx/drivers_renderchain/null_renderchain.c | 2 +- gfx/drivers_shader/shader_gl_cg.c | 26 +- gfx/drivers_shader/shader_glsl.c | 10 +- gfx/drivers_shader/shader_glsl.h | 2 +- gfx/drivers_shader/shader_hlsl.c | 8 +- gfx/drivers_shader/shader_hlsl.h | 2 +- gfx/drivers_shader/shader_null.c | 2 +- gfx/drivers_shader/shader_vulkan.h | 4 +- gfx/drivers_shader/slang_preprocess.h | 2 +- gfx/drivers_tracker/video_state_python.h | 4 +- gfx/font_driver.c | 10 +- gfx/font_driver.h | 14 +- gfx/include/GL/glext.h | 6 +- gfx/include/d3d8/d3d8.h | 2558 +++++------ gfx/include/d3d8/d3dx8.h | 88 +- gfx/include/d3d8/d3dx8core.h | 1126 ++--- gfx/include/d3d8/d3dx8effect.h | 452 +- gfx/include/d3d8/d3dx8math.h | 2426 +++++------ gfx/include/d3d8/d3dx8mesh.h | 1520 +++---- gfx/include/d3d8/d3dx8shape.h | 440 +- gfx/include/d3d8/d3dx8tex.h | 3184 +++++++------- gfx/include/d3d9/d3dx9anim.h | 170 +- gfx/include/d3d9/d3dx9core.h | 52 +- gfx/include/d3d9/d3dx9effect.h | 50 +- gfx/include/d3d9/d3dx9math.h | 72 +- gfx/include/d3d9/d3dx9mesh.h | 716 +-- gfx/include/d3d9/d3dx9shader.h | 28 +- gfx/include/d3d9/d3dx9shape.h | 32 +- gfx/include/d3d9/d3dx9tex.h | 14 +- gfx/include/d3d9/d3dx9xof.h | 20 +- gfx/include/d3d9caps.h | 16 +- gfx/include/d3d9types.h | 78 +- gfx/include/vulkan/vulkan.h | 4 +- gfx/video_coord_array.c | 2 +- gfx/video_coord_array.h | 2 +- gfx/video_driver.c | 82 +- gfx/video_driver.h | 64 +- gfx/video_filter.c | 8 +- gfx/video_filters/2xbr.c | 118 +- gfx/video_filters/2xsai.c | 14 +- gfx/video_filters/blargg_ntsc_snes.c | 8 +- gfx/video_filters/darken.c | 6 +- gfx/video_filters/epx.c | 6 +- gfx/video_filters/lq2x.c | 12 +- gfx/video_filters/phosphor2x.c | 72 +- gfx/video_filters/scale2x.c | 12 +- gfx/video_filters/snes_ntsc/snes_ntsc.c | 48 +- gfx/video_filters/snes_ntsc/snes_ntsc.h | 4 +- gfx/video_filters/snes_ntsc/snes_ntsc_impl.h | 42 +- gfx/video_filters/softfilter.h | 30 +- gfx/video_filters/super2xsai.c | 8 +- gfx/video_filters/supereagle.c | 4 +- gfx/video_shader_parse.c | 56 +- gfx/video_shader_parse.h | 20 +- gfx/video_state_tracker.c | 12 +- gfx/video_state_tracker.h | 2 +- gfx/video_thread_wrapper.c | 28 +- gfx/video_thread_wrapper.h | 6 +- input/common/input_x11_common.c | 2 +- input/common/input_x11_common.h | 2 +- input/common/linux_common.c | 8 +- input/common/linux_common.h | 2 +- input/connect/connect_ps4.c | 2 +- input/connect/connect_wiiupro.c | 2 +- input/drivers/android_input.c | 60 +- input/drivers/cocoa_input.h | 2 +- input/drivers/ctr_input.c | 2 +- input/drivers/gx_input.c | 2 +- input/drivers/linuxraw_input.c | 4 +- input/drivers/nullinput.c | 2 +- input/drivers/ps3_input.c | 8 +- input/drivers/rwebinput_input.c | 6 +- input/drivers/sdl_input.c | 8 +- input/drivers/wayland_input.c | 14 +- input/drivers/winraw_input.c | 1714 ++++---- input/drivers/x11_input.c | 16 +- input/drivers/xdk_xinput_input.c | 8 +- input/drivers/xenon360_input.c | 2 +- input/drivers_hid/libusb_hid.c | 14 +- input/drivers_joypad/dinput_joypad.c | 8 +- input/drivers_joypad/sdl_joypad.c | 2 +- input/drivers_joypad/xinput_joypad.c | 20 +- .../drivers_keyboard/keyboard_event_android.c | 4 +- .../drivers_keyboard/keyboard_event_android.h | 2 +- input/drivers_keyboard/keyboard_event_dos.c | 2 +- input/drivers_keyboard/keyboard_event_dos.h | 2 +- input/drivers_keyboard/keyboard_event_xkb.c | 2 +- input/include/GameController/GCController.h | 46 +- .../GameController/GCControllerAxisInput.h | 2 +- .../GameController/GCControllerButtonInput.h | 4 +- .../GameController/GCControllerDirectionPad.h | 2 +- .../GameController/GCExtendedGamepad.h | 14 +- .../GCExtendedGamepadSnapshot.h | 14 +- input/include/GameController/GCGamepad.h | 12 +- .../GameController/GCGamepadSnapshot.h | 16 +- input/input_driver.c | 76 +- input/input_keymaps.c | 6 +- input/input_keymaps.h | 4 +- input/input_mapper.c | 6 +- input/input_mapper.h | 2 +- input/input_overlay.c | 22 +- input/input_overlay.h | 10 +- input/input_remapping.c | 14 +- input/input_remote.c | 4 +- input/input_remote.h | 2 +- intl/msg_hash_pt_br.c | 12 +- lakka.h | 2 +- libretro-common/audio/audio_mix.c | 6 +- libretro-common/audio/audio_mixer.c | 84 +- .../audio/conversion/float_to_s16.c | 6 +- .../audio/conversion/s16_to_float.c | 6 +- libretro-common/audio/dsp_filter.c | 6 +- libretro-common/audio/dsp_filters/chorus.c | 2 +- libretro-common/audio/dsp_filters/eq.c | 6 +- libretro-common/audio/dsp_filters/iir.c | 10 +- libretro-common/audio/dsp_filters/panning.c | 2 +- .../audio/resampler/audio_resampler.c | 2 +- .../resampler/drivers/nearest_resampler.c | 20 +- .../audio/resampler/drivers/null_resampler.c | 10 +- .../audio/resampler/drivers/sinc_resampler.c | 34 +- libretro-common/compat/compat_fnmatch.c | 12 +- libretro-common/compat/compat_getopt.c | 6 +- libretro-common/compat/compat_ifaddrs.c | 10 +- libretro-common/compat/compat_snprintf.c | 20 +- libretro-common/encodings/encoding_utf.c | 6 +- libretro-common/features/features_cpu.c | 12 +- libretro-common/file/archive_file.c | 4 +- libretro-common/file/archive_file_zlib.c | 2 +- libretro-common/file/config_file.c | 4 +- libretro-common/file/config_file_userdata.c | 8 +- libretro-common/file/file_path.c | 12 +- libretro-common/file/nbio/nbio_intf.c | 170 +- libretro-common/file/nbio/nbio_linux.c | 8 +- libretro-common/file/nbio/nbio_stdio.c | 536 +-- libretro-common/file/nbio/nbio_unixmmap.c | 10 +- libretro-common/file/nbio/nbio_windowsmmap.c | 6 +- libretro-common/formats/bmp/rbmp.c | 8 +- libretro-common/formats/image_texture.c | 12 +- libretro-common/formats/image_transfer.c | 2 +- libretro-common/formats/jpeg/rjpeg.c | 18 +- libretro-common/formats/json/jsonsax_full.c | 22 +- libretro-common/formats/libchdr/bitstream.c | 2 +- libretro-common/formats/libchdr/cdrom.c | 848 ++-- libretro-common/formats/libchdr/chd.c | 22 +- libretro-common/formats/libchdr/flac.c | 668 +-- libretro-common/formats/libchdr/huffman.c | 1134 ++--- libretro-common/formats/png/rpng.c | 42 +- libretro-common/formats/png/rpng_encode.c | 4 +- libretro-common/formats/tga/rtga.c | 6 +- libretro-common/formats/wav/rwav.c | 6 +- libretro-common/formats/xml/rxml.c | 12 +- libretro-common/formats/xml/test/rxml_test.c | 2 +- libretro-common/gfx/gl_capabilities.c | 2 +- libretro-common/gfx/scaler/pixconv.c | 2 +- libretro-common/gfx/scaler/scaler.c | 4 +- libretro-common/gfx/scaler/scaler_filter.c | 6 +- libretro-common/gfx/scaler/scaler_int.c | 26 +- libretro-common/glsm/glsm.c | 154 +- libretro-common/hash/rhash.c | 30 +- .../include/audio/audio_resampler.h | 18 +- .../include/audio/conversion/float_to_s16.h | 2 +- libretro-common/include/compat/getopt.h | 6 +- libretro-common/include/compat/intrinsics.h | 2 +- libretro-common/include/compat/msvc.h | 62 +- libretro-common/include/compat/msvc/stdint.h | 14 +- libretro-common/include/compat/strcasestr.h | 2 +- libretro-common/include/compat/strl.h | 2 +- libretro-common/include/encodings/win32.h | 126 +- libretro-common/include/file/config_file.h | 6 +- libretro-common/include/file/file_path.h | 38 +- libretro-common/include/file/nbio.h | 2 +- libretro-common/include/formats/rwav.h | 8 +- libretro-common/include/formats/rxml.h | 12 +- libretro-common/include/gfx/math/matrix_4x4.h | 8 +- libretro-common/include/gfx/math/vector_2.h | 4 +- libretro-common/include/glsm/glsmsym.h | 2 +- libretro-common/include/libchdr/cdrom.h | 140 +- libretro-common/include/libchdr/chd.h | 4 +- libretro-common/include/libchdr/flac.h | 104 +- libretro-common/include/libchdr/huffman.h | 180 +- libretro-common/include/libchdr/minmax.h | 42 +- libretro-common/include/libretro.h | 570 +-- libretro-common/include/libretro_dspfilter.h | 42 +- libretro-common/include/libretro_vulkan.h | 106 +- libretro-common/include/lists/file_list.h | 8 +- libretro-common/include/net/net_http.h | 6 +- libretro-common/include/net/net_ifinfo.h | 2 +- libretro-common/include/queues/task_queue.h | 40 +- libretro-common/include/retro_common.h | 2 +- libretro-common/include/retro_common_api.h | 4 +- libretro-common/include/retro_endianness.h | 24 +- libretro-common/include/retro_miscellaneous.h | 10 +- libretro-common/include/rthreads/rthreads.h | 34 +- libretro-common/libco/armeabi.c | 2 +- libretro-common/libco/ppc.c | 32 +- libretro-common/lists/file_list.c | 8 +- libretro-common/memmap/memmap.c | 4 +- libretro-common/net/net_compat.c | 12 +- libretro-common/net/net_http.c | 6 +- libretro-common/net/net_ifinfo.c | 2 +- libretro-common/net/net_socket.c | 4 +- libretro-common/queues/message_queue.c | 6 +- libretro-common/queues/task_queue.c | 4 +- libretro-common/rthreads/rthreads.c | 94 +- .../samples/formats/png/rpng_test.c | 2 +- libretro-common/samples/net/net_http_test.c | 6 +- libretro-common/samples/net/udp-test.c | 116 +- libretro-common/streams/chd_stream.c | 4 +- .../streams/file_stream_transforms.c | 205 +- libretro-common/streams/memory_stream.c | 4 +- libretro-common/string/stdstring.c | 8 +- libretro-common/utils/crc32.c | 86 +- libretro-common/utils/sha1.c | 16 +- libretro-common/utils/sha1_main.c | 4 +- libretro-db/libretrodb_tool.c | 8 +- libretro-db/query.c | 12 +- libretro-db/rmsgpack_dom.c | 4 +- list_special.c | 2 +- list_special.h | 2 +- location/drivers/android.c | 4 +- location/drivers/nulllocation.c | 2 +- location/location_driver.c | 16 +- location/location_driver.h | 4 +- managers/cheat_manager.h | 2 +- managers/core_manager.c | 2 +- managers/core_manager.h | 2 +- managers/core_option_manager.c | 8 +- managers/core_option_manager.h | 6 +- managers/state_manager.c | 88 +- managers/state_manager.h | 2 +- memory/wii/mem2_manager.c | 14 +- memory/wii/mem2_manager.h | 2 +- menu/cbs/menu_cbs_deferred_push.c | 18 +- menu/cbs/menu_cbs_get_value.c | 4 +- menu/cbs/menu_cbs_info.c | 2 +- menu/cbs/menu_cbs_left.c | 22 +- menu/cbs/menu_cbs_ok.c | 8 +- menu/cbs/menu_cbs_right.c | 10 +- menu/cbs/menu_cbs_scan.c | 2 +- menu/cbs/menu_cbs_select.c | 10 +- menu/cbs/menu_cbs_start.c | 4 +- menu/cbs/menu_cbs_title.c | 46 +- menu/drivers/materialui.c | 160 +- menu/drivers/menu_generic.c | 2 +- menu/drivers/nuklear.c | 6 +- menu/drivers/nuklear/nk_common.c | 2 +- menu/drivers/nuklear/nk_menu.c | 68 +- menu/drivers/rgui.c | 6 +- menu/drivers/xmb.c | 2 +- menu/drivers/zarch.c | 34 +- menu/drivers_display/menu_display_caca.c | 2 +- menu/drivers_display/menu_display_ctr.c | 4 +- menu/drivers_display/menu_display_d3d.c | 6 +- menu/drivers_display/menu_display_vga.c | 2 +- menu/drivers_display/menu_display_vita2d.c | 36 +- menu/drivers_display/menu_display_vulkan.c | 6 +- menu/menu_animation.c | 6 +- menu/menu_cbs.c | 16 +- menu/menu_cbs.h | 4 +- menu/menu_content.c | 4 +- menu/menu_displaylist.h | 2 +- menu/menu_driver.c | 30 +- menu/menu_entries.c | 6 +- menu/menu_entries.h | 2 +- menu/menu_event.c | 10 +- menu/menu_event.h | 4 +- menu/menu_input.c | 12 +- menu/menu_setting.h | 2 +- menu/menu_shader.c | 28 +- menu/menu_shader.h | 6 +- menu/widgets/menu_entry.c | 8 +- menu/widgets/menu_filebrowser.c | 2 +- menu/widgets/menu_input_bind_dialog.c | 2 +- movie.c | 16 +- movie.h | 2 +- network/httpserver/httpserver.c | 2 +- network/net_http_special.h | 2 +- network/net_logger.c | 2 +- network/netplay/netplay.h | 2 +- network/netplay/netplay_buf.c | 2 +- network/netplay/netplay_discovery.c | 12 +- network/netplay/netplay_discovery.h | 2 +- network/netplay/netplay_frontend.c | 30 +- network/netplay/netplay_handshake.c | 8 +- network/netplay/netplay_init.c | 18 +- network/netplay/netplay_io.c | 4 +- network/netplay/netplay_private.h | 6 +- paths.c | 14 +- paths.h | 2 +- performance_counters.h | 6 +- playlist.c | 12 +- playlist.h | 10 +- record/drivers/record_ffmpeg.c | 34 +- record/record_driver.c | 10 +- record/record_driver.h | 2 +- retroarch.h | 10 +- setting_list.c | 48 +- setting_list.h | 10 +- tasks/task_audio_mixer.c | 8 +- tasks/task_content.c | 40 +- tasks/task_database.c | 10 +- tasks/task_http.c | 2 +- tasks/task_image.c | 12 +- tasks/task_netplay_find_content.c | 18 +- tasks/task_netplay_lan_scan.c | 2 +- tasks/task_overlay.c | 4 +- tasks/task_patch.c | 76 +- tasks/task_save.c | 8 +- tasks/task_screenshot.c | 8 +- tasks/task_wifi.c | 2 +- tasks/tasks_internal.h | 4 +- tools/ps3/ps3py/crypt.c | 10 +- ui/drivers/cocoa/cocoa_common.h | 4 +- ui/drivers/qt/wimp/wimp.h | 126 +- ui/drivers/qt/wimp/wimp_global.h | 56 +- ui/drivers/qt/wrapper/wrapper.h | 76 +- ui/drivers/ui_cocoa.h | 2 +- ui/drivers/ui_win32.c | 64 +- ui/drivers/ui_win32.h | 2 +- ui/drivers/ui_win32_resource.h | 64 +- ui/drivers/win32/ui_win32_browser_window.c | 2 +- ui/drivers/win32/ui_win32_window.c | 2 +- ui/ui_companion_driver.c | 2 +- ui/ui_companion_driver.h | 6 +- verbosity.c | 2 +- version.h | 2 +- version_git.c | 2 +- version_git.h | 4 +- wifi/drivers/connmanctl.c | 4 +- wifi/drivers/nullwifi.c | 2 +- wifi/wifi_driver.c | 14 +- wifi/wifi_driver.h | 2 +- wii/app_booter/main.c | 2 +- wii/libogc/include/bte/bd_addr.h | 28 +- wii/libogc/include/debug.h | 2 +- wii/libogc/include/gctypes.h | 6 +- wii/libogc/include/ipv4/lwip/icmp.h | 30 +- wii/libogc/include/ipv4/lwip/inet.h | 28 +- wii/libogc/include/ipv4/lwip/ip.h | 30 +- wii/libogc/include/ipv4/lwip/ip_frag.h | 28 +- wii/libogc/include/iso9660.h | 2 +- wii/libogc/include/lwip/api.h | 28 +- wii/libogc/include/lwip/api_msg.h | 28 +- wii/libogc/include/lwip/arch.h | 28 +- wii/libogc/include/lwip/debug.h | 40 +- wii/libogc/include/lwip/def.h | 28 +- wii/libogc/include/lwip/dhcp.h | 22 +- wii/libogc/include/lwip/err.h | 28 +- wii/libogc/include/lwip/lwipopts.h | 2 +- wii/libogc/include/lwip/mem.h | 28 +- wii/libogc/include/lwip/memp.h | 32 +- wii/libogc/include/lwip/netif.h | 28 +- wii/libogc/include/lwip/opt.h | 56 +- wii/libogc/include/lwip/pbuf.h | 42 +- wii/libogc/include/lwip/sio.h | 26 +- wii/libogc/include/lwip/snmp.h | 54 +- wii/libogc/include/lwip/sockets.h | 32 +- wii/libogc/include/lwip/stats.h | 32 +- wii/libogc/include/lwip/sys.h | 28 +- wii/libogc/include/lwip/tcp.h | 68 +- wii/libogc/include/lwip/tcpip.h | 28 +- wii/libogc/include/lwip/udp.h | 34 +- wii/libogc/include/netif/arch/cc.h | 48 +- wii/libogc/include/netif/arch/cpu.h | 48 +- wii/libogc/include/netif/arch/init.h | 48 +- wii/libogc/include/netif/arch/lib.h | 48 +- wii/libogc/include/netif/arch/perf.h | 48 +- wii/libogc/include/netif/arch/sys_arch.h | 48 +- wii/libogc/include/netif/etharp.h | 28 +- wii/libogc/include/netif/loopif.h | 28 +- wii/libogc/include/ogc/aram.h | 36 +- wii/libogc/include/ogc/arqmgr.h | 4 +- wii/libogc/include/ogc/arqueue.h | 4 +- wii/libogc/include/ogc/audio.h | 54 +- wii/libogc/include/ogc/card.h | 28 +- wii/libogc/include/ogc/cond.h | 6 +- wii/libogc/include/ogc/disc_io.h | 2 +- wii/libogc/include/ogc/dsp.h | 18 +- wii/libogc/include/ogc/dvd.h | 66 +- wii/libogc/include/ogc/exi.h | 4 +- wii/libogc/include/ogc/gu.h | 2 +- wii/libogc/include/ogc/gx.h | 14 +- wii/libogc/include/ogc/gx_struct.h | 4 +- wii/libogc/include/ogc/lwp.h | 4 +- wii/libogc/include/ogc/lwp_mutex.h | 2 +- wii/libogc/include/ogc/lwp_stack.h | 2 +- wii/libogc/include/ogc/lwp_states.h | 2 +- wii/libogc/include/ogc/lwp_threads.h | 2 +- wii/libogc/include/ogc/lwp_watchdog.h | 6 +- wii/libogc/include/ogc/machine/asm.h | 30 +- wii/libogc/include/ogc/machine/spinlock.h | 4 +- wii/libogc/include/ogc/message.h | 4 +- wii/libogc/include/ogc/mutex.h | 4 +- wii/libogc/include/ogc/semaphore.h | 4 +- wii/libogc/include/ogc/video.h | 34 +- wii/libogc/include/sdcard/gcsd.h | 2 +- wii/libogc/include/sdcard/wiisd_io.h | 2 +- wii/libogc/include/wiiuse/wiiuse.h | 2 +- wii/libogc/include/wiiuse/wpad.h | 8 +- wii/libogc/libdb/debug.c | 26 +- wii/libogc/libdb/debug_supp.c | 12 +- wii/libogc/libdb/geckousb.c | 2 +- wii/libogc/libdb/tcpip.c | 42 +- wii/libogc/libdb/uIP/bba.c | 48 +- wii/libogc/libdb/uIP/memb.c | 2 +- wii/libogc/libdb/uIP/memr.c | 10 +- wii/libogc/libdb/uIP/uip.h | 22 +- wii/libogc/libdb/uIP/uip_arch.c | 30 +- wii/libogc/libdb/uIP/uip_arch.h | 24 +- wii/libogc/libdb/uIP/uip_arp.c | 48 +- wii/libogc/libdb/uIP/uip_arp.h | 32 +- wii/libogc/libdb/uIP/uip_icmp.c | 10 +- wii/libogc/libdb/uIP/uip_ip.c | 42 +- wii/libogc/libdb/uIP/uip_ip.h | 6 +- wii/libogc/libdb/uIP/uip_netif.c | 14 +- wii/libogc/libdb/uIP/uip_netif.h | 8 +- wii/libogc/libdb/uIP/uip_pbuf.c | 16 +- wii/libogc/libdb/uIP/uip_tcp.c | 112 +- wii/libogc/libdb/uIP/uip_tcp.h | 26 +- wii/libogc/libdb/uIP/uipopt.h | 30 +- wii/libogc/libfat/bit_ops.h | 2 +- wii/libogc/libfat/directory.h | 10 +- wii/libogc/libfat/disc.c | 14 +- wii/libogc/libfat/disc.h | 12 +- wii/libogc/libfat/fatdir.h | 6 +- wii/libogc/libfat/fatfile.h | 6 +- wii/libogc/libfat/file_allocation_table.h | 6 +- wii/libogc/libfat/filetime.c | 20 +- wii/libogc/libfat/filetime.h | 2 +- wii/libogc/libfat/libfat.c | 8 +- wii/libogc/libfat/mem_allocate.h | 2 +- wii/libogc/libogc/argv.c | 6 +- wii/libogc/libogc/arqmgr.c | 8 +- wii/libogc/libogc/arqueue.c | 10 +- wii/libogc/libogc/card.c | 392 +- wii/libogc/libogc/cond.c | 8 +- wii/libogc/libogc/conf.c | 76 +- wii/libogc/libogc/console.c | 30 +- wii/libogc/libogc/depackrnc1.c | 2 +- wii/libogc/libogc/dvd.c | 2 +- wii/libogc/libogc/es.c | 10 +- wii/libogc/libogc/exception.c | 4 +- wii/libogc/libogc/gcsd.c | 2 +- wii/libogc/libogc/gu.c | 36 +- wii/libogc/libogc/ios.c | 8 +- wii/libogc/libogc/isfs.c | 66 +- wii/libogc/libogc/lock_supp.c | 10 +- wii/libogc/libogc/lwp.c | 20 +- wii/libogc/libogc/lwp_heap.c | 34 +- wii/libogc/libogc/lwp_messages.c | 18 +- wii/libogc/libogc/lwp_mutex.c | 8 +- wii/libogc/libogc/lwp_objmgr.c | 2 +- wii/libogc/libogc/lwp_priority.c | 4 +- wii/libogc/libogc/lwp_queue.c | 10 +- wii/libogc/libogc/lwp_sema.c | 6 +- wii/libogc/libogc/lwp_stack.c | 2 +- wii/libogc/libogc/lwp_threadq.c | 22 +- wii/libogc/libogc/lwp_threads.c | 60 +- wii/libogc/libogc/lwp_watchdog.c | 2 +- wii/libogc/libogc/malloc_lock.c | 6 +- wii/libogc/libogc/mutex.c | 4 +- wii/libogc/libogc/network_common.c | 4 +- wii/libogc/libogc/newlibc.c | 4 +- wii/libogc/libogc/pad.c | 2 +- wii/libogc/libogc/sbrk.c | 2 +- wii/libogc/libogc/sdgecko_buf.c | 6 +- wii/libogc/libogc/sdgecko_io.c | 92 +- wii/libogc/libogc/semaphore.c | 4 +- wii/libogc/libogc/stm.c | 26 +- wii/libogc/libogc/texconv.c | 2 +- wii/libogc/libogc/timesupp.c | 4 +- wii/libogc/libogc/timesupp.h | 2 +- wii/libogc/libogc/tpl.c | 6 +- wii/libogc/libogc/usbstorage.c | 28 +- wii/libogc/libogc/wiilaunch.c | 4 +- wii/libogc/libogc/wiisd.c | 154 +- wii/libogc/libwiikeyboard/ukbdmap.c | 2 +- wii/libogc/lwbt/bt.h | 22 +- wii/libogc/lwbt/btarch.h | 28 +- wii/libogc/lwbt/bte.c | 22 +- wii/libogc/lwbt/btmemb.c | 4 +- wii/libogc/lwbt/btmemr.c | 10 +- wii/libogc/lwbt/btopt.h | 50 +- wii/libogc/lwbt/btpbuf.c | 16 +- wii/libogc/lwbt/hci.c | 176 +- wii/libogc/lwbt/hci.h | 6 +- wii/libogc/lwbt/l2cap.c | 192 +- wii/libogc/lwbt/l2cap.h | 2 +- wii/libogc/lwbt/physbusif.h | 20 +- wii/libogc/lwip/core/dhcp.c | 16 +- wii/libogc/lwip/core/inet.c | 12 +- wii/libogc/lwip/core/inet6.c | 42 +- wii/libogc/lwip/core/ipv4/ip.c | 8 +- wii/libogc/lwip/core/ipv4/ip_addr.c | 32 +- wii/libogc/lwip/core/ipv4/ip_frag.c | 46 +- wii/libogc/lwip/core/mem.c | 74 +- wii/libogc/lwip/core/memp.c | 64 +- wii/libogc/lwip/core/netif.c | 16 +- wii/libogc/lwip/core/pbuf.c | 20 +- wii/libogc/lwip/core/raw.c | 14 +- wii/libogc/lwip/core/stats.c | 76 +- wii/libogc/lwip/core/tcp.c | 140 +- wii/libogc/lwip/core/tcp_in.c | 18 +- wii/libogc/lwip/core/tcp_out.c | 22 +- wii/libogc/lwip/core/udp.c | 16 +- wii/libogc/lwip/netif/etharp.c | 44 +- wii/libogc/lwip/netif/loopif.c | 40 +- wii/libogc/lwip/netif/skeleton/ethernetif.c | 72 +- wii/libogc/lwip/netif/skeleton/slipif.c | 84 +- wii/libogc/lwip/netio.c | 8 +- wii/libogc/lwip/network.c | 154 +- wii/libogc/wiiuse/classic.h | 2 +- wii/libogc/wiiuse/dynamics.c | 2 +- wii/libogc/wiiuse/dynamics.h | 2 +- wii/libogc/wiiuse/events.c | 10 +- wii/libogc/wiiuse/events.h | 2 +- wii/libogc/wiiuse/io.h | 2 +- wii/libogc/wiiuse/io_wii.c | 8 +- wii/libogc/wiiuse/ir.c | 4 +- wii/libogc/wiiuse/ir.h | 2 +- wii/libogc/wiiuse/motion_plus.c | 8 +- wii/libogc/wiiuse/motion_plus.h | 2 +- wii/libogc/wiiuse/nunchuk.c | 4 +- wii/libogc/wiiuse/nunchuk.h | 2 +- wii/libogc/wiiuse/os.h | 2 +- wii/libogc/wiiuse/speaker.c | 2 +- wii/libogc/wiiuse/speaker.h | 2 +- wii/libogc/wiiuse/wiiuse.c | 14 +- wii/libogc/wiiuse/wiiuse_internal.h | 2 +- wii/libogc/wiiuse/wpad.c | 6 +- wiiu/include/wiiu/nsyskbd.h | 4 +- wiiu/include/wiiu/syshid.h | 82 +- 765 files changed, 23368 insertions(+), 23369 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 6acb0b2ca72..6cd70cf6816 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 @@ bool audio_driver_start(bool is_shutdown) 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 3a62b95c295..27b6a4205c4 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 196fd201c6f..76e130fd449 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 298941d4ff5..fcb2e0d028a 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 379b579658b..c2f2a13f918 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 6fe075cfd91..76d442db98c 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 e6206eb65b3..b01b6a424ab 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 02ff2c6b9a8..6f255bbc5be 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 4765cd7f5c7..8731706c324 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 9514236f4a2..09b8119f87d 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 74530608812..5e840a933f8 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 9b0758175f4..40a116f292d 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 d0d9c0d36b0..39be26d4d0e 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 69964f42250..6127ca9b4d8 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 fef08db8f29..113bce3567f 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 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency, 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 d6d4d28ffab..1c6691187e2 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 0d4e56e4676..1f5eba29b6e 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 808f21e3e59..48e0cdc8234 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -244,9 +244,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 +269,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); diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index 61e47fd08f9..ce3e94bd5e5 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 7e08f74749f..815e5ade967 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 258f42aa2af..c6241c51d5d 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 645eaa83163..236eeb16e62 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 5a90e69233f..3e819b2049f 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 49703948a2c..31152a644b4 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 08e8ea4a1a3..bb12d3a253d 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 e11d8056e08..249ab3589db 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); @@ -339,7 +339,7 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, HRESULT hr; WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -391,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); @@ -433,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); @@ -452,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); @@ -669,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); @@ -1045,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 cae0f8a289e..f3c81a17414 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 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, +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; } + +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 266f89a59cf..4c03e600351 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 diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index b72e01fc4db..fdcd5855720 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 b743338f109..5a3f9204312 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 273fc13334b..da2aaeaa866 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 39cfe8a7a17..1421d604368 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/main.c b/bootstrap/psp1/kernel_functions_prx/main.c index 335b1560971..08ae0bf0ba8 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 cceca6b30ae..8b0d10aa2aa 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 34a5a31d88b..0ee9a7f8786 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 a9161656899..25bbc71d389 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 2ee7541e33f..ab176401552 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 bb0cc82c5cf..332a671e342 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 c630f0f4c1e..a7a39cab36c 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 2be990821e0..1fa94fcfa61 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 5ac11122229..b51ae3669f8 100644 --- a/cheevos/badges.c +++ b/cheevos/badges.c @@ -1,55 +1,55 @@ -#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) -{ - 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) -{ - 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) +{ + if(path_file_exists(filepath)) + return true; + else + return false; +} + +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) +{ + 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 57a8de6ed21..05fe875a2a3 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 5d1c7515ac2..827cd2290a5 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -3163,7 +3163,7 @@ static int cheevos_iterate(coro_t* coro) { settings_t *settings = config_get_ptr(); - if (!string_is_equal(settings->arrays.menu_driver, "xmb") || + if (!string_is_equal(settings->arrays.menu_driver, "xmb") || !settings->bools.cheevos_badges_enable) CORO_RET(); } @@ -3182,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/var.c b/cheevos/var.c index 45ae9ac8666..e0e6d5c6d80 100644 --- a/cheevos/var.c +++ b/cheevos/var.c @@ -256,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; @@ -352,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 67fa8014c50..7b01a2b0d90 100644 --- a/command.c +++ b/command.c @@ -610,7 +610,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 +1028,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; @@ -1126,7 +1126,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 +1338,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(); @@ -1383,7 +1383,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)) @@ -1713,7 +1713,7 @@ void command_playlist_push_write( if (!playlist) return; - + if (playlist_push( playlist, path, diff --git a/command.h b/command.h index 286383fc83a..858fcd820f1 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/configuration.h b/configuration.h index c94b2152095..881e94afeee 100644 --- a/configuration.h +++ b/configuration.h @@ -38,7 +38,7 @@ { \ settings->modified = true; \ var = newvar; \ -} +} #define configuration_set_uint(settings, var, newvar) \ { \ diff --git a/core.h b/core.h index 08ec2e1f089..35878206b4c 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 c2989d883be..2194e296489 100644 --- a/core_info.c +++ b/core_info.c @@ -214,7 +214,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 +255,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 +270,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 +285,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 +293,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 +305,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 +316,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 +327,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 +338,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 +349,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 +360,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 +371,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); diff --git a/core_info.h b/core_info.h index a1510916732..c058e8d9371 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 532b4e4fa6f..e4a66058e54 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 e5b3397f48f..ad61faff97f 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 69c698d3f26..aa756ed3498 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 f6ba5e51dd4..1842f598095 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 32405a0dea4..8d8d22ba128 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 49f4289a004..012a5c7ff0b 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 a5ea0adb2ef..85fec8f6680 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/image_core.c b/cores/libretro-imageviewer/image_core.c index fdc28b90886..2c562b3e5f9 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -274,7 +274,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 +437,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 +446,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 d49d0900aa3..d5f0813f19a 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/defaults.h b/defaults.h index 66940f307e1..2373d0bf00e 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 2e98aabfee3..c4dccb2618a 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 e472b8231b8..c9e7c28e7c2 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 ac8e6f920c5..2b4b0b3d756 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 4f2ee95d88a..84cd56c1524 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 3d30bfd270c..832a7a9271d 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 485ec12610f..4ce09cb7672 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 0e95f17a348..02728d23d6d 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 4b56a1c506a..30890b80355 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 d2f18b372b8..22bd4b11968 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 34eac2a8322..4ed17b23408 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 8f0b628fff0..6dc10da40ca 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 86c3ed10609..33910ec4206 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 b2b67b063b9..62c1d5eb827 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 c205fbe2007..1fc86d064c4 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 d4ac470e238..9d99c5dff2a 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 7c55cae3d11..13991b76988 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 a7651499f74..edca41e0a9d 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 40a0e5f9ed3..49df0831b3e 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 3e9d9d9a30d..52fa0b30b11 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 6cb7bb17f56..d404527199f 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 700945f6178..b223f1a7cb5 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 e41014e65f0..0ad8c2c733f 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 a7fc1175366..063eceb5e48 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 a99b1f91b36..5b8a61c7d5f 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 53797ae0498..5ab3706b49d 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 4a0a5a5fafc..5325053939d 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 b10837ce99e..a7cf98d9710 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 6ea4395a3bf..d66c0acb08f 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 54cc00e9a88..943fd8650f8 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 df31092bec0..86d3da80654 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 b3c686aae58..ee5f63c653d 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 @@ class spirvbin_t : public spirvbin_base_t 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 @@ class spirvbin_t : public spirvbin_base_t 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 @@ class spirvbin_t : public spirvbin_base_t // 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 e8524b2b1b7..ad5da5ffded 100755 --- a/deps/glslang/glslang/SPIRV/SpvBuilder.h +++ b/deps/glslang/glslang/SPIRV/SpvBuilder.h @@ -301,7 +301,7 @@ class Builder { // 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 743896ff4a7..dfc56626678 100644 --- a/deps/glslang/glslang/SPIRV/doc.h +++ b/deps/glslang/glslang/SPIRV/doc.h @@ -195,7 +195,7 @@ class EnumParameters { // 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 c584c9dcb4a..88630f899c8 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 @@ class Block { 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 57dc0db7b29..cfa80a83211 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 f7074406721..38719306d09 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 a779c83e6a7..e0af6b1ff16 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 @@ template class TVector : public std::vector > { 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 ec6aff1171b..18756f5ce0e 100644 --- a/deps/glslang/glslang/glslang/Include/ConstantUnion.h +++ b/deps/glslang/glslang/glslang/Include/ConstantUnion.h @@ -46,14 +46,14 @@ class TConstUnion { 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 @@ class TConstUnion { void setDConst(double d) { - dConst = d; + dConst = d; type = EbtDouble; } void setBConst(bool b) { - bConst = b; + bConst = b; type = EbtBool; } @@ -215,7 +215,7 @@ class TConstUnion { } bool operator>(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -250,7 +250,7 @@ class TConstUnion { } bool operator<(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -285,7 +285,7 @@ class TConstUnion { } TConstUnion operator+(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -301,7 +301,7 @@ class TConstUnion { } TConstUnion operator-(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -317,7 +317,7 @@ class TConstUnion { } TConstUnion operator*(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -325,7 +325,7 @@ class TConstUnion { 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 @@ class TConstUnion { } TConstUnion operator%(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -348,7 +348,7 @@ class TConstUnion { } TConstUnion operator>>(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -394,7 +394,7 @@ class TConstUnion { } TConstUnion operator<<(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -440,7 +440,7 @@ class TConstUnion { } TConstUnion operator&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -455,7 +455,7 @@ class TConstUnion { } TConstUnion operator|(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -470,7 +470,7 @@ class TConstUnion { } TConstUnion operator^(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -485,7 +485,7 @@ class TConstUnion { } TConstUnion operator~() const - { + { TConstUnion returnValue; switch (type) { case EbtInt: returnValue.setIConst(~iConst); break; @@ -499,7 +499,7 @@ class TConstUnion { } TConstUnion operator&&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -511,7 +511,7 @@ class TConstUnion { } TConstUnion operator||(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -544,7 +544,7 @@ class TConstUnion { // 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 0cbd99bdaae..54f1f3393c3 100644 --- a/deps/glslang/glslang/glslang/Include/InfoSink.h +++ b/deps/glslang/glslang/glslang/Include/InfoSink.h @@ -74,9 +74,9 @@ class TInfoSinkBase { 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 @@ class TInfoSinkBase { 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 635be79ef95..0aa2ab2c115 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 @@ class TAllocation { memset(postGuard(), guardBlockEndVal, guardBlockSize); # endif } - + void check() const { checkGuardBlock(preGuard(), guardBlockBeginVal, "before"); checkGuardBlock(postGuard(), guardBlockEndVal, "after"); @@ -100,7 +100,7 @@ class TAllocation { 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 @@ class TAllocation { 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 @@ class TAllocation { // 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 @@ class TPoolAllocator { protected: friend struct tHeader; - + struct tHeader { tHeader(tHeader* nextPage, size_t pageCount) : #ifdef GUARD_BLOCKS @@ -227,7 +227,7 @@ class TPoolAllocator { } 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 @@ class pool_allocator { typedef T& reference; typedef const T& const_reference; typedef T value_type; - template + template struct rebind { typedef pool_allocator other; }; @@ -292,9 +292,9 @@ class pool_allocator { 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 e8c743d6b7c..b9cadb9faf6 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 bfc97db8b24..1e24fdd9337 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 @@ class TUniformMap : public TShHandleBase { 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 @@ class TCompiler : public TShHandleBase { 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 @@ class TLinker : public TShHandleBase { const ShBindingTable* fixedAttributeBindings; const int* excludedAttributes; int excludedCount; - ShBindingTable* uniformBindings; // created by the linker + ShBindingTable* uniformBindings; // created by the linker }; // @@ -155,7 +155,7 @@ class TLinker : public TShHandleBase { // 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 8745c7a9422..7642df9be13 100644 --- a/deps/glslang/glslang/glslang/Include/Types.h +++ b/deps/glslang/glslang/glslang/Include/Types.h @@ -421,7 +421,7 @@ class TQualifier { 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 @@ class TType { 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 8f7ffcc0daa..ffdc82b0034 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 @@ class TIntermTyped : public TIntermNode { 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 @@ class TIntermTyped : public TIntermNode { // 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 23f57acc17e..a61c6b408ad 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h @@ -67,7 +67,7 @@ class TBuiltInParseables { 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 @@ class TBuiltIns : public TBuiltInParseables { 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 6234db6095a..30f2d9a8222 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h @@ -449,7 +449,7 @@ class TParseContext : public TParseContextBase { // * 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 67c86d2efe7..fe747ef431c 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h @@ -254,7 +254,7 @@ class TInputScanner { 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 aeec34fc029..9f5a2e69f5d 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h @@ -120,7 +120,7 @@ class TSymbol { 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 @@ class TSymbol { 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 @@ class TVariable : public TSymbol { 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 @@ class TAnonMember : public TSymbol { 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 @@ class TAnonMember : public TSymbol { 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 @@ class TSymbolTableLevel { 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 @@ class TSymbolTable { while (table.size() > adoptedLevels) pop(0); } - + void adoptLevels(TSymbolTable& symTable) { for (unsigned int level = 0; level < symTable.table.size(); ++level) { @@ -520,7 +520,7 @@ class TSymbolTable { void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; } void setSeparateNameSpaces() { separateNameSpaces = true; } - + void push() { table.push_back(new TSymbolTableLevel); @@ -546,7 +546,7 @@ class TSymbolTable { // 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 @@ class TSymbolTable { // // 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 @@ class TSymbolTable { 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 b6d27993c96..a3a458bb77c 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 6f6db92d5fd..57a2a703538 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 @@ class TIntermediate { 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 @@ class TIntermediate { 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 @@ class TIntermediate { 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 @@ class TIntermediate { 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 013c90e5675..f1c2f311088 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 @@ class TPpContext { 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 @@ class TPpContext { 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 @@ class TPpContext { 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 @@ class TPpContext { return '\\'; } while (ch == '\\'); } - + // handle any non-escaped newline if (ch == '\r' || ch == '\n') { if (ch == '\r' && input->peek() == '\n') @@ -432,7 +432,7 @@ class TPpContext { 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 c84431d3685..2d231e1d2d9 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 13f5177c0f4..b6bf4a9b021 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 @@ class TReflection { // 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 @@ class TReflection { } // 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 afdc7d1eb26..4e4d695c696 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 @@ class TProgram { 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 e795e8dc90d..8aee0cf88e4 100644 --- a/deps/glslang/glslang/gtests/TestFixture.h +++ b/deps/glslang/glslang/gtests/TestFixture.h @@ -258,7 +258,7 @@ class GlslangTest : public GT { glslang::TProgram program; program.addShader(&shader); - + success &= program.link(controls); success &= program.mapIO(); @@ -330,7 +330,7 @@ class GlslangTest : public GT { 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 8804b217ec7..ad124cb7556 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 206df9b887a..1de4f36d03f 100755 --- a/deps/glslang/glslang/hlsl/hlslParseHelper.h +++ b/deps/glslang/glslang/hlsl/hlslParseHelper.h @@ -263,7 +263,7 @@ class HlslParseContext : public TParseContextBase { // * 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 c8375900308..3c93b178e65 100755 --- a/deps/glslang/glslang/hlsl/hlslParseables.h +++ b/deps/glslang/glslang/hlsl/hlslParseables.h @@ -52,7 +52,7 @@ class TBuiltInParseablesHlsl : public TBuiltInParseables { 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 6902070cbe3..cfa63b7cfec 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 526cfd68755..2097cedc127 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 9d43071fb2a..452bd4e51e4 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 1fa1c2d8015..9218c5d172f 100644 --- a/deps/mbedtls/ecjpake.c +++ b/deps/mbedtls/ecjpake.c @@ -299,7 +299,7 @@ static int ecjpake_zkp_read( const mbedtls_md_info_t *md_info, */ 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 2991e26dd9b..1a0fcd688ca 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 7d7469d509e..a1a804be4c4 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 9101d9cc7c4..8ef79fdad38 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 a2b9f8cfe11..b73e4164586 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 f137c3dce61..be961af710c 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 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) /* * 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 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) 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 a6dce95ba29..a2305beb2e8 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/stb/stb_image.h b/deps/stb/stb_image.h index 3349700b815..323ce6df12f 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 f31258adb99..6c658de33e5 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 ba3dd5acc0c..4e1b8a97e71 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 f662695711a..6adaff49401 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; @@ -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 486e9dcc2cd..35b7ad54133 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. @@ -82,7 +82,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); diff --git a/dirs.h b/dirs.h index f69bb06715c..e9bc186c69d 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 fbee1c29f19..7cadd24508c 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. @@ -145,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)) @@ -253,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) @@ -266,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); @@ -279,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. * @@ -397,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 1120253e656..49d61bbf07a 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 7661316f22b..5e9bce61cb9 100644 --- a/dynamic.c +++ b/dynamic.c @@ -199,11 +199,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 +339,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 +712,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 +730,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 +742,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 +757,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 +765,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 +942,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 +1238,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 +1253,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 +1392,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 +1494,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) } break; } - + case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: { if (system) @@ -1575,9 +1575,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 +1617,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 { diff --git a/dynamic.h b/dynamic.h index d2b529520ba..2432704e489 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 ce976bf261c..219c7197205 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 7d3b7b6b286..015d7e0ae4a 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_gx.c b/frontend/drivers/platform_gx.c index 8443348c639..541e1363bf4 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -405,7 +405,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], diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 9360feef2d6..e6d49fcf43d 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. @@ -56,7 +56,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; @@ -189,7 +189,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"); diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index b115e22520b..d9ec683b242 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -45,7 +45,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; } diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 80bd183322d..43847effee2 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1502,7 +1502,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 +1592,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 +1606,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 +1621,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 +1650,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 +1664,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 +1768,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 +2035,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 +2175,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 db5eacceb3c..c5a028ccc89 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 ac5ebfaea34..51b0d9c148c 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_win32.c b/frontend/drivers/platform_win32.c index 64703e4dcb9..31b238c814a 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -42,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. */ @@ -89,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) { @@ -116,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) { @@ -292,11 +292,11 @@ 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) @@ -307,7 +307,7 @@ static void frontend_win32_init(void *data) setDPIAwareProc(); } } - + } enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent) @@ -471,7 +471,7 @@ 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 >= 0x0500 MEMORYSTATUSEX mem_info; @@ -492,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) @@ -534,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 3c626285d85..e67d5935baf 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 b6dcca2cd25..137d9fa0bf7 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 fed99639ce9..ef821097c47 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 e8c2441e29b..52868ec0c89 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 07976b7393e..5de2e746c93 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 8fd61d2aad9..fa88fb2e55c 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 4fd335a8f61..72705103378 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 c8a4e5f3e4a..97f6b2a97ce 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 b1d11ec999b..33052c83e13 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 e66e1c17040..87458dac9aa 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 691213f7b67..a0dd747c240 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 70f48b666d0..e82f889567d 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 10c139bef01..98a4c41c588 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. diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 7fb5527dcfe..46b1c0b6214 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. diff --git a/gfx/common/vita2d_common.h b/gfx/common/vita2d_common.h index 010f3fca108..39006586a83 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 02717d7d3fd..257952d93a9 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 cab3af0bd36..91990eadb4f 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.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. @@ -162,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, @@ -413,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) { @@ -657,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 @@ -733,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. @@ -774,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; @@ -873,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) { @@ -939,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; @@ -982,7 +982,7 @@ 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); @@ -1011,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; @@ -1120,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; } @@ -1149,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; @@ -1194,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; @@ -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; } @@ -2386,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(); @@ -2421,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; @@ -2531,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 @@ -2565,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, diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 732e7173e18..e4714142ef9 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. diff --git a/gfx/common/wayland_common.h b/gfx/common/wayland_common.h index 4cec21d3860..e48f4509071 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 426632bbd07..766838e6716 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. @@ -673,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, diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c87a991fdb8..9df4db82468 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 1375fd11868..c7894ed41d3 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. @@ -139,7 +139,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; @@ -252,7 +252,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; @@ -391,7 +391,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) @@ -407,7 +407,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. */ @@ -464,7 +464,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; diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index d70f2d28c6f..23fc4898bc8 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 0ce48c66ed0..34879e82759 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 e66c17b8495..3a7e00e4cfc 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/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 0aabb51ccd3..720fac08343 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 48aefd123ec..4ef1375f904 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 efd0d7ca76a..dc72306b8e0 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 18afe085aed..5eeaf51e7b8 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 01fb0dec6a2..4516bd10e1f 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 4b0476f4b5e..6d0efe41e75 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 b1ded17fdb8..c28aa01784b 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; @@ -493,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 c717513f74d..27c79b9a1e2 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -740,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 */ @@ -796,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); @@ -1033,7 +1033,7 @@ 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) { @@ -1082,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; @@ -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); diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h index 1b048d2223f..c6ad48e0714 100644 --- a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -1,4 +1,4 @@ -/* credits to: TheTimJames +/* credits to: TheTimJames https://www.shadertoy.com/view/Md2GRw */ @@ -17,17 +17,17 @@ static const char* stock_fragment_xmb_snowflake = GLSL( } 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; @@ -41,7 +41,7 @@ static const char* stock_fragment_xmb_snowflake = GLSL( } return col * pos.z; } - + return 0.0; } @@ -54,12 +54,12 @@ static const char* stock_fragment_xmb_snowflake = GLSL( 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); + + color += snow(vec3(x,y,z), c, o); } - + return color; - } + } void main(void) { @@ -67,9 +67,9 @@ static const char* stock_fragment_xmb_snowflake = GLSL( 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)); } 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 256ae4378bd..52f2385bbee 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/gx_gfx.c b/gfx/drivers/gx_gfx.c index 14b7f61c388..7726a4a8765 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. @@ -270,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; @@ -304,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()); @@ -418,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; @@ -485,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 }; @@ -495,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); @@ -507,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"); @@ -524,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); } @@ -977,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) @@ -1111,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; @@ -1213,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; } @@ -1379,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; } @@ -1647,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 104650f040f..5b7a4ca905c 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 128fab83b57..8133a8dcf59 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 4d2021379c2..5798f56149d 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 8431ebb531b..a77061f6e59 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 7f2060296c5..0e2d2d473a1 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 90a9eadbc54..2c4eecbe5fa 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 9bbf4311865..301dec6e19b 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 8cc1ba72be2..8e4c13ee355 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 dafcb40fb7e..f18f2ba290a 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; @@ -170,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}}; @@ -245,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] = { @@ -268,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}; @@ -517,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, @@ -622,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); @@ -761,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) @@ -848,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, @@ -1072,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(); @@ -1171,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"); @@ -1195,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); @@ -1422,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); @@ -1604,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. */ @@ -1658,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( @@ -1685,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); } @@ -1849,8 +1849,8 @@ static bool vulkan_frame(void *data, const void *frame, 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. @@ -2068,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; @@ -2095,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; @@ -2369,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++, @@ -2532,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 3832e7c5380..9101d047ccf 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 75882f5f217..900a8a61a48 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 dc3738c5515..8df8f528bbe 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 341aa465c62..acd73fe27cf 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; @@ -370,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: @@ -582,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 4593b46d8ec..53e923da926 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 d5e3923be9e..4a5e6d667dc 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 e5eb203075b..5c101eb57f8 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 @@ static void *gfx_ctx_drm_init(video_frame_info_t *video_info, void *video_driver 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 9d1e5980ae8..eee7296ad44 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 e6bf37c8194..1dd79a9b6f4 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 53e3bfb5285..b0dd26cc643 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. @@ -242,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 e9b97dbe782..aa7e7395b42 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 b50317e2002..9ad56bc662e 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 0c3775ec581..050e241db9f 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,15 +119,15 @@ 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) { @@ -195,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 } @@ -224,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; @@ -265,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 6c9f70df405..4827c7da849 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 26e1b695f4e..62714cf62cf 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 17fdf3e19b0..10ea704ee6f 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 cde0887fb05..29f45c925bc 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 @@ -1133,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 9b5e441503a..c6179a088f0 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. @@ -159,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) @@ -203,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) @@ -280,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; @@ -462,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 1faa28b95f6..64673379cd5 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) @@ -706,8 +706,8 @@ 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); @@ -740,13 +740,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(). */ @@ -756,7 +756,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(). */ @@ -788,7 +788,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; @@ -864,7 +864,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; } @@ -923,7 +923,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 351c021215d..59d7d65c620 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 6d6f37196a3..0454aa3844b 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 e78054768b5..08d3080ce58 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 892197f16b9..c0c707689ee 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 177b38b2bfe..133de8af2f6 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. diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 16a2bbc55fe..72d84a32052 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 25268c031e6..d98f1d8cd3e 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 229186e3c76..a217494edc4 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 7a4777a3eb9..f6cdcace8ae 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 c76910b5007..a562aa33b0f 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. * 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); @@ -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 4e0c808d640..f76883f683c 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 5a5a4ba82b1..84830215329 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 b6d289ec034..71a09964205 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 9205e00f228..33a321b97e3 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 966ab74548d..2c4edbf965b 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. @@ -263,7 +263,7 @@ static void *font_renderer_ft_init(const char *font_path, float font_size) 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[] = { diff --git a/gfx/drivers_font_renderer/stb_unicode.c b/gfx/drivers_font_renderer/stb_unicode.c index d22a461f619..878b3cd93d4 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) diff --git a/gfx/drivers_renderchain/d3d8_renderchain.c b/gfx/drivers_renderchain/d3d8_renderchain.c index faef44aee72..3427ce988e4 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 8d96721d86f..b40c011604a 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 56a5d27650c..3eb1f887c74 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. @@ -213,7 +213,7 @@ 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, diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 9f4a14fb07f..95168fb8aa6 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. @@ -177,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); @@ -198,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; } @@ -221,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; } @@ -248,7 +248,7 @@ static bool gl_recreate_fbo( RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *texture, 0); - if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) + if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) == RARCH_GL_FRAMEBUFFER_COMPLETE) return true; @@ -256,13 +256,13 @@ static bool gl_recreate_fbo( return false; } -static void gl_check_fbo_dimension(gl_t *gl, +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; @@ -275,14 +275,14 @@ static void gl_check_fbo_dimension(gl_t *gl, 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); @@ -293,7 +293,7 @@ static void gl_check_fbo_dimension(gl_t *gl, 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, @@ -309,7 +309,7 @@ static void gl2_renderchain_check_fbo_dimensions(void *data, 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) || @@ -590,7 +590,7 @@ static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) 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); @@ -606,7 +606,7 @@ static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) return false; } -static void gl_create_fbo_texture(gl_t *gl, +static void gl_create_fbo_texture(gl_t *gl, void *chain_data, unsigned i, GLuint texture) { GLenum mag_filter, wrap_enum; @@ -617,7 +617,7 @@ static void gl_create_fbo_texture(gl_t *gl, 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); @@ -628,7 +628,7 @@ static void gl_create_fbo_texture(gl_t *gl, 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); } @@ -663,21 +663,21 @@ static void gl_create_fbo_texture(gl_t *gl, { #ifndef HAVE_OPENGLES bool srgb_fbo = chain->fbo_scale[i].srgb_fbo; - + if (!fp_fbo && 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 && 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, @@ -700,7 +700,7 @@ static void gl_create_fbo_texture(gl_t *gl, 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, @@ -734,7 +734,7 @@ static void gl_create_fbo_textures(gl_t *gl, void *chain_data) } /* 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( @@ -807,7 +807,7 @@ static void gl2_renderchain_start_render(void *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, @@ -825,7 +825,7 @@ static void gl2_renderchain_start_render(void *data, 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. */ @@ -885,7 +885,7 @@ void gl2_renderchain_init( 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; } @@ -902,7 +902,7 @@ void gl2_renderchain_init( if (!chain->fbo_scale[i].valid) { 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 = + chain->fbo_scale[i].type_x = chain->fbo_scale[i].type_y = RARCH_SCALE_INPUT; chain->fbo_scale[i].valid = true; } @@ -923,7 +923,7 @@ 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 + if (gl->fbo_feedback_enable && gl->fbo_feedback_pass < (unsigned)chain->fbo_pass) { RARCH_LOG("[GL]: Creating feedback FBO %d @ %ux%u\n", i, @@ -1064,7 +1064,7 @@ static void gl2_renderchain_bind_prev_texture( 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) { @@ -1098,7 +1098,7 @@ static void gl2_renderchain_viewport_info( } static bool gl2_renderchain_read_viewport( - void *data, + void *data, void *chain_data, uint8_t *buffer, bool is_idle) { @@ -1160,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 @@ -1272,7 +1272,7 @@ static void gl2_renderchain_restore_default_state( } static void gl2_renderchain_copy_frame( - void *data, + void *data, void *chain_data, video_frame_info_t *video_info, const void *frame, @@ -1280,7 +1280,7 @@ static void gl2_renderchain_copy_frame( { gl_t *gl = (gl_t*)data; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - + (void)chain; #if defined(HAVE_PSGL) @@ -1315,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) diff --git a/gfx/drivers_renderchain/null_renderchain.c b/gfx/drivers_renderchain/null_renderchain.c index a3ed173615e..c017cb98760 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 e37b40352c5..34bb362d9c9 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 e013c95acfd..dc5b96528da 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -525,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", @@ -737,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++) @@ -1465,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); @@ -1497,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 7f77693a599..311bccdc95e 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 9ffedf5ef1e..afc79cf913b 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 77bbe3c5995..b5be3eb16f7 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 8ee92bff403..d85cfd1b97b 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 26c373023e3..79ac7f2d8f5 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 e889f319473..d2c94de12da 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 4abdb929f25..3addbc790c5 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 1390412f68c..61969afe566 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 eaa3ef6a85d..2656d358c65 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 a1381696b44..a0d2948292d 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. diff --git a/gfx/include/d3d8/d3d8.h b/gfx/include/d3d8/d3d8.h index 2600282c16e..adf91ebf0b7 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 a7d30d74ebe..fc2688c43a7 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 7db338f9b47..2d70af640cb 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 96fc382815d..84449358770 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 fa15ff778ac..a1a68fd6b68 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 d4cadd95b9a..f17d92c8bde 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 c4d36309838..e874d6479f5 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 2bdfce8b823..cb30a7cf37a 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 ecdabdc52c4..0d0a945344c 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 c3df8ce5c33..e3e10bd37e6 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 4fbb3f75aab..3947c7a91b6 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 165014b0dfc..f861629e0dc 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 6798c5898f0..2418f7acdb2 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 74e40cfc804..174ec6667b4 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; diff --git a/gfx/include/d3d9/d3dx9shape.h b/gfx/include/d3d9/d3dx9shape.h index 9d1ff52e7f2..cc0c618c5aa 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 ec29c0187af..4de1ead96ca 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 6b47acd2734..0ad3a1250f8 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 adc3fb1f8de..cd89f29450f 100644 --- a/gfx/include/d3d9caps.h +++ b/gfx/include/d3d9caps.h @@ -107,14 +107,14 @@ 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 */ @@ -211,7 +211,7 @@ typedef struct _D3DCAPS9 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 MaxVertexShader30InstructionSlots; DWORD MaxPixelShader30InstructionSlots; } D3DCAPS9; @@ -250,7 +250,7 @@ typedef struct _D3DCAPS9 */ #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L -/* Indicates that the device can perform a gamma correction from +/* 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 @@ -354,7 +354,7 @@ 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 /* @@ -428,7 +428,7 @@ 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 */ /* diff --git a/gfx/include/d3d9types.h b/gfx/include/d3d9types.h index b4b9a94ddf0..ef96fda4969 100644 --- a/gfx/include/d3d9types.h +++ b/gfx/include/d3d9types.h @@ -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 */ @@ -1632,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 */ @@ -1657,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 @@ -1984,7 +1984,7 @@ typedef struct _D3DPRESENTSTATS { typedef enum D3DSCANLINEORDERING { - D3DSCANLINEORDERING_UNKNOWN = 0, + D3DSCANLINEORDERING_UNKNOWN = 0, D3DSCANLINEORDERING_PROGRESSIVE = 1, D3DSCANLINEORDERING_INTERLACED = 2, } D3DSCANLINEORDERING; @@ -2046,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 @@ -2062,7 +2062,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { struct { - UINT ProtectionEnabled : 1; + UINT ProtectionEnabled : 1; UINT OverlayOrFullscreenRequired : 1; UINT Reserved : 30; }; @@ -2080,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 @@ -2092,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 @@ -2104,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 @@ -2126,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 @@ -2138,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 @@ -2167,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 @@ -2179,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 @@ -2187,7 +2187,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT; @@ -2196,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 @@ -2210,7 +2210,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT OutputIDIndex; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT; @@ -2220,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 @@ -2241,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 @@ -2256,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 @@ -2268,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 @@ -2289,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 @@ -2303,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 @@ -2333,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 @@ -2345,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 @@ -2359,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 @@ -2373,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 @@ -2386,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 121738c08fa..463e0a17317 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 835b9ba967f..f06a619861a 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 9a3ec1e1dbd..1dee18db50c 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_driver.c b/gfx/video_driver.c index b07d869967e..0302d7008b6 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -175,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; @@ -192,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; @@ -212,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. * @@ -665,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 @@ -690,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; @@ -718,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. */ @@ -783,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( @@ -838,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); @@ -1057,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)) { @@ -1390,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); @@ -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; @@ -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 @@ -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 43bbef97ca9..6abae88e137 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -206,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); @@ -340,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; @@ -370,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. @@ -391,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; @@ -720,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, @@ -737,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); @@ -804,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); @@ -840,7 +840,7 @@ 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 (*set_mvp)(void *data, void *chain_data, void *shader_data, const void *mat_data); @@ -860,7 +860,7 @@ typedef struct gl_renderchain_driver void (*bind_pbo)(unsigned idx); 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, @@ -957,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); @@ -968,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); @@ -989,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); @@ -1092,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, @@ -1194,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 9c4f1bf7409..86976263a2f 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 4dd94db1d09..ef978ee7414 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 42a005143a8..7accb0ae6ff 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 a8a3ea715a8..334885981e9 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 b4b3a573a17..17cdce73348 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 2fa0407d968..0256f80ca6b 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 fc362801adb..e00be0d29bf 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 1d3db0a02c2..8ba64afe2ad 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 34269b236d6..e1125be4bc2 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 8ea1363ba4f..bb330313898 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 82205e01152..d9aa710e27b 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 2d3c6545891..fc9be637393 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 937e3fba8d4..99cd10eedc5 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 1d5c2bf309e..f9dc321a9c0 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 06b7c4c8c11..a191d104c36 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 e8f18968a7c..3194beb4c8f 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. @@ -79,7 +79,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. * @@ -108,7 +108,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. @@ -144,10 +144,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'; @@ -332,7 +332,7 @@ static bool video_shader_parse_pass(config_file_t *conf, return false; } -/** +/** * video_shader_parse_textures: * @conf : Preset file to read from. * @shader : Shader pass handle. @@ -385,7 +385,7 @@ static bool video_shader_parse_textures(config_file_t *conf, if (path_file_exists(tmp_path)) { - strlcpy(shader->lut[shader->luts].path, + strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); } @@ -394,7 +394,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; @@ -420,7 +420,7 @@ static bool video_shader_parse_textures(config_file_t *conf, return false; } -/** +/** * video_shader_parse_find_parameter: * @params : Shader parameter handle. * @num_params : Number of shader params in @params. @@ -445,7 +445,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. @@ -478,10 +478,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); @@ -500,12 +500,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). **/ @@ -595,12 +595,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). **/ @@ -615,7 +615,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); @@ -637,10 +637,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)); @@ -739,13 +739,13 @@ static bool video_shader_parse_imports(config_file_t *conf, 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). **/ @@ -925,13 +925,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) @@ -1001,7 +1001,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); @@ -1038,7 +1038,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); } @@ -1087,7 +1087,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) @@ -1127,7 +1127,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; @@ -1165,7 +1165,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 4dcbabfcf79..cb79c1f09c0 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 8cebede20f9..a36a50f8fba 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 abcd2e27e8a..649f48e4204 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 59739117f4e..3fc697d2608 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 31c2010cff9..3fd306590a8 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/input/common/input_x11_common.c b/input/common/input_x11_common.c index d9598496e0e..dbbe53fc43e 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 4d325e4525b..a0cd0342d51 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 17825654a33..0d35611db1c 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 b924b7246d6..701adbbd88c 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_ps4.c b/input/connect/connect_ps4.c index dcdd88a41ec..ee5ead5c326 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -188,7 +188,7 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; - struct ps4 *rpt = device ? + struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; if (!device || !rpt) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 6356fc94fa8..c3787bbe3cc 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -121,7 +121,7 @@ static void hidpad_wiiupro_deinit(void *data) static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) { struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; - struct wiiupro *rpt = device ? + struct wiiupro *rpt = device ? (struct wiiupro*)&device->data : NULL; if (!device || !rpt) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index f25477e3727..2eb4884bce9 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.h b/input/drivers/cocoa_input.h index 33194837f5f..62f21b4904b 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 9871a9669d3..359dc9f5eb9 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/gx_input.c b/input/drivers/gx_input.c index b4daff900df..cecbc92643a 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 eee4a70cd61..5c2b780e9a8 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 78498f88dc3..edb3c93e3e8 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 b5e2037027b..8edc8419600 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 9d2fde4d96a..3506b7e029f 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 5b462d55ff1..5376f2b9ce0 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/wayland_input.c b/input/drivers/wayland_input.c index 21ff4845684..6fab41d99ff 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/winraw_input.c b/input/drivers/winraw_input.c index fa6011291d3..2b15c53c1bc 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -1,857 +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_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, -}; +/* 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 e21e9a100e1..9e357870bff 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. @@ -156,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; @@ -164,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; @@ -421,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 d6c45a6d8a2..a603d0ae623 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 e1d1142bb90..f1c933a68e9 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/libusb_hid.c b/input/drivers_hid/libusb_hid.c index f2fd6d0bca0..c03004b3959 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -94,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, @@ -180,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 @@ -191,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) diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index b04e7397905..c92d9179ad4 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. @@ -141,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/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index fa141059e06..05ccfad1a54 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/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index f7eb8bd3478..77a9680d521 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. @@ -96,8 +96,8 @@ typedef struct #define ERROR_DEVICE_NOT_CONNECTED 1167 #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. * @@ -191,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"); @@ -255,7 +255,7 @@ static bool xinput_joypad_init(void *data) (!g_xinput_states[3].connected)) return false; - RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + + 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; @@ -350,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) @@ -420,7 +420,7 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) 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; @@ -475,8 +475,8 @@ 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; } @@ -507,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 cd7b7e27dd7..6c2f95bec8a 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 d80fb2f606f..27e77f78a4b 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 f9b76ad4a64..62f23feff96 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 0cecb855760..0239f5087d6 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 eae2f1e4c02..b406d12e737 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 5eab6264ce2..7a7980338eb 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 1bb95f3003b..7fab120c55e 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 65e977cee42..735bceb9f32 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 afb15b3c6d8..5bb1398d15a 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 00e4fcb0de8..e293ce24e80 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 8f6cd125f10..e8500d25fb6 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 74de5c3558b..2c318fcb699 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 b81922483cf..117efdc9c5f 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/input_driver.c b/input/input_driver.c index bbd4ed099be..3765d399168 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. @@ -336,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. **/ @@ -557,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; @@ -608,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, @@ -627,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(); @@ -695,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); @@ -706,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); } @@ -803,10 +803,10 @@ 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 + uint8_t port_max = + settings->bools.input_all_users_control_menu ? max_users : 1; - + joypad_info.joy_idx = 0; joypad_info.auto_binds = NULL; @@ -815,7 +815,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* 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; @@ -840,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)) { @@ -862,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++) @@ -883,7 +883,7 @@ 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) @@ -1048,7 +1048,7 @@ void input_keys_pressed(void *data, retro_bits_t* 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; @@ -1065,7 +1065,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) 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) @@ -1098,7 +1098,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) } #ifdef HAVE_OVERLAY - if (overlay_ptr && + if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { BIT256_SET_PTR(p_new_state, i); @@ -1123,7 +1123,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) #endif #ifdef HAVE_NETWORKGAMEPAD - if (input_driver_remote && + if (input_driver_remote && input_remote_key_pressed(i, 0)) { BIT256_SET_PTR(p_new_state, i); @@ -1503,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. @@ -1554,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. * @@ -1600,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. @@ -1715,12 +1715,12 @@ int16_t input_joypad_analog(const input_device_driver_t *drv, } /** - * 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 @@ -1799,7 +1799,7 @@ bool input_mouse_button_raw(unsigned port, unsigned id) /** * 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. @@ -1955,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') @@ -2069,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. @@ -2213,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; @@ -2222,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; @@ -2231,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; @@ -2240,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; @@ -2286,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; @@ -2330,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) @@ -2585,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 @@ -2719,7 +2719,7 @@ 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(); } } diff --git a/input/input_keymaps.c b/input/input_keymaps.c index ddd900a45fa..ef4345e8c39 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 19504364544..11757f2f680 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 0cfd365c300..decfea1716c 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 500faab4a02..c50519acd84 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 01bea5f40cc..384d589015e 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 ba81955f388..cac22693881 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 68e0d7363e4..1493368454e 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -90,15 +90,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++) @@ -244,7 +244,7 @@ bool input_remapping_remove_file(const char *path) ret = path_file_remove(remap_file) == 0 ? true : false;; free(buf); free(remap_file); - return ret; + return ret; } void input_remapping_set_defaults(bool deinit) @@ -252,7 +252,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 +273,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 e66b8f5ae08..d74529c7d2d 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 861cea91498..a80185a724d 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_pt_br.c b/intl/msg_hash_pt_br.c index 37f690c57d1..3f60fba684d 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/lakka.h b/lakka.h index f1659d2ef8f..60d117cbdb0 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 ac1dc1e25de..bd40ccb63cb 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 e6bc09eff2e..3e912cb9746 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 @@ static void audio_mixer_mix_mod(float* buffer, size_t num_frames, 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 3010cb798a2..bb979459714 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 ff727913d3b..814ddd82612 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 0b695ec87e2..7f428eee12b 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 d48c346fb09..54d9aa715ad 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 4033aa6512e..a3defe77e1a 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 801e9085696..748d0b8c1e4 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 52935bb88e9..da1cbc3d10f 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 a7cc0c2f47e..0a4b8b3ff85 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 c5244851a6a..65ced854f6b 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