mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-12 12:39:56 +00:00
Merge branch 'master' into International-translations-update
This commit is contained in:
commit
80c1b54b52
90
CHANGES.md
90
CHANGES.md
@ -1,10 +1,72 @@
|
||||
# Future
|
||||
- AUDIO/JACK: Fix regression introduced after 1.8.4 - would hang at startup
|
||||
- CHEEVOS: Disable hardcore when cheats are enabled
|
||||
- CHD: Return false when special track cannot be found
|
||||
- DISCORD/MATCHMAKING: Fix Discord 'Ask To Join' functionality
|
||||
- INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button
|
||||
- INPUT MAPPING/REMAPPING: Fix 'reset to default' action for analog sticks and undefined core inputs
|
||||
- MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error
|
||||
- MENU/OZONE/ANDROIDTV: Default to Ozone menu driver
|
||||
- MENU/OZONE/ANDROID: Gamepad-like devices default to Ozone now (Shield Portable)
|
||||
- NETPLAY: Lower announcement rate
|
||||
- OVERLAYS: Fix memory leak when loading overlays
|
||||
- WIIU: Gamepad hotplugging support
|
||||
- WIIU: Theoretical multi-gamepad support
|
||||
|
||||
# 1.8.7
|
||||
- 3DS: Add IDs for Frodo
|
||||
- 3DS: Enable basic networking / cheevos
|
||||
- CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games)
|
||||
- CHEEVOS: Option to start a session with all achievements active
|
||||
- CHEEVOS: Don't perform unnecessary cheevos initialisation when cheevos are disabled. Should reduce startup times when loading content.
|
||||
- CORE OPTIONS: Disable 'Use Global Core Options File' by default
|
||||
- DOS/DJGPP: Add 32bit color support for cores
|
||||
- GLCORE: Switch to glcore video driver when requested by a core
|
||||
- LINUX/XDG: Use GenericName correctly in desktop entry
|
||||
- MAC/COCOA: Fix mouse cursor tracking
|
||||
- MENU/MATERIALUI: Add desktop-style playlist view mode
|
||||
- MENU/MATERIALUI/DESKTOPVIEW: When scrolling playlists, show last selected thumbnails while waiting for next entry to load
|
||||
- MENU/MATERIALUI: Limit tab switch rate when input repeat is active
|
||||
- MENU/OZONE: Fix sidebar playlist sort order when 'Truncate Playlist Names' is enabled
|
||||
- MENU/RGUI: Adjusted menu defaults, adjusted default scrolling speed
|
||||
- MENU/RGUI: Enable custom wallpaper when menu size is reduced at low resolutions
|
||||
- MENU/XMB: Limit tab switch rate when input repeat is active
|
||||
- NETPLAY: Fix regressions introduced in 1.8.5
|
||||
- RGUI: Add option to always stretch menu to fill the screen
|
||||
- WIIU: Enable graphics widgets
|
||||
|
||||
# 1.8.6
|
||||
- 3DS: Add IDs for UZEM, TGB Dual, and NeoCD
|
||||
- 3DS: Fix font driver horizontal text alignment
|
||||
- 3DS: Allow button presses up to INPUT_MAX_USERS - this enables the 3DS to bind and use buttons and axis for users up to the maximum set by 'Max Users' in the input settings menu.
|
||||
- 3DS: Disable video filter if upscaled resolution exceeds hardware limits. The 3DS has a maximum video buffer size of 2048x2048. This is sufficient for every core that it supports, but when using software video filters the core output resolution is doubled. This is made worse by the fact that the video filter upscaling buffer size is dependent upon the maximum output resolution of the core - which in some cases is very large indeed (e.g. pcsx-rearmed sets a maximum width of 1024, for enhanced resolution support). The 3DS has very limited 'linear memory' for graphics buffer purposes, and a large base core buffer + video filter buffer can easily exceed this - which may also disable video output, or cause a crash. This PR very simply adds a 3DS-specific check to the video filter initialisation: if the resultant upscaling buffer exceeds the hardware limitation, then the filter is automatically disabled.
|
||||
- 3DS/FONT/BUGFIX: Text colour was wrong: the RGBA channels were muddled, and R was always set to 255
|
||||
- 3DS/FONT/BUGFIX: When drawing multiline strings, the line spacing was completely incorrect
|
||||
- 3DS/FONT: Improves the appearance of the drop shadow effect on notification text.
|
||||
- 3DS/ARCHIVE/7Z: Re-enable 7zip support.
|
||||
- ARCHIVE/ZIP: Expand functionality of 'rzip_stream' interface. This PR expands the functionality of the new rzip_stream archived stream interface such that it now has almost complete feature parity with the standard file_stream interface, and can therefore be used as a drop-in replacement in most situations
|
||||
- AI SERVICE: Hide redundant entries when service is disabled
|
||||
- AI SERVICE: Added in auto-translate support
|
||||
- AI SERVICE: support for NVDA and SAPI narration
|
||||
- AUTOCONFIG: Use correct port index in input device configured/disconnected notifications
|
||||
- BUGFIX: Fix race condition where task could momentarily not be in the queue when reordering
|
||||
- CHEEVOS/BUGFIX: Prevent null reference rendering achievement list while closing application
|
||||
- CHEEVOS/BUGFIX: Report non-memorymap GBA cores as unsupported
|
||||
- COMMANDLINE: Advise against using -s and -S variables on the command line. …
|
||||
- CONFIG FILE: Only write config files to disk when parameters change
|
||||
- CONFIG FILE/BUGFIX: RetroArch no longer crashes when attempting to save a config file after 'unsetting' a parameter (currently, this can be triggered quite easily by manipulating input remaps)
|
||||
- CONFIG FILE/BUGFIX: When using Material UI, RetroArch no longer modifies the wrong setting (or segfaults...) when tapping entries in the Quick Menu > Controls input remapping submenu
|
||||
- CONFIG FILE/BUGFIX: Quite a few real and potential memory leaks have been fixed.
|
||||
- CHD: Fixes a crash caused by ignoring the return value from one of the CHD library functions
|
||||
- FASTFORWARDING: A new Mute When Fast-Forwarding option has been added under Settings > Audio. When enabled, users can fast forward without having to listen to distorted audio.
|
||||
- GLCORE/SLANG: Set filter and wrap mode correctly when intialising shader textures. Before, the glcore shader driver did not correctly initialise loaded textures. The texture filtering and wrap mode were forced on texture creation, but these settings were not recorded - subsequent updates would set garbage values, that would resolve to linear filtering OFF and wrap mode = CLAMP_TO_EDGE.
|
||||
- LOCALIZATION: Update Japanese translation
|
||||
- LOCALIZATION: Update Spanish translation
|
||||
- LOCALIZATION: Update Portuguese Brazilian translation
|
||||
- IOS: Set audio session category to ambient so sound does not get cut off on interruption (phone call/playing back audio)
|
||||
- MAC/IOHIDMANAGER/BUGFIX: Fix for Mayflash N64 adapter. In case last hatswitch does not match cookie. For the mayflash N64 adapter, I was getting a BAD EXC ADDRESS (in mac OS 10.13) for this line (tmp was NULL). Retroarch would crash in the gui if I pressed a button from the DPAD on controller 2. With this change, it no longer crashes in the gui and still registers the button push.
|
||||
- MAC/COCOA: Fix mouse input - this brings back two lines of code that have been removed over time but
|
||||
appear to be required in order for mouse input to work on macOS
|
||||
- METAL/BUGFIX: GPU capture on Metal/OSX/NVidia could crash
|
||||
- METAL/BUGFIX: Taking screenshots could capture black frames. Resulting PNG screenshots were black.
|
||||
- METAL/BUGFIX: Corrupted image due to incorrect viewport copy when taking screenshot
|
||||
@ -16,13 +78,41 @@
|
||||
- MENU/OZONE: Hide 'Menu Color Theme' setting when 'Use preferred system color theme' is enabled
|
||||
- MENU/OZONE: Fix thumbnail switching via 'scan' button functionality
|
||||
- MENU/OZONE: Prevent glitches when rendering Ozone's selection cursor
|
||||
- MENU/OZONE: Enable proper vertical text alignment + thumbnail display improvements
|
||||
- MENU/OZONE: Enable second thumbnail/content metadata toggle using RetroPad 'select'
|
||||
- MENU/OZONE: Refactor footer display
|
||||
- MENU/OZONE: Hide thumbnail button hints when viewing file browser lists
|
||||
- MENU/OZONE/INPUT/BUGFIX: Fix undefined behaviour when using touch screen to change input remaps
|
||||
- MENU/OZONE/INPUT/BUGFIX: It turns out that Windows reports negative pointer coordinates when the mouse cursor goes beyond the left hand edge of the RetroArch window (this doesn't happen on Linux, so I never encountered this issue before!). As a result, if Ozone is currently not showing the sidebar (menu depth > 1), moving the cursor off the left edge of the window generates a false positive 'cursor in sidebar' event - which breaks menu navigation, as described in #10419. With this PR, we now handle 'cursor in sidebar' status correctly in all cases
|
||||
- MENU/OZONE/INPUT/BUGFIX: Pointer input is now correctly disabled when message boxes are displayed
|
||||
- MENU/XMB: Fix thumbnail switching via 'scan' button functionality
|
||||
- ODROID GO ADVANCE: Add DRM HW context driver
|
||||
- PSL1GHT: Initial port
|
||||
- PSL1GHT/KEYBOARD: Implement PSL1GHT keyboard
|
||||
- PLAYLIST/BUGFIX: Improve handling of 'broken' playlists - RetroArch will no longer segfault when attempting to run content via a playlist entry with missing path or core path fields.
|
||||
- PLAYLIST/BUGFIX: Improve handling of 'broken' playlists - when a playlist entry has either core path and/or core name set to NULL, DETECT or an empty string, attempting to load content will fallback to the normal 'core selection' code (currently this happens only if both core path and core name are DETECT - this is wholly inadequate!)
|
||||
- PLAYLIST/BUGFIX: RetroArch will no longer segfault when attempting to fetch content runtime information when core path is NULL
|
||||
- PLAYLIST/BUGFIX: Core name + runtime info will only be displayed on playlists and in the Information submenu if both the core path and core name fields are 'valid' (i.e. not NULL or DETECT)
|
||||
- PLAYLIST/BUGFIX: When handling entries with missing path fields, the menu sorting order now matches that of the playlist sorting order (at present, everything goes out of sync when paths are empty). Moreover, entries with missing path fields can now be 'selected', so users can remove them (currently, hitting A on such an entry immediately tries - and fails - to load the content, so the only way to remove the broken entry is via the Playlist Management > Clean Playlist feature)
|
||||
- PLAYLIST: Add optional per-playlist alphabetical sorting
|
||||
- PLAYLIST: Omit whitespace when writing compressed JSON format playlists
|
||||
- PLAYLIST: Add optional playlist compression
|
||||
- QNX: Support analog sticks
|
||||
- SAVESTATES: Add optional save state compression (enabled by default now)
|
||||
- SRAM: Add optional save (SRAM) file compression
|
||||
- SCANNER: Prevent redundant playlist entries when handling M3U content
|
||||
- SCANNER/ANDROID: Fix content scanner being unable to identify certain games from CHD images (raw data sector/subcode)
|
||||
- TASKS/BUGFIX: Fix task deadlocks
|
||||
- TASKS/SCREENSHOT/BUGFIX: Fix heap-use-after-free error when widgets are disabled
|
||||
- TVOS: Disable overlays for tvOS, fix app icon
|
||||
- VIDEO/WIDGETS/BUGFIX: The font ascender/descender metrics added in #10375 are now used to achieve 'pixel perfect' vertical text alignment
|
||||
- VIDEO/WIDGETS/BUGFIX: Message queue text now uses its own dedicated font. Previously, a single (larger) font was used for all active widgets, and this was scaled down for message queue items. This 'squished' the text a little; more importantly, when using the stb font renderers (on Android. etc.) it caused ugly artefacts around the edges of glyphs due to pixel interpolation errors. Now that a correctly sized font is used, the message queue is always rendered cleanly.
|
||||
- VIDEO/WIDGETS/BUGFIX: Previously, each widget font was 'flushed' (font_driver_flush()) at least once a frame. This is quite a slow operation. Now we only flush fonts if they have actually been used.
|
||||
- VULKAN/BUGFIX: Fix display of statistics text
|
||||
- UNIX/BUGFIX: Fix overflow when computing total memory on i386
|
||||
- WIIU/BUGFIX: Fix font driver horizontal text alignment
|
||||
- WIIU/BUGFIX: Fix non-vertex coordinates in draws using tex shader
|
||||
- WIIU/BUGFIX: Update and fix meta.xml file for the WiiU release. This change makes it so the information from the meta.xml file parsed for the WiiU's Homebrew Launcher is displayed properly.
|
||||
|
||||
# 1.8.5
|
||||
- 3DS: Keep the bottom screen hidden on sleep/wakeup. When the 3DS wakes back up after being closed, the bottom screen needs to be reinitialized. Adding the condition here will cause the screen to be turned on or off based on the state of ctr_bottom_screen_enabled, as you'd expect
|
||||
|
@ -1831,6 +1831,7 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
# Netplay
|
||||
DEFINES += -DHAVE_NETWORK_CMD
|
||||
OBJ += network/netplay/netplay_delta.o \
|
||||
network/netplay/netplay_frontend.o \
|
||||
network/netplay/netplay_handshake.o \
|
||||
network/netplay/netplay_init.o \
|
||||
network/netplay/netplay_io.o \
|
||||
@ -1845,24 +1846,27 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
DEFINES += -DHAVE_CHEEVOS
|
||||
INCLUDE_DIRS += -Ideps/rcheevos/include
|
||||
|
||||
OBJ += cheevos-new/cheevos.o \
|
||||
cheevos-new/badges.o \
|
||||
cheevos-new/fixup.o \
|
||||
cheevos-new/parser.o \
|
||||
cheevos-new/hash.o \
|
||||
OBJ += cheevos/cheevos.o \
|
||||
cheevos/badges.o \
|
||||
cheevos/fixup.o \
|
||||
cheevos/parser.o \
|
||||
cheevos/hash.o \
|
||||
$(LIBRETRO_COMM_DIR)/formats/cdfs/cdfs.o \
|
||||
deps/rcheevos/src/rcheevos/trigger.o \
|
||||
deps/rcheevos/src/rcheevos/condset.o \
|
||||
deps/rcheevos/src/rcheevos/condition.o \
|
||||
deps/rcheevos/src/rcheevos/operand.o \
|
||||
deps/rcheevos/src/rcheevos/term.o \
|
||||
deps/rcheevos/src/rcheevos/expression.o \
|
||||
deps/rcheevos/src/rcheevos/value.o \
|
||||
deps/rcheevos/src/rcheevos/lboard.o \
|
||||
deps/rcheevos/src/rcheevos/alloc.o \
|
||||
deps/rcheevos/src/rcheevos/compat.o \
|
||||
deps/rcheevos/src/rcheevos/condition.o \
|
||||
deps/rcheevos/src/rcheevos/condset.o \
|
||||
deps/rcheevos/src/rcheevos/consoleinfo.o \
|
||||
deps/rcheevos/src/rcheevos/format.o \
|
||||
deps/rcheevos/src/rcheevos/lboard.o \
|
||||
deps/rcheevos/src/rcheevos/memref.o \
|
||||
deps/rcheevos/src/rcheevos/operand.o \
|
||||
deps/rcheevos/src/rcheevos/richpresence.o \
|
||||
deps/rcheevos/src/rcheevos/runtime.o \
|
||||
deps/rcheevos/src/rcheevos/runtime_progress.o \
|
||||
deps/rcheevos/src/rcheevos/trigger.o \
|
||||
deps/rcheevos/src/rcheevos/value.o \
|
||||
deps/rcheevos/src/rhash/hash.o \
|
||||
deps/rcheevos/src/rurl/url.o
|
||||
|
||||
ifeq ($(HAVE_LUA), 1)
|
||||
@ -1911,7 +1915,8 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
ifeq ($(HAVE_DISCORD), 1)
|
||||
NEED_CXX_LINKER = 1
|
||||
DEFINES += -DHAVE_DISCORD
|
||||
INCLUDE_DIRS += -Ideps/discord-rpc/include/ -Ideps/discord-rpc/thirdparty/rapidjson-1.1.0/include/
|
||||
INCLUDE_DIRS += -Ideps/discord-rpc/include \
|
||||
-Ideps/discord-rpc/thirdparty/rapidjson-1.1.0/include/
|
||||
|
||||
ifneq ($(HAVE_THREADS), 1)
|
||||
DEFINES += -DDISCORD_DISABLE_IO_THREAD
|
||||
@ -1920,7 +1925,7 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
OBJ += deps/discord-rpc/src/discord_rpc.o \
|
||||
deps/discord-rpc/src/rpc_connection.o \
|
||||
deps/discord-rpc/src/serialization.o \
|
||||
discord/discord.o
|
||||
network/discord.o
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
OBJ += deps/discord-rpc/src/discord_register_win.o \
|
||||
|
@ -51,8 +51,9 @@ DEFINES :=
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJ += griffin/griffin.o
|
||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA
|
||||
#DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA -DHAVE_SOCKET_LEGACY -DHAVE_THREADS
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_7ZIP -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA
|
||||
DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA
|
||||
#DEFINES += -DHAVE_SOCKET_LEGACY -DHAVE_THREADS
|
||||
#-DHAVE_SSL -DHAVE_BUILTINMBEDTLS -DMBEDTLS_SSL_DEBUG_ALL
|
||||
#ssl is currently incompatible with griffin due to use of the "static" flag on repeating functions that will conflict when included in one file
|
||||
else
|
||||
@ -135,6 +136,7 @@ CFLAGS += -I. \
|
||||
-Ideps \
|
||||
-Ideps/7zip \
|
||||
-Ideps/stb \
|
||||
-Ideps/rcheevos/include \
|
||||
-Ilibretro-common/include \
|
||||
-Ilibretro-common/include/compat/zlib
|
||||
|
||||
|
@ -868,6 +868,46 @@ else ifneq (,$(findstring unix,$(platform)))
|
||||
EXT_INTER_TARGET := $(TARGET_NAME)
|
||||
INCLUDE += -Ilibretro-common/include -Igfx/include -Ideps -Ideps/stb -Ideps/rcheevos/include -Ideps/SPIRV-Cross -Ideps/glslang -I.
|
||||
LIBS += -ldl -lm -lpthread -lGL -ludev -lpulse -lX11 -lX11-xcb -lXxf86vm
|
||||
else ifeq (dos,$(platform))
|
||||
HAVE_AUDIOMIXER := 1
|
||||
HAVE_RPNG := 1
|
||||
HAVE_RJPEG := 1
|
||||
HAVE_RBMP := 1
|
||||
HAVE_RTGA := 1
|
||||
HAVE_ZLIB := 1
|
||||
HAVE_7ZIP := 1
|
||||
HAVE_NETWORKING := 0
|
||||
HAVE_NETWORK_CMD := 0
|
||||
HAVE_NETPLAYDISCOVERY := 0
|
||||
HAVE_OVERLAY := 1
|
||||
HAVE_VIDEO_LAYOUT := 0
|
||||
HAVE_MATERIALUI := 1
|
||||
HAVE_XMB := 0
|
||||
HAVE_STB_FONT := 1
|
||||
HAVE_THREADS := 0
|
||||
HAVE_LIBRETRODB := 1
|
||||
HAVE_COMMAND := 1
|
||||
HAVE_STDIN_CMD := 1
|
||||
HAVE_CMD := 1
|
||||
HAVE_DYLIB := 0
|
||||
HAVE_DYNAMIC := 0
|
||||
HAVE_GRIFFIN_CPP := 0
|
||||
WANT_GLSLANG := 0
|
||||
HAVE_CONFIGFILE := 1
|
||||
CC=i586-pc-msdosdjgpp-gcc
|
||||
CXX=i586-pc-msdosdjgpp-g++
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
PLATCFLAGS += -DHAVE_SHADERPIPELINE -DHAVE_CC_RESAMPLER -DRC_DISABLE_LUA -DHAVE_FBO -DHAVE_IMAGEVIEWER -DHAVE_LANGEXTRA -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_SPIRV_CROSS -DHAVE_STB_FONT -DRARCH_INTERNAL -DHAVE_XCB
|
||||
TARGET_NAME := retrodos
|
||||
EXT_TARGET := $(TARGET_NAME).exe
|
||||
EXT_INTER_TARGET := $(TARGET_NAME).exe
|
||||
INCLUDE += -Ilibretro-common/include -Igfx/include -Ideps -Ideps/stb -Ideps/SPIRV-Cross -Ideps/glslang -I.
|
||||
LIBS += -lm
|
||||
LIBDIRS += -L.
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring msvc,$(platform)))
|
||||
|
27
Makefile.ps2
27
Makefile.ps2
@ -11,8 +11,6 @@ PS2_IP = 192.168.1.150
|
||||
TARGET = retroarchps2.elf
|
||||
TARGET_RELEASE = retroarchps2-release.elf
|
||||
|
||||
# Lib CDVD
|
||||
CDVD_DIR = ps2/libcdvd
|
||||
|
||||
# Compile the IRXs first
|
||||
IRX_DIR = ps2/irx
|
||||
@ -30,7 +28,7 @@ ifeq ($(MUTE_WARNINGS), 1)
|
||||
DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses
|
||||
endif
|
||||
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(CDVD_DIR)/ee
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
|
||||
INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip
|
||||
INCDIR += -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper
|
||||
GPVAL = -G0
|
||||
@ -41,9 +39,9 @@ RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHA
|
||||
RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L$(CDVD_DIR)/lib -L.
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lmf -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz
|
||||
LIBS += -lcdvdfs -lpatches -lpoweroff
|
||||
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L.
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz
|
||||
LIBS += -lpatches -lpoweroff
|
||||
|
||||
ifeq ($(BUILD_FOR_PCSX2), 1)
|
||||
RARCH_DEFINES += -DBUILD_FOR_PCSX2
|
||||
@ -71,13 +69,10 @@ CFLAGS += $(RARCH_DEFINES)
|
||||
EE_OBJS += $(IRX_DIR)/freemtap_irx.o $(IRX_DIR)/freepad_irx.o $(IRX_DIR)/freesio2_irx.o $(IRX_DIR)/iomanX_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/fileXio_irx.o $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o $(IRX_DIR)/usbd_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/usbhdfsd_irx.o $(IRX_DIR)/freesd_irx.o $(IRX_DIR)/audsrv_irx.o $(IRX_DIR)/poweroff_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/cdvd_irx.o
|
||||
|
||||
# Missing objecst on the PS2SDK
|
||||
EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o ps2/compat_files/ps2_devices.o
|
||||
EE_OBJS += ps2/compat_files/fileXio_cdvd.o ps2/compat_files/ps2_descriptor.o
|
||||
EE_OBJS += ps2/compat_files/ps2_devices.o
|
||||
|
||||
#EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o
|
||||
EE_OBJS += griffin/griffin.o
|
||||
|
||||
EE_CFLAGS = $(CFLAGS)
|
||||
@ -106,7 +101,10 @@ prepare:
|
||||
run:
|
||||
ps2client -h $(PS2_IP) execee host:$(EE_BIN)
|
||||
|
||||
debug: clean prepare all run
|
||||
sim:
|
||||
PCSX2 --elf=$(PWD)/$(EE_BIN) --nogui
|
||||
|
||||
debug: clean all run
|
||||
|
||||
package:
|
||||
ps2-packer $(EE_BIN) $(TARGET_RELEASE)
|
||||
@ -115,9 +113,4 @@ release: clean all package
|
||||
|
||||
#Include preferences
|
||||
include $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||
|
||||
#Linking with C++
|
||||
$(EE_BIN): $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o
|
||||
$(EE_CXX) $(EE_NO_CRT) -T$(PS2SDK)/ee/startup/linkfile $(EE_CXXFLAGS) \
|
||||
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(EE_OBJS) $(CRTEND_OBJ) $(CRTN_OBJ) $(EE_LDFLAGS) $(EE_LIBS)
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal_cpp
|
||||
|
@ -87,7 +87,7 @@ AR := $(PREFIX)ar
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
STRIP := $(PREFIX)strip
|
||||
NM := $(PREFIX)nm
|
||||
LD := $(CXX)
|
||||
LD := $(CC)
|
||||
|
||||
LIBDIRS := -L.
|
||||
|
||||
@ -122,7 +122,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
VITA_LIBS := -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub \
|
||||
-lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceTouch_stub -lSceAudio_stub \
|
||||
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \
|
||||
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lpthread -lpng -lz
|
||||
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lstdc++ -lpthread -lpng -lz
|
||||
|
||||
LIBS := $(WHOLE_START) -lretro_vita $(WHOLE_END) $(VITA_LIBS) -lm -lc
|
||||
|
||||
|
@ -97,7 +97,7 @@ endif
|
||||
OBJ += gfx/drivers/gx2_shaders/snowflake.o
|
||||
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJ += griffin/griffin.o
|
||||
OBJ += griffin/griffin.o griffin/griffin_cpp.o
|
||||
|
||||
INCDIRS += -Ilibretro-common/include/compat/zlib
|
||||
# for stb, libfat, iosuhax
|
||||
@ -107,7 +107,7 @@ endif
|
||||
INCDIRS += -Ideps/SPIRV-Cross
|
||||
|
||||
DEFINES += -DHAVE_AUDIOMIXER
|
||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_LIBRETRODB
|
||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_LIBRETRODB
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_CC_RESAMPLER
|
||||
DEFINES += -DHAVE_SPIRV_CROSS -DHAVE_SLANG
|
||||
DEFINES += -DHAVE_STB_FONT -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB -DHAVE_NETWORKING -DHAVE_NETPLAYDISCOVERY
|
||||
@ -122,6 +122,7 @@ endif
|
||||
else
|
||||
HAVE_AUDIOMIXER = 1
|
||||
HAVE_MENU_COMMON = 1
|
||||
HAVE_GFX_WIDGETS = 1
|
||||
HAVE_RTGA = 1
|
||||
HAVE_RPNG = 1
|
||||
HAVE_RJPEG = 1
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <boolean.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
|
||||
#include "../../configuration.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
@ -96,13 +97,13 @@ static void shutdown_cb(void *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int parse_ports(const char *audio_device,
|
||||
char **dest_ports, const char **jports)
|
||||
static int parse_ports(char **dest_ports, const char **jports)
|
||||
{
|
||||
int i;
|
||||
char *save = NULL;
|
||||
int parsed = 0;
|
||||
char *audio_device_cpy = strdup(audio_device);
|
||||
settings_t *settings = config_get_ptr();
|
||||
char *audio_device_cpy = strdup(settings->arrays.audio_device);
|
||||
const char *con = strtok_r(audio_device_cpy, ",", &save);
|
||||
|
||||
if (con)
|
||||
@ -203,7 +204,7 @@ static void *ja_init(const char *device,
|
||||
}
|
||||
}
|
||||
|
||||
parsed = parse_ports(device, dest_ports, jports);
|
||||
parsed = parse_ports(dest_ports, jports);
|
||||
|
||||
if (jack_activate(jd->client) < 0)
|
||||
{
|
||||
|
@ -402,7 +402,7 @@ static bool v4l_poll(void *data,
|
||||
|
||||
if (preprocess_image(data))
|
||||
{
|
||||
if (frame_raw_cb != NULL)
|
||||
if (frame_raw_cb)
|
||||
frame_raw_cb(v4l->buffer_output, v4l->width,
|
||||
v4l->height, v4l->width * 4);
|
||||
return true;
|
||||
|
@ -54,7 +54,7 @@ void cheevos_set_menu_badge(int index, const char *badge, bool locked)
|
||||
uintptr_t cheevos_get_menu_badge_texture(int index)
|
||||
{
|
||||
if (index < CHEEVOS_MENU_BADGE_LIMIT)
|
||||
return cheevos_badge_menu_texture_list[index];
|
||||
return cheevos_badge_menu_texture_list[index];
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -65,7 +65,7 @@ uintptr_t cheevos_get_badge_texture(const char *badge, bool locked)
|
||||
{
|
||||
char badge_file[24];
|
||||
char fullpath[PATH_MAX_LENGTH];
|
||||
uintptr_t tex;
|
||||
uintptr_t tex = 0;
|
||||
|
||||
if (!badge)
|
||||
return 0;
|
||||
@ -76,8 +76,9 @@ uintptr_t cheevos_get_badge_texture(const char *badge, bool locked)
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES);
|
||||
|
||||
gfx_display_reset_textures_list(badge_file, fullpath,
|
||||
&tex, TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL);
|
||||
if (!gfx_display_reset_textures_list(badge_file, fullpath,
|
||||
&tex, TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
|
||||
tex = 0;
|
||||
|
||||
return tex;
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
#include <features/features_cpu.h>
|
||||
#include <formats/cdfs.h>
|
||||
#include <compat/strl.h>
|
||||
#include <rhash.h>
|
||||
#include <../libretro-common/include/rhash.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <retro_math.h>
|
||||
#include <net/net_http.h>
|
||||
@ -47,7 +47,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
#include "../discord/discord.h"
|
||||
#include "../network/discord.h"
|
||||
#endif
|
||||
|
||||
#include "badges.h"
|
||||
@ -81,9 +81,6 @@
|
||||
/* Define this macro to dump all cheevos' addresses. */
|
||||
#undef CHEEVOS_DUMP_ADDRS
|
||||
|
||||
/* Define this macro to remove HTTP timeouts. */
|
||||
#undef CHEEVOS_NO_TIMEOUT
|
||||
|
||||
/* Define this macro to load a JSON file from disk instead of downloading
|
||||
* from retroachievements.org. */
|
||||
#undef CHEEVOS_JSON_OVERRIDE
|
||||
@ -92,7 +89,7 @@
|
||||
* that name. */
|
||||
#undef CHEEVOS_SAVE_JSON
|
||||
|
||||
/* Define this macro to log URLs. */
|
||||
/* Define this macro to log URLs. */
|
||||
#undef CHEEVOS_LOG_URLS
|
||||
|
||||
/* Define this macro to have the password and token logged. THIS WILL DISCLOSE
|
||||
@ -210,8 +207,6 @@ bool rcheevos_loaded = false;
|
||||
bool rcheevos_hardcore_active = false;
|
||||
bool rcheevos_hardcore_paused = false;
|
||||
bool rcheevos_state_loaded_flag = false;
|
||||
int rcheevos_cheats_are_enabled = 0;
|
||||
int rcheevos_cheats_were_enabled = 0;
|
||||
char rcheevos_user_agent_prefix[128] = "";
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
@ -311,69 +306,94 @@ static void rcheevos_get_user_agent(char* buffer)
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
static void rcheevos_log_url(const char* format, const char* url)
|
||||
#ifdef CHEEVOS_LOG_URLS
|
||||
static void rcheevos_filter_url_param(char* url, char* param)
|
||||
{
|
||||
char* start;
|
||||
char* next;
|
||||
size_t param_len = strlen(param);
|
||||
|
||||
start = strchr(url, '?');
|
||||
if (!start)
|
||||
start = url;
|
||||
else
|
||||
++start;
|
||||
|
||||
do
|
||||
{
|
||||
next = strchr(start, '&');
|
||||
|
||||
if (start[param_len] == '=' && memcmp(start, param, param_len) == 0)
|
||||
{
|
||||
if (next)
|
||||
strcpy(start, next + 1);
|
||||
else if (start > url)
|
||||
start[-1] = '\0';
|
||||
else
|
||||
*start = '\0';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!next)
|
||||
return;
|
||||
|
||||
start = next + 1;
|
||||
} while (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rcheevos_log_url(const char* api, const char* url)
|
||||
{
|
||||
#ifdef CHEEVOS_LOG_URLS
|
||||
#ifdef CHEEVOS_LOG_PASSWORD
|
||||
CHEEVOS_LOG(format, url);
|
||||
#else
|
||||
#ifdef CHEEVOS_LOG_PASSWORD
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
|
||||
#else
|
||||
char copy[256];
|
||||
char* aux = NULL;
|
||||
char* next = NULL;
|
||||
|
||||
if (!string_is_empty(url))
|
||||
strlcpy(copy, url, sizeof(copy));
|
||||
|
||||
aux = strstr(copy, "?p=");
|
||||
|
||||
if (!aux)
|
||||
aux = strstr(copy, "&p=");
|
||||
|
||||
if (aux)
|
||||
{
|
||||
aux += 3;
|
||||
next = strchr(aux, '&');
|
||||
|
||||
if (next)
|
||||
{
|
||||
do
|
||||
{
|
||||
*aux++ = *next++;
|
||||
} while (next[-1] != 0);
|
||||
}
|
||||
else
|
||||
*aux = 0;
|
||||
}
|
||||
|
||||
aux = strstr(copy, "?t=");
|
||||
|
||||
if (!aux)
|
||||
aux = strstr(copy, "&t=");
|
||||
|
||||
if (aux)
|
||||
{
|
||||
aux += 3;
|
||||
next = strchr(aux, '&');
|
||||
|
||||
if (next)
|
||||
{
|
||||
do
|
||||
{
|
||||
*aux++ = *next++;
|
||||
} while (next[-1] != 0);
|
||||
}
|
||||
else
|
||||
*aux = 0;
|
||||
}
|
||||
|
||||
CHEEVOS_LOG(format, copy);
|
||||
#endif
|
||||
strlcpy(copy, url, sizeof(copy));
|
||||
rcheevos_filter_url_param(copy, "p");
|
||||
rcheevos_filter_url_param(copy, "t");
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, copy);
|
||||
#endif
|
||||
#else
|
||||
(void)format;
|
||||
(void)api;
|
||||
(void)url;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void rcheevos_log_post_url(const char* api, const char* url, const char* post)
|
||||
{
|
||||
#ifdef CHEEVOS_LOG_URLS
|
||||
#ifdef CHEEVOS_LOG_PASSWORD
|
||||
if (post && post[0])
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post);
|
||||
else
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
|
||||
#else
|
||||
if (post && post[0])
|
||||
{
|
||||
char post_copy[2048];
|
||||
strlcpy(post_copy, post, sizeof(post_copy));
|
||||
rcheevos_filter_url_param(post_copy, "p");
|
||||
rcheevos_filter_url_param(post_copy, "t");
|
||||
|
||||
if (post_copy[0])
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post_copy);
|
||||
else
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
(void)api;
|
||||
(void)url;
|
||||
(void)post;
|
||||
#endif
|
||||
}
|
||||
|
||||
static retro_time_t rcheevos_async_send_rich_presence(rcheevos_async_io_request* request);
|
||||
static void rcheevos_async_award_achievement(rcheevos_async_io_request* request);
|
||||
static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request);
|
||||
@ -442,39 +462,6 @@ static void rcheevos_async_task_callback(retro_task_t* task, void* task_data, vo
|
||||
}
|
||||
}
|
||||
|
||||
static const char* rcheevos_rc_error(int ret)
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case RC_OK: return "Ok";
|
||||
case RC_INVALID_LUA_OPERAND: return "Invalid Lua operand";
|
||||
case RC_INVALID_MEMORY_OPERAND: return "Invalid memory operand";
|
||||
case RC_INVALID_CONST_OPERAND: return "Invalid constant operand";
|
||||
case RC_INVALID_FP_OPERAND: return "Invalid floating-point operand";
|
||||
case RC_INVALID_CONDITION_TYPE: return "Invalid condition type";
|
||||
case RC_INVALID_OPERATOR: return "Invalid operator";
|
||||
case RC_INVALID_REQUIRED_HITS: return "Invalid required hits";
|
||||
case RC_DUPLICATED_START: return "Duplicated start condition";
|
||||
case RC_DUPLICATED_CANCEL: return "Duplicated cancel condition";
|
||||
case RC_DUPLICATED_SUBMIT: return "Duplicated submit condition";
|
||||
case RC_DUPLICATED_VALUE: return "Duplicated value expression";
|
||||
case RC_DUPLICATED_PROGRESS: return "Duplicated progress expression";
|
||||
case RC_MISSING_START: return "Missing start condition";
|
||||
case RC_MISSING_CANCEL: return "Missing cancel condition";
|
||||
case RC_MISSING_SUBMIT: return "Missing submit condition";
|
||||
case RC_MISSING_VALUE: return "Missing value expression";
|
||||
case RC_INVALID_LBOARD_FIELD: return "Invalid field in leaderboard";
|
||||
case RC_MISSING_DISPLAY_STRING: return "Missing display string";
|
||||
case RC_OUT_OF_MEMORY: return "Out of memory";
|
||||
case RC_INVALID_VALUE_FLAG: return "Invalid flag in value expression";
|
||||
case RC_MISSING_VALUE_MEASURED: return "Missing measured flag in value expression";
|
||||
case RC_MULTIPLE_MEASURED: return "Multiple measured targets";
|
||||
case RC_INVALID_MEASURED_TARGET: return "Invalid measured target";
|
||||
|
||||
default: return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
static int rcheevos_parse(const char* json)
|
||||
{
|
||||
char buffer[256];
|
||||
@ -604,7 +591,7 @@ static int rcheevos_parse(const char* json)
|
||||
if (res < 0)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error in achievement %d \"%s\": %s",
|
||||
cheevo->info->id, cheevo->info->title, rcheevos_rc_error(res));
|
||||
cheevo->info->id, cheevo->info->title, rc_error_str(res));
|
||||
|
||||
if (settings->bools.cheevos_verbose_enable)
|
||||
runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -641,7 +628,7 @@ static int rcheevos_parse(const char* json)
|
||||
if (res < 0)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error in leaderboard %d \"%s\": %s",
|
||||
lboard->info->id, lboard->info->title, rcheevos_rc_error(res));
|
||||
lboard->info->id, lboard->info->title, rc_error_str(res));
|
||||
|
||||
if (settings->bools.cheevos_verbose_enable)
|
||||
runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -671,7 +658,7 @@ static int rcheevos_parse(const char* json)
|
||||
int buffer_size = rc_richpresence_size(rcheevos_locals.patchdata.richpresence_script);
|
||||
if (buffer_size <= 0)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error in rich presence: %s", rcheevos_rc_error(buffer_size));
|
||||
snprintf(buffer, sizeof(buffer), "Error in rich presence: %s", rc_error_str(buffer_size));
|
||||
|
||||
if (settings->bools.cheevos_verbose_enable)
|
||||
runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -721,7 +708,7 @@ static void rcheevos_async_award_achievement(rcheevos_async_io_request* request)
|
||||
{
|
||||
char buffer[256];
|
||||
settings_t *settings = config_get_ptr();
|
||||
int ret = rc_url_award_cheevo(buffer, sizeof(buffer), settings->arrays.cheevos_username, rcheevos_locals.token, request->id, request->hardcore);
|
||||
int ret = rc_url_award_cheevo(buffer, sizeof(buffer), settings->arrays.cheevos_username, rcheevos_locals.token, request->id, request->hardcore, rcheevos_locals.hash);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
@ -730,7 +717,7 @@ static void rcheevos_async_award_achievement(rcheevos_async_io_request* request)
|
||||
return;
|
||||
}
|
||||
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_award_cheevo: %s\n", buffer);
|
||||
rcheevos_log_url("rc_url_award_cheevo", buffer);
|
||||
task_push_http_transfer_with_user_agent(buffer, true, NULL, request->user_agent, rcheevos_async_task_callback, request);
|
||||
}
|
||||
|
||||
@ -907,7 +894,7 @@ static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request)
|
||||
char buffer[256];
|
||||
settings_t *settings = config_get_ptr();
|
||||
int ret = rc_url_submit_lboard(buffer, sizeof(buffer), settings->arrays.cheevos_username,
|
||||
rcheevos_locals.token, request->id, request->value, rcheevos_locals.hash);
|
||||
rcheevos_locals.token, request->id, request->value);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
@ -916,7 +903,7 @@ static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request)
|
||||
return;
|
||||
}
|
||||
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_submit_lboard: %s\n", buffer);
|
||||
rcheevos_log_url("rc_url_submit_lboard", buffer);
|
||||
task_push_http_transfer_with_user_agent(buffer, true, NULL, request->user_agent, rcheevos_async_task_callback, request);
|
||||
}
|
||||
|
||||
@ -971,39 +958,33 @@ static void rcheevos_test_leaderboards(void)
|
||||
switch (rc_evaluate_lboard(lboard->lboard, &lboard->last_value, rcheevos_peek, NULL, NULL))
|
||||
{
|
||||
default:
|
||||
case RC_LBOARD_INACTIVE:
|
||||
break;
|
||||
|
||||
case RC_LBOARD_ACTIVE:
|
||||
/* this is where we would update the onscreen tracker */
|
||||
break;
|
||||
|
||||
case RC_LBOARD_TRIGGERED:
|
||||
case RC_LBOARD_STATE_TRIGGERED:
|
||||
rcheevos_lboard_submit(lboard);
|
||||
break;
|
||||
|
||||
case RC_LBOARD_CANCELED:
|
||||
{
|
||||
case RC_LBOARD_STATE_CANCELED:
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "Cancel leaderboard %s\n", lboard->info->title);
|
||||
lboard->active = 0;
|
||||
runloop_msg_queue_push("Leaderboard attempt cancelled!",
|
||||
0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
case RC_LBOARD_STARTED:
|
||||
{
|
||||
char buffer[256];
|
||||
case RC_LBOARD_STATE_STARTED:
|
||||
if (!lboard->active)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "Leaderboard started: %s\n", lboard->info->title);
|
||||
lboard->active = 1;
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "Leaderboard started: %s\n", lboard->info->title);
|
||||
lboard->active = 1;
|
||||
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Leaderboard Active: %s", lboard->info->title);
|
||||
runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
runloop_msg_queue_push(lboard->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Leaderboard Active: %s", lboard->info->title);
|
||||
runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
runloop_msg_queue_push(lboard->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rcheevos_locals.invalid_peek_address)
|
||||
@ -1046,30 +1027,31 @@ static retro_time_t rcheevos_async_send_rich_presence(rcheevos_async_io_request*
|
||||
|
||||
{
|
||||
char url[256], post_data[1024];
|
||||
int ret = rc_url_ping(url, sizeof(url), post_data, sizeof(post_data),
|
||||
cheevos_username, rcheevos_locals.token, rcheevos_locals.patchdata.game_id,
|
||||
rcheevos_locals.richpresence.evaluation);
|
||||
|
||||
snprintf(url, sizeof(url),
|
||||
"http://retroachievements.org/dorequest.php?r=ping&u=%s&t=%s",
|
||||
cheevos_username, rcheevos_locals.token);
|
||||
|
||||
if (rcheevos_locals.richpresence.evaluation[0])
|
||||
if (ret < 0)
|
||||
{
|
||||
char* tmp = NULL;
|
||||
net_http_urlencode(&tmp, rcheevos_locals.richpresence.evaluation);
|
||||
snprintf(post_data, sizeof(post_data), "g=%u&m=%s", rcheevos_locals.patchdata.game_id, tmp);
|
||||
CHEEVOS_FREE(tmp);
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
if (settings->bools.discord_enable)
|
||||
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS, false);
|
||||
#endif
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
|
||||
}
|
||||
else
|
||||
snprintf(post_data, sizeof(post_data), "g=%u", rcheevos_locals.patchdata.game_id);
|
||||
{
|
||||
rcheevos_log_post_url("rc_url_ping", url, post_data);
|
||||
|
||||
rcheevos_get_user_agent(request->user_agent);
|
||||
task_push_http_post_transfer_with_user_agent(url, post_data, true, "POST", request->user_agent, NULL, NULL);
|
||||
rcheevos_get_user_agent(request->user_agent);
|
||||
task_push_http_post_transfer_with_user_agent(url, post_data, true, "POST", request->user_agent, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
if (rcheevos_locals.richpresence.evaluation[0])
|
||||
{
|
||||
if (settings->bools.discord_enable)
|
||||
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update rich presence every two minutes */
|
||||
if (settings->bools.cheevos_richpresence_enable)
|
||||
return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY;
|
||||
@ -1109,15 +1091,7 @@ void rcheevos_reset_game(void)
|
||||
rc_reset_lboard(lboard->lboard);
|
||||
|
||||
if (lboard->active)
|
||||
{
|
||||
lboard->active = 0;
|
||||
|
||||
/* This ensures the leaderboard won't restart
|
||||
* until the start trigger is false for at
|
||||
* least one frame */
|
||||
if (lboard->lboard)
|
||||
lboard->lboard->submitted = 1;
|
||||
}
|
||||
}
|
||||
|
||||
rcheevos_locals.richpresence.last_update = cpu_features_get_time_usec();
|
||||
@ -1293,12 +1267,9 @@ bool rcheevos_get_description(rcheevos_ctx_desc_t* desc)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rcheevos_apply_cheats(bool* data_bool)
|
||||
void rcheevos_pause_hardcore()
|
||||
{
|
||||
rcheevos_cheats_are_enabled = *data_bool;
|
||||
rcheevos_cheats_were_enabled |= rcheevos_cheats_are_enabled;
|
||||
|
||||
return true;
|
||||
rcheevos_hardcore_paused = true;
|
||||
}
|
||||
|
||||
bool rcheevos_unload(void)
|
||||
@ -1422,12 +1393,6 @@ void rcheevos_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool rcheevos_set_cheats(void)
|
||||
{
|
||||
rcheevos_cheats_were_enabled = rcheevos_cheats_are_enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
void rcheevos_set_support_cheevos(bool state)
|
||||
{
|
||||
rcheevos_locals.core_supports = state;
|
||||
@ -1576,7 +1541,7 @@ static int rcheevos_prepare_hash_psx(rcheevos_coro_t* coro)
|
||||
|
||||
/* find the data track - it should be the first one */
|
||||
coro->track = cdfs_open_data_track(coro->path);
|
||||
|
||||
|
||||
if (!coro->track)
|
||||
{
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "could not open CD\n");
|
||||
@ -2015,7 +1980,8 @@ found:
|
||||
* Inputs: CHEEVOS_VAR_GAMEID
|
||||
* Outputs:
|
||||
*/
|
||||
CORO_GOSUB(RCHEEVOS_DEACTIVATE);
|
||||
if (!coro->settings->bools.cheevos_start_active)
|
||||
CORO_GOSUB(RCHEEVOS_DEACTIVATE);
|
||||
|
||||
/*
|
||||
* Inputs: CHEEVOS_VAR_GAMEID
|
||||
@ -2045,15 +2011,33 @@ found:
|
||||
|
||||
if (!number_of_unsupported)
|
||||
{
|
||||
snprintf(msg, sizeof(msg),
|
||||
"You have %d of %d achievements unlocked.",
|
||||
number_of_unlocked, rcheevos_locals.patchdata.core_count);
|
||||
if (coro->settings->bools.cheevos_start_active) {
|
||||
snprintf(msg, sizeof(msg),
|
||||
"All %d achievements activated for this session.",
|
||||
rcheevos_locals.patchdata.core_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(msg, sizeof(msg),
|
||||
"You have %d of %d achievements unlocked.",
|
||||
number_of_unlocked, rcheevos_locals.patchdata.core_count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(msg, sizeof(msg),
|
||||
"You have %d of %d achievements unlocked (%d unsupported).",
|
||||
number_of_unlocked - number_of_unsupported, rcheevos_locals.patchdata.core_count, number_of_unsupported);
|
||||
if (coro->settings->bools.cheevos_start_active) {
|
||||
snprintf(msg, sizeof(msg),
|
||||
"All %d achievements activated for this session (%d unsupported).",
|
||||
rcheevos_locals.patchdata.core_count,
|
||||
number_of_unsupported);
|
||||
}
|
||||
else{
|
||||
snprintf(msg, sizeof(msg),
|
||||
"You have %d of %d achievements unlocked (%d unsupported).",
|
||||
number_of_unlocked - number_of_unsupported,
|
||||
rcheevos_locals.patchdata.core_count,
|
||||
number_of_unsupported);
|
||||
}
|
||||
}
|
||||
|
||||
msg[sizeof(msg) - 1] = 0;
|
||||
@ -2463,14 +2447,6 @@ found:
|
||||
}
|
||||
memcpy(coro->last_hash, coro->hash, sizeof(coro->hash));
|
||||
|
||||
size = rc_url_get_gameid(coro->url, sizeof(coro->url), coro->hash);
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
|
||||
CORO_RET();
|
||||
}
|
||||
|
||||
sprintf(rcheevos_locals.hash, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
coro->hash[0], coro->hash[1], coro->hash[2], coro->hash[3],
|
||||
coro->hash[4], coro->hash[5], coro->hash[6], coro->hash[7],
|
||||
@ -2478,7 +2454,16 @@ found:
|
||||
coro->hash[12], coro->hash[13], coro->hash[14], coro->hash[15]);
|
||||
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "checking %s\n", rcheevos_locals.hash);
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_gameid: %s\n", coro->url);
|
||||
|
||||
size = rc_url_get_gameid(coro->url, sizeof(coro->url), rcheevos_locals.hash);
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
|
||||
CORO_RET();
|
||||
}
|
||||
|
||||
rcheevos_log_url("rc_url_get_gameid", coro->url);
|
||||
CORO_GOSUB(RCHEEVOS_HTTP_GET);
|
||||
|
||||
if (!coro->json)
|
||||
@ -2511,7 +2496,7 @@ found:
|
||||
CORO_STOP();
|
||||
}
|
||||
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_patch: %s\n", coro->url);
|
||||
rcheevos_log_url("rc_url_get_patch", coro->url);
|
||||
CORO_GOSUB(RCHEEVOS_HTTP_GET);
|
||||
|
||||
if (!coro->json)
|
||||
@ -2651,21 +2636,36 @@ found:
|
||||
}
|
||||
|
||||
if (string_is_empty(coro->settings->arrays.cheevos_token))
|
||||
{
|
||||
ret = rc_url_login_with_password(coro->url, sizeof(coro->url),
|
||||
coro->settings->arrays.cheevos_username,
|
||||
coro->settings->arrays.cheevos_password);
|
||||
|
||||
if (ret == RC_OK)
|
||||
{
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "attempting to login %s (with password)\n", coro->settings->arrays.cheevos_username);
|
||||
rcheevos_log_url("rc_url_login_with_password", coro->url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = rc_url_login_with_token(coro->url, sizeof(coro->url),
|
||||
coro->settings->arrays.cheevos_username,
|
||||
coro->settings->arrays.cheevos_token);
|
||||
|
||||
if (ret == RC_OK)
|
||||
{
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "attempting to login %s (with token)\n", coro->settings->arrays.cheevos_username);
|
||||
rcheevos_log_url("rc_url_login_with_token", coro->url);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
|
||||
CORO_STOP();
|
||||
}
|
||||
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_login_with_password: %s\n", coro->url);
|
||||
CORO_GOSUB(RCHEEVOS_HTTP_GET);
|
||||
|
||||
if (!coro->json)
|
||||
@ -2686,6 +2686,7 @@ found:
|
||||
tok);
|
||||
runloop_msg_queue_push(msg, 0, 5 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
*coro->settings->arrays.cheevos_token = 0;
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "login error: %s\n", tok);
|
||||
|
||||
CHEEVOS_FREE(coro->json);
|
||||
CORO_STOP();
|
||||
@ -2703,6 +2704,7 @@ found:
|
||||
runloop_msg_queue_push(msg, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "logged in successfully\n");
|
||||
strlcpy(rcheevos_locals.token, tok,
|
||||
sizeof(rcheevos_locals.token));
|
||||
|
||||
@ -2838,7 +2840,7 @@ found:
|
||||
CORO_STOP();
|
||||
}
|
||||
|
||||
rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_unlock_list: %s\n", coro->url);
|
||||
rcheevos_log_url("rc_url_get_unlock_list", coro->url);
|
||||
CORO_GOSUB(RCHEEVOS_HTTP_GET);
|
||||
|
||||
if (coro->json)
|
||||
@ -2862,15 +2864,19 @@ found:
|
||||
*************************************************************************/
|
||||
CORO_SUB(RCHEEVOS_PLAYING)
|
||||
|
||||
snprintf(
|
||||
coro->url, sizeof(coro->url),
|
||||
"http://retroachievements.org/dorequest.php?r=postactivity&u=%s&t=%s&a=3&m=%u",
|
||||
{
|
||||
int ret = rc_url_post_playing(coro->url, sizeof(coro->url),
|
||||
coro->settings->arrays.cheevos_username,
|
||||
rcheevos_locals.token, coro->gameid
|
||||
);
|
||||
rcheevos_locals.token, coro->gameid);
|
||||
|
||||
coro->url[sizeof(coro->url) - 1] = 0;
|
||||
rcheevos_log_url(RCHEEVOS_TAG "url to post the 'playing' activity: %s\n", coro->url);
|
||||
if (ret < 0)
|
||||
{
|
||||
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
|
||||
CORO_STOP();
|
||||
}
|
||||
}
|
||||
|
||||
rcheevos_log_url("rc_url_post_playing", coro->url);
|
||||
|
||||
CORO_GOSUB(RCHEEVOS_HTTP_GET);
|
||||
|
||||
@ -2923,11 +2929,13 @@ bool rcheevos_load(const void *data)
|
||||
retro_task_t *task = NULL;
|
||||
const struct retro_game_info *info = NULL;
|
||||
rcheevos_coro_t *coro = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool cheevos_enable = settings && settings->bools.cheevos_enable;
|
||||
|
||||
rcheevos_loaded = false;
|
||||
rcheevos_hardcore_paused = false;
|
||||
|
||||
if (!rcheevos_locals.core_supports || !data)
|
||||
if (!cheevos_enable || !rcheevos_locals.core_supports || !data)
|
||||
{
|
||||
rcheevos_hardcore_paused = true;
|
||||
return false;
|
@ -49,7 +49,7 @@ void rcheevos_get_achievement_state(unsigned index, char* buffer, size_t buffer_
|
||||
|
||||
bool rcheevos_get_description(rcheevos_ctx_desc_t *desc);
|
||||
|
||||
bool rcheevos_apply_cheats(bool *data_bool);
|
||||
void rcheevos_pause_hardcore();
|
||||
|
||||
bool rcheevos_unload(void);
|
||||
|
||||
@ -57,8 +57,6 @@ bool rcheevos_toggle_hardcore_mode(void);
|
||||
|
||||
void rcheevos_test(void);
|
||||
|
||||
bool rcheevos_set_cheats(void);
|
||||
|
||||
void rcheevos_set_support_cheevos(bool state);
|
||||
|
||||
bool rcheevos_get_support_cheevos(void);
|
||||
@ -73,8 +71,6 @@ extern bool rcheevos_loaded;
|
||||
extern bool rcheevos_hardcore_active;
|
||||
extern bool rcheevos_hardcore_paused;
|
||||
extern bool rcheevos_state_loaded_flag;
|
||||
extern int rcheevos_cheats_are_enabled;
|
||||
extern int rcheevos_cheats_were_enabled;
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "../core.h"
|
||||
|
||||
#include "../deps/rcheevos/include/rcheevos.h"
|
||||
#include "../deps/rcheevos/include/rconsoles.h"
|
||||
|
||||
static int rcheevos_cmpaddr(const void* e1, const void* e2)
|
||||
{
|
14
config.def.h
14
config.def.h
@ -517,8 +517,8 @@ static const bool menu_show_sublabels = true;
|
||||
|
||||
static const bool menu_scroll_fast = false;
|
||||
|
||||
#define DEFAULT_MENU_TICKER_TYPE (TICKER_TYPE_BOUNCE)
|
||||
static const float menu_ticker_speed = 1.0f;
|
||||
#define DEFAULT_MENU_TICKER_TYPE (TICKER_TYPE_LOOP)
|
||||
static const float menu_ticker_speed = 2.0f;
|
||||
|
||||
#define DEFAULT_MENU_TICKER_SMOOTH true
|
||||
|
||||
@ -539,11 +539,15 @@ static const bool content_show_music = true;
|
||||
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
|
||||
static const bool content_show_video = true;
|
||||
#endif
|
||||
#ifdef HAVE_NETWORKING
|
||||
#if defined(HAVE_NETWORKING)
|
||||
#if defined(_3DS)
|
||||
static const bool content_show_netplay = false;
|
||||
#else
|
||||
static const bool content_show_netplay = true;
|
||||
#endif
|
||||
#endif
|
||||
static const bool content_show_history = true;
|
||||
static const bool content_show_add = true;
|
||||
static const bool content_show_add = true;
|
||||
static const bool content_show_playlists = true;
|
||||
|
||||
#ifdef HAVE_XMB
|
||||
@ -610,7 +614,7 @@ static const bool rgui_extended_ascii = false;
|
||||
static const bool default_game_specific_options = true;
|
||||
static const bool default_auto_overrides_enable = true;
|
||||
static const bool default_auto_remaps_enable = true;
|
||||
static const bool default_global_core_options = true;
|
||||
static const bool default_global_core_options = false;
|
||||
static const bool default_auto_shaders_enable = true;
|
||||
|
||||
static const bool default_sort_savefiles_enable = false;
|
||||
|
@ -332,7 +332,7 @@ static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_XENON360;
|
||||
#elif defined(HAVE_D3D11)
|
||||
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D11;
|
||||
#elif defined(HAVE_D3D12)
|
||||
/* FIXME/WARNING: DX12 performance on Xbox is horrible for
|
||||
/* FIXME/WARNING: DX12 performance on Xbox is horrible for
|
||||
* some reason. For now, we will default to D3D11 when possible. */
|
||||
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D12;
|
||||
#elif defined(HAVE_D3D10)
|
||||
@ -1454,7 +1454,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
|
||||
#ifdef HAVE_MENU
|
||||
SETTING_BOOL("menu_unified_controls", &settings->bools.menu_unified_controls, true, false, false);
|
||||
SETTING_BOOL("menu_throttle_framerate", &settings->bools.menu_throttle_framerate, true, true, false);
|
||||
SETTING_BOOL("menu_linear_filter", &settings->bools.menu_linear_filter, true, true, false);
|
||||
SETTING_BOOL("menu_linear_filter", &settings->bools.menu_linear_filter, true, DEFAULT_VIDEO_SMOOTH, false);
|
||||
SETTING_BOOL("menu_horizontal_animation", &settings->bools.menu_horizontal_animation, true, DEFAULT_MENU_HORIZONTAL_ANIMATION, false);
|
||||
SETTING_BOOL("menu_pause_libretro", &settings->bools.menu_pause_libretro, true, true, false);
|
||||
SETTING_BOOL("menu_savestate_resume", &settings->bools.menu_savestate_resume, true, menu_savestate_resume, false);
|
||||
@ -1588,6 +1588,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
|
||||
SETTING_BOOL("cheevos_verbose_enable", &settings->bools.cheevos_verbose_enable, true, false, false);
|
||||
SETTING_BOOL("cheevos_auto_screenshot", &settings->bools.cheevos_auto_screenshot, true, false, false);
|
||||
SETTING_BOOL("cheevos_badges_enable", &settings->bools.cheevos_badges_enable, true, false, false);
|
||||
SETTING_BOOL("cheevos_start_active", &settings->bools.cheevos_start_active, true, false, false);
|
||||
#endif
|
||||
#ifdef HAVE_OVERLAY
|
||||
SETTING_BOOL("input_overlay_enable", &settings->bools.input_overlay_enable, true, config_overlay_enable_default(), false);
|
||||
@ -2674,7 +2675,7 @@ static config_file_t *open_default_config_file(void)
|
||||
|
||||
skeleton_conf[0] = '\0';
|
||||
|
||||
/* Build a retroarch.cfg path from the
|
||||
/* Build a retroarch.cfg path from the
|
||||
* global config directory (/etc). */
|
||||
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||
@ -2689,7 +2690,7 @@ static config_file_t *open_default_config_file(void)
|
||||
|
||||
if (conf)
|
||||
{
|
||||
/* Since this is a clean config file, we can
|
||||
/* Since this is a clean config file, we can
|
||||
* safely use config_save_on_exit. */
|
||||
config_set_bool(conf, "config_save_on_exit", true);
|
||||
saved = config_file_write(conf, conf_path, true);
|
||||
|
@ -304,6 +304,7 @@ typedef struct settings
|
||||
bool cheevos_badges_enable;
|
||||
bool cheevos_verbose_enable;
|
||||
bool cheevos_auto_screenshot;
|
||||
bool cheevos_start_active;
|
||||
|
||||
/* Camera */
|
||||
bool camera_allow;
|
||||
|
@ -232,7 +232,7 @@ static config_file_t *core_info_list_iterate(
|
||||
current_path,
|
||||
info_path_base_size);
|
||||
|
||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(PS2) && !defined(HW_WUP))
|
||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(HW_WUP))
|
||||
{
|
||||
char *substr = strrchr(info_path_base, '_');
|
||||
if (substr)
|
||||
|
14
deps/discord-rpc/include/discord_register.h
vendored
14
deps/discord-rpc/include/discord_register.h
vendored
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define DISCORD_EXPORT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
|
||||
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
6
deps/discord-rpc/include/discord_rpc.h
vendored
6
deps/discord-rpc/include/discord_rpc.h
vendored
@ -53,9 +53,9 @@ typedef struct DiscordEventHandlers
|
||||
#define DISCORD_REPLY_IGNORE 2
|
||||
|
||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister,
|
||||
const char* optionalSteamId);
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister,
|
||||
const char* optionalSteamId);
|
||||
DISCORD_EXPORT void Discord_Shutdown(void);
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
|
55
deps/discord-rpc/src/backoff.h
vendored
55
deps/discord-rpc/src/backoff.h
vendored
@ -5,36 +5,37 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
struct Backoff {
|
||||
int64_t minAmount;
|
||||
int64_t maxAmount;
|
||||
int64_t current;
|
||||
int fails;
|
||||
std::mt19937_64 randGenerator;
|
||||
std::uniform_real_distribution<> randDistribution;
|
||||
struct Backoff
|
||||
{
|
||||
int64_t minAmount;
|
||||
int64_t maxAmount;
|
||||
int64_t current;
|
||||
int fails;
|
||||
std::mt19937_64 randGenerator;
|
||||
std::uniform_real_distribution<> randDistribution;
|
||||
|
||||
double rand01() { return randDistribution(randGenerator); }
|
||||
double rand01() { return randDistribution(randGenerator); }
|
||||
|
||||
Backoff(int64_t min, int64_t max)
|
||||
Backoff(int64_t min, int64_t max)
|
||||
: minAmount(min)
|
||||
, maxAmount(max)
|
||||
, current(min)
|
||||
, fails(0)
|
||||
, randGenerator((uint64_t)time(0))
|
||||
{
|
||||
}
|
||||
, maxAmount(max)
|
||||
, current(min)
|
||||
, fails(0)
|
||||
, randGenerator((uint64_t)time(0))
|
||||
{
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
fails = 0;
|
||||
current = minAmount;
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
fails = 0;
|
||||
current = minAmount;
|
||||
}
|
||||
|
||||
int64_t nextDelay()
|
||||
{
|
||||
++fails;
|
||||
int64_t delay = (int64_t)((double)current * 2.0 * rand01());
|
||||
current = std::min(current + delay, maxAmount);
|
||||
return current;
|
||||
}
|
||||
int64_t nextDelay()
|
||||
{
|
||||
++fails;
|
||||
int64_t delay = (int64_t)((double)current * 2.0 * rand01());
|
||||
current = std::min(current + delay, maxAmount);
|
||||
return current;
|
||||
}
|
||||
};
|
||||
|
19
deps/discord-rpc/src/connection.h
vendored
19
deps/discord-rpc/src/connection.h
vendored
@ -6,14 +6,15 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/* not really connectiony, but need per-platform */
|
||||
int GetProcessId();
|
||||
int GetProcessId(void);
|
||||
|
||||
struct BaseConnection {
|
||||
static BaseConnection* Create();
|
||||
static void Destroy(BaseConnection*&);
|
||||
bool isOpen{false};
|
||||
bool Open();
|
||||
bool Close();
|
||||
bool Write(const void* data, size_t length);
|
||||
bool Read(void* data, size_t length);
|
||||
struct BaseConnection
|
||||
{
|
||||
static BaseConnection* Create();
|
||||
static void Destroy(BaseConnection*&);
|
||||
bool isOpen{false};
|
||||
bool Open();
|
||||
bool Close();
|
||||
bool Write(const void* data, size_t length);
|
||||
bool Read(void* data, size_t length);
|
||||
};
|
||||
|
10
deps/discord-rpc/src/discord_register_linux.c
vendored
10
deps/discord-rpc/src/discord_register_linux.c
vendored
@ -1,5 +1,3 @@
|
||||
#include "discord_rpc.h"
|
||||
#include "discord_register.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <errno.h>
|
||||
@ -13,9 +11,11 @@
|
||||
#include <file/file_path.h>
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include <discord_rpc.h>
|
||||
|
||||
/* we want to register games so we can run them from
|
||||
* Discord client as discord-<appid>:// */
|
||||
void Discord_Register(const char* applicationId, const char* command)
|
||||
void Discord_Register(const char *applicationId, const char *command)
|
||||
{
|
||||
FILE* fp;
|
||||
int fileLen;
|
||||
@ -82,9 +82,7 @@ void Discord_Register(const char* applicationId, const char* command)
|
||||
fprintf(stderr, "Failed to register mime handler\n");
|
||||
}
|
||||
|
||||
void Discord_RegisterSteamGame(
|
||||
const char* applicationId,
|
||||
const char* steamId)
|
||||
void Discord_RegisterSteamGame(const char *applicationId, const char *steamId)
|
||||
{
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "xdg-open steam://rungameid/%s", steamId);
|
||||
|
76
deps/discord-rpc/src/discord_register_osx.m
vendored
76
deps/discord-rpc/src/discord_register_osx.m
vendored
@ -3,8 +3,6 @@
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "../include/discord_register.h"
|
||||
|
||||
static void RegisterCommand(const char* applicationId, const char* command)
|
||||
{
|
||||
/* There does not appear to be a way to register arbitrary commands on OSX, so instead we'll save the command
|
||||
@ -31,54 +29,52 @@ static void RegisterCommand(const char* applicationId, const char* command)
|
||||
|
||||
static void RegisterURL(const char* applicationId)
|
||||
{
|
||||
char url[256];
|
||||
snprintf(url, sizeof(url), "discord-%s", applicationId);
|
||||
CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8);
|
||||
NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier];
|
||||
char url[256];
|
||||
snprintf(url, sizeof(url), "discord-%s", applicationId);
|
||||
CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8);
|
||||
NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier];
|
||||
|
||||
if (!myBundleId)
|
||||
{
|
||||
fprintf(stderr, "No bundle id found\n");
|
||||
return;
|
||||
}
|
||||
if (!myBundleId)
|
||||
{
|
||||
fprintf(stderr, "No bundle id found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL* myURL = [[NSBundle mainBundle] bundleURL];
|
||||
if (!myURL)
|
||||
{
|
||||
fprintf(stderr, "No bundle url found\n");
|
||||
return;
|
||||
}
|
||||
NSURL* myURL = [[NSBundle mainBundle] bundleURL];
|
||||
if (!myURL)
|
||||
{
|
||||
fprintf(stderr, "No bundle url found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId);
|
||||
if (status != noErr)
|
||||
{
|
||||
fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status);
|
||||
return;
|
||||
}
|
||||
OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId);
|
||||
if (status != noErr)
|
||||
{
|
||||
fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status);
|
||||
return;
|
||||
}
|
||||
|
||||
status = LSRegisterURL((__bridge CFURLRef)myURL, true);
|
||||
if (status != noErr)
|
||||
{
|
||||
fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status);
|
||||
}
|
||||
status = LSRegisterURL((__bridge CFURLRef)myURL, true);
|
||||
if (status != noErr)
|
||||
fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status);
|
||||
}
|
||||
|
||||
void Discord_Register(const char* applicationId, const char* command)
|
||||
{
|
||||
if (command)
|
||||
RegisterCommand(applicationId, command);
|
||||
else
|
||||
{
|
||||
/* RAII Lite */
|
||||
@autoreleasepool {
|
||||
RegisterURL(applicationId);
|
||||
}
|
||||
}
|
||||
if (command)
|
||||
RegisterCommand(applicationId, command);
|
||||
else
|
||||
{
|
||||
/* RAII Lite */
|
||||
@autoreleasepool {
|
||||
RegisterURL(applicationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Discord_RegisterSteamGame(const char* applicationId, const char* steamId)
|
||||
{
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "steam://rungameid/%s", steamId);
|
||||
Discord_Register(applicationId, command);
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "steam://rungameid/%s", steamId);
|
||||
Discord_Register(applicationId, command);
|
||||
}
|
||||
|
150
deps/discord-rpc/src/discord_register_win.c
vendored
150
deps/discord-rpc/src/discord_register_win.c
vendored
@ -1,5 +1,4 @@
|
||||
#include "discord_rpc.h"
|
||||
#include "discord_register.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMCX
|
||||
@ -53,99 +52,99 @@ static LSTATUS regset(HKEY hkey,
|
||||
const void* data,
|
||||
DWORD len)
|
||||
{
|
||||
HKEY htkey = hkey, hsubkey = NULL;
|
||||
LSTATUS ret;
|
||||
if (subkey && subkey[0])
|
||||
{
|
||||
if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) !=
|
||||
LSTATUS ret;
|
||||
HKEY htkey = hkey, hsubkey = NULL;
|
||||
if (subkey && subkey[0])
|
||||
{
|
||||
if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) !=
|
||||
ERROR_SUCCESS)
|
||||
return ret;
|
||||
htkey = hsubkey;
|
||||
}
|
||||
ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len);
|
||||
if (hsubkey && hsubkey != hkey)
|
||||
RegCloseKey(hsubkey);
|
||||
return ret;
|
||||
return ret;
|
||||
htkey = hsubkey;
|
||||
}
|
||||
ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len);
|
||||
if (hsubkey && hsubkey != hkey)
|
||||
RegCloseKey(hsubkey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void Discord_RegisterW(
|
||||
const wchar_t* applicationId, const wchar_t* command)
|
||||
{
|
||||
/* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
|
||||
* we want to register games so we can run them as discord-<appid>://
|
||||
* Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */
|
||||
/* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
|
||||
* we want to register games so we can run them as discord-<appid>://
|
||||
* Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */
|
||||
|
||||
DWORD len;
|
||||
LSTATUS result;
|
||||
wchar_t urlProtocol = 0;
|
||||
wchar_t keyName[256];
|
||||
wchar_t protocolName[64];
|
||||
wchar_t protocolDescription[128];
|
||||
wchar_t exeFilePath[MAX_PATH];
|
||||
DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH);
|
||||
wchar_t openCommand[1024];
|
||||
DWORD len;
|
||||
LSTATUS result;
|
||||
wchar_t urlProtocol = 0;
|
||||
wchar_t keyName[256];
|
||||
wchar_t protocolName[64];
|
||||
wchar_t protocolDescription[128];
|
||||
wchar_t exeFilePath[MAX_PATH];
|
||||
DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH);
|
||||
wchar_t openCommand[1024];
|
||||
|
||||
if (command && command[0])
|
||||
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command);
|
||||
else
|
||||
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath);
|
||||
if (command && command[0])
|
||||
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command);
|
||||
else
|
||||
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath);
|
||||
|
||||
StringCbPrintfW(protocolName, sizeof(protocolName),
|
||||
L"discord-%S", applicationId);
|
||||
StringCbPrintfW(
|
||||
protocolDescription, sizeof(protocolDescription),
|
||||
L"URL:Run game %S protocol", applicationId);
|
||||
StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName);
|
||||
HKEY key;
|
||||
LSTATUS status =
|
||||
StringCbPrintfW(protocolName, sizeof(protocolName),
|
||||
L"discord-%S", applicationId);
|
||||
StringCbPrintfW(
|
||||
protocolDescription, sizeof(protocolDescription),
|
||||
L"URL:Run game %S protocol", applicationId);
|
||||
StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName);
|
||||
HKEY key;
|
||||
LSTATUS status =
|
||||
RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Error creating key\n");
|
||||
return;
|
||||
}
|
||||
len = (DWORD)lstrlenW(protocolDescription) + 1;
|
||||
result =
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Error creating key\n");
|
||||
return;
|
||||
}
|
||||
len = (DWORD)lstrlenW(protocolDescription) + 1;
|
||||
result =
|
||||
RegSetKeyValueW(key, NULL, NULL, REG_SZ, protocolDescription, len * sizeof(wchar_t));
|
||||
if (FAILED(result)) {
|
||||
fprintf(stderr, "Error writing description\n");
|
||||
}
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing description\n");
|
||||
|
||||
len = (DWORD)lstrlenW(protocolDescription) + 1;
|
||||
result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing description\n");
|
||||
len = (DWORD)lstrlenW(protocolDescription) + 1;
|
||||
result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing description\n");
|
||||
|
||||
result = RegSetKeyValueW(
|
||||
key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing icon\n");
|
||||
result = RegSetKeyValueW(
|
||||
key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing icon\n");
|
||||
|
||||
len = (DWORD)lstrlenW(openCommand) + 1;
|
||||
result = RegSetKeyValueW(
|
||||
key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing command\n");
|
||||
RegCloseKey(key);
|
||||
len = (DWORD)lstrlenW(openCommand) + 1;
|
||||
result = RegSetKeyValueW(
|
||||
key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t));
|
||||
if (FAILED(result))
|
||||
fprintf(stderr, "Error writing command\n");
|
||||
RegCloseKey(key);
|
||||
}
|
||||
|
||||
void Discord_Register(const char* applicationId, const char* command)
|
||||
{
|
||||
wchar_t openCommand[1024];
|
||||
const wchar_t* wcommand = NULL;
|
||||
wchar_t appId[32];
|
||||
wchar_t appId[32];
|
||||
wchar_t openCommand[1024];
|
||||
const wchar_t* wcommand = NULL;
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32);
|
||||
if (command && command[0])
|
||||
{
|
||||
const int commandBufferLen =
|
||||
sizeof(openCommand) / sizeof(*openCommand);
|
||||
MultiByteToWideChar(CP_UTF8, 0, command, -1,
|
||||
openCommand, commandBufferLen);
|
||||
wcommand = openCommand;
|
||||
}
|
||||
MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32);
|
||||
|
||||
Discord_RegisterW(appId, wcommand);
|
||||
if (command && command[0])
|
||||
{
|
||||
const int commandBufferLen =
|
||||
sizeof(openCommand) / sizeof(*openCommand);
|
||||
MultiByteToWideChar(CP_UTF8, 0, command, -1,
|
||||
openCommand, commandBufferLen);
|
||||
wcommand = openCommand;
|
||||
}
|
||||
|
||||
Discord_RegisterW(appId, wcommand);
|
||||
}
|
||||
|
||||
void Discord_RegisterSteamGame(
|
||||
@ -172,7 +171,8 @@ void Discord_RegisterSteamGame(
|
||||
status = RegQueryValueExW(key,
|
||||
L"SteamExe", NULL, NULL, (BYTE*)steamPath, &pathBytes);
|
||||
RegCloseKey(key);
|
||||
if (status != ERROR_SUCCESS || pathBytes < 1) {
|
||||
if (status != ERROR_SUCCESS || pathBytes < 1)
|
||||
{
|
||||
fprintf(stderr, "Error reading SteamExe key\n");
|
||||
return;
|
||||
}
|
||||
|
161
deps/discord-rpc/src/discord_rpc.cpp
vendored
161
deps/discord-rpc/src/discord_rpc.cpp
vendored
@ -1,7 +1,7 @@
|
||||
#include <retro_common_api.h>
|
||||
#include "discord_rpc.h"
|
||||
|
||||
#include "backoff.h"
|
||||
#include "discord_register.h"
|
||||
#include "msg_queue.h"
|
||||
#include "rpc_connection.h"
|
||||
#include "serialization.h"
|
||||
@ -15,14 +15,23 @@
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
constexpr size_t MaxMessageSize{16 * 1024};
|
||||
constexpr size_t MessageQueueSize{8};
|
||||
constexpr size_t JoinQueueSize{8};
|
||||
|
||||
/* Forward declarations */
|
||||
#if defined(__cplusplus) && !defined(CXX_BUILD)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void Discord_Register(const char *a, const char *b);
|
||||
void Discord_RegisterSteamGame(const char *a, const char *b);
|
||||
|
||||
#if defined(__cplusplus) && !defined(CXX_BUILD)
|
||||
}
|
||||
#endif
|
||||
|
||||
struct QueuedMessage
|
||||
{
|
||||
size_t length;
|
||||
char buffer[MaxMessageSize];
|
||||
char buffer[16384];
|
||||
|
||||
void Copy(const QueuedMessage& other)
|
||||
{
|
||||
@ -50,25 +59,32 @@ struct User
|
||||
* from future changes in these sizes */
|
||||
};
|
||||
|
||||
static int Pid{0};
|
||||
static int Nonce{1};
|
||||
static int LastErrorCode{0};
|
||||
static int LastDisconnectErrorCode{0};
|
||||
|
||||
static char JoinGameSecret[256];
|
||||
static char SpectateGameSecret[256];
|
||||
static char LastErrorMessage[256];
|
||||
static char LastDisconnectErrorMessage[256];
|
||||
|
||||
static RpcConnection* Connection{nullptr};
|
||||
|
||||
static DiscordEventHandlers QueuedHandlers{};
|
||||
static DiscordEventHandlers Handlers{};
|
||||
|
||||
static std::atomic_bool WasJustConnected{false};
|
||||
static std::atomic_bool WasJustDisconnected{false};
|
||||
static std::atomic_bool GotErrorMessage{false};
|
||||
static std::atomic_bool WasJoinGame{false};
|
||||
static std::atomic_bool WasSpectateGame{false};
|
||||
static char JoinGameSecret[256];
|
||||
static char SpectateGameSecret[256];
|
||||
static int LastErrorCode{0};
|
||||
static char LastErrorMessage[256];
|
||||
static int LastDisconnectErrorCode{0};
|
||||
static char LastDisconnectErrorMessage[256];
|
||||
|
||||
static std::mutex PresenceMutex;
|
||||
static std::mutex HandlerMutex;
|
||||
static QueuedMessage QueuedPresence{};
|
||||
static MsgQueue<QueuedMessage, MessageQueueSize> SendQueue;
|
||||
static MsgQueue<User, JoinQueueSize> JoinAskQueue;
|
||||
static MsgQueue<QueuedMessage, 8> SendQueue;
|
||||
static MsgQueue<User, 8> JoinAskQueue;
|
||||
static User connectedUser;
|
||||
|
||||
/* We want to auto connect, and retry on failure,
|
||||
@ -76,57 +92,57 @@ static User connectedUser;
|
||||
* backoff from 0.5 seconds to 1 minute */
|
||||
static Backoff ReconnectTimeMs(500, 60 * 1000);
|
||||
static auto NextConnect = std::chrono::system_clock::now();
|
||||
static int Pid{0};
|
||||
static int Nonce{1};
|
||||
|
||||
#ifndef DISCORD_DISABLE_IO_THREAD
|
||||
static void Discord_UpdateConnection(void);
|
||||
class IoThreadHolder {
|
||||
private:
|
||||
std::atomic_bool keepRunning{true};
|
||||
std::mutex waitForIOMutex;
|
||||
std::condition_variable waitForIOActivity;
|
||||
std::thread ioThread;
|
||||
class IoThreadHolder
|
||||
{
|
||||
private:
|
||||
std::atomic_bool keepRunning{true};
|
||||
std::mutex waitForIOMutex;
|
||||
std::condition_variable waitForIOActivity;
|
||||
std::thread ioThread;
|
||||
|
||||
public:
|
||||
void Start()
|
||||
{
|
||||
keepRunning.store(true);
|
||||
ioThread = std::thread([&]() {
|
||||
const std::chrono::duration<int64_t, std::milli> maxWait{500LL};
|
||||
Discord_UpdateConnection();
|
||||
while (keepRunning.load()) {
|
||||
std::unique_lock<std::mutex> lock(waitForIOMutex);
|
||||
waitForIOActivity.wait_for(lock, maxWait);
|
||||
Discord_UpdateConnection();
|
||||
}
|
||||
});
|
||||
}
|
||||
public:
|
||||
void Start()
|
||||
{
|
||||
keepRunning.store(true);
|
||||
ioThread = std::thread([&]() {
|
||||
const std::chrono::duration<int64_t, std::milli> maxWait{500LL};
|
||||
Discord_UpdateConnection();
|
||||
while (keepRunning.load()) {
|
||||
std::unique_lock<std::mutex> lock(waitForIOMutex);
|
||||
waitForIOActivity.wait_for(lock, maxWait);
|
||||
Discord_UpdateConnection();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Notify() { waitForIOActivity.notify_all(); }
|
||||
void Notify() { waitForIOActivity.notify_all(); }
|
||||
|
||||
void Stop()
|
||||
{
|
||||
keepRunning.exchange(false);
|
||||
Notify();
|
||||
if (ioThread.joinable())
|
||||
void Stop()
|
||||
{
|
||||
keepRunning.exchange(false);
|
||||
Notify();
|
||||
if (ioThread.joinable())
|
||||
ioThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
~IoThreadHolder() { Stop(); }
|
||||
~IoThreadHolder() { Stop(); }
|
||||
};
|
||||
#else
|
||||
class IoThreadHolder {
|
||||
public:
|
||||
void Start() {}
|
||||
void Stop() {}
|
||||
void Notify() {}
|
||||
class IoThreadHolder
|
||||
{
|
||||
public:
|
||||
void Start() {}
|
||||
void Stop() {}
|
||||
void Notify() {}
|
||||
};
|
||||
#endif /* DISCORD_DISABLE_IO_THREAD */
|
||||
|
||||
static IoThreadHolder* IoThread{nullptr};
|
||||
|
||||
static void UpdateReconnectTime()
|
||||
static void UpdateReconnectTime(void)
|
||||
{
|
||||
NextConnect = std::chrono::system_clock::now() +
|
||||
std::chrono::duration<int64_t, std::milli>{ReconnectTimeMs.nextDelay()};
|
||||
@ -160,18 +176,18 @@ static void Discord_UpdateConnection(void)
|
||||
if (!Connection->Read(message))
|
||||
break;
|
||||
|
||||
const char* evtName = GetStrMember(&message, "evt");
|
||||
const char* nonce = GetStrMember(&message, "nonce");
|
||||
const char *evtName = GetStrMember(&message, "evt");
|
||||
const char *nonce = GetStrMember(&message, "nonce");
|
||||
|
||||
if (nonce)
|
||||
{
|
||||
/* in responses only --
|
||||
* should use to match up response when needed. */
|
||||
|
||||
if (evtName && strcmp(evtName, "ERROR") == 0)
|
||||
if (evtName && !strcmp(evtName, "ERROR"))
|
||||
{
|
||||
auto data = GetObjMember(&message, "data");
|
||||
LastErrorCode = GetIntMember(data, "code");
|
||||
JsonValue *data = GetObjMember(&message, "data");
|
||||
LastErrorCode = GetIntMember(data, "code");
|
||||
StringCopy(LastErrorMessage, GetStrMember(data, "message", ""));
|
||||
GotErrorMessage.store(true);
|
||||
}
|
||||
@ -182,39 +198,40 @@ static void Discord_UpdateConnection(void)
|
||||
if (!evtName)
|
||||
continue;
|
||||
|
||||
auto data = GetObjMember(&message, "data");
|
||||
JsonValue *data = GetObjMember(&message, "data");
|
||||
|
||||
if (strcmp(evtName, "ACTIVITY_JOIN") == 0)
|
||||
if (!strcmp(evtName, "ACTIVITY_JOIN"))
|
||||
{
|
||||
auto secret = GetStrMember(data, "secret");
|
||||
const char *secret = GetStrMember(data, "secret");
|
||||
if (secret)
|
||||
{
|
||||
StringCopy(JoinGameSecret, secret);
|
||||
WasJoinGame.store(true);
|
||||
}
|
||||
}
|
||||
else if (strcmp(evtName, "ACTIVITY_SPECTATE") == 0)
|
||||
else if (!strcmp(evtName, "ACTIVITY_SPECTATE"))
|
||||
{
|
||||
auto secret = GetStrMember(data, "secret");
|
||||
const char *secret = GetStrMember(data, "secret");
|
||||
if (secret)
|
||||
{
|
||||
StringCopy(SpectateGameSecret, secret);
|
||||
WasSpectateGame.store(true);
|
||||
}
|
||||
}
|
||||
else if (strcmp(evtName, "ACTIVITY_JOIN_REQUEST") == 0)
|
||||
else if (!strcmp(evtName, "ACTIVITY_JOIN_REQUEST"))
|
||||
{
|
||||
auto user = GetObjMember(data, "user");
|
||||
auto userId = GetStrMember(user, "id");
|
||||
auto username = GetStrMember(user, "username");
|
||||
auto avatar = GetStrMember(user, "avatar");
|
||||
auto joinReq = JoinAskQueue.GetNextAddMessage();
|
||||
JsonValue *user = GetObjMember(data, "user");
|
||||
const char *userId = GetStrMember(user, "id");
|
||||
const char *username = GetStrMember(user, "username");
|
||||
const char *avatar = GetStrMember(user, "avatar");
|
||||
auto joinReq = JoinAskQueue.GetNextAddMessage();
|
||||
|
||||
if (userId && username && joinReq)
|
||||
{
|
||||
StringCopy(joinReq->userId, userId);
|
||||
StringCopy(joinReq->username, username);
|
||||
auto discriminator = GetStrMember(user, "discriminator");
|
||||
const char *discriminator = GetStrMember(user,
|
||||
"discriminator");
|
||||
if (discriminator)
|
||||
StringCopy(joinReq->discriminator, discriminator);
|
||||
if (avatar)
|
||||
@ -321,16 +338,16 @@ extern "C" DISCORD_EXPORT void Discord_Initialize(
|
||||
Connection->onConnect = [](JsonDocument& readyMessage)
|
||||
{
|
||||
Discord_UpdateHandlers(&QueuedHandlers);
|
||||
auto data = GetObjMember(&readyMessage, "data");
|
||||
auto user = GetObjMember(data, "user");
|
||||
auto userId = GetStrMember(user, "id");
|
||||
auto username = GetStrMember(user, "username");
|
||||
auto avatar = GetStrMember(user, "avatar");
|
||||
JsonValue *data = GetObjMember(&readyMessage, "data");
|
||||
JsonValue *user = GetObjMember(data, "user");
|
||||
const char *userId = GetStrMember(user, "id");
|
||||
const char *username = GetStrMember(user, "username");
|
||||
const char *avatar = GetStrMember(user, "avatar");
|
||||
if (userId && username)
|
||||
{
|
||||
StringCopy(connectedUser.userId, userId);
|
||||
StringCopy(connectedUser.username, username);
|
||||
auto discriminator = GetStrMember(user, "discriminator");
|
||||
const char *discriminator = GetStrMember(user, "discriminator");
|
||||
if (discriminator)
|
||||
StringCopy(connectedUser.discriminator, discriminator);
|
||||
if (avatar)
|
||||
|
4
deps/discord-rpc/src/rpc_connection.cpp
vendored
4
deps/discord-rpc/src/rpc_connection.cpp
vendored
@ -36,8 +36,8 @@ void RpcConnection::Open()
|
||||
JsonDocument message;
|
||||
if (Read(message))
|
||||
{
|
||||
auto cmd = GetStrMember(&message, "cmd");
|
||||
auto evt = GetStrMember(&message, "evt");
|
||||
const char *cmd = GetStrMember(&message, "cmd");
|
||||
const char *evt = GetStrMember(&message, "evt");
|
||||
if (cmd && evt
|
||||
&& !strcmp(cmd, "DISPATCH")
|
||||
&& !strcmp(evt, "READY"))
|
||||
|
4
deps/discord-rpc/src/rpc_connection.h
vendored
4
deps/discord-rpc/src/rpc_connection.h
vendored
@ -5,7 +5,7 @@
|
||||
|
||||
/* I took this from the buffer size libuv uses for named pipes;
|
||||
* I suspect ours would usually be much smaller. */
|
||||
constexpr size_t MaxRpcFrameSize = 64 * 1024;
|
||||
#define MAX_RPC_FRAMESIZE 65536
|
||||
|
||||
struct RpcConnection
|
||||
{
|
||||
@ -33,7 +33,7 @@ struct RpcConnection
|
||||
|
||||
struct MessageFrame : public MessageFrameHeader
|
||||
{
|
||||
char message[MaxRpcFrameSize - sizeof(MessageFrameHeader)];
|
||||
char message[MAX_RPC_FRAMESIZE - sizeof(MessageFrameHeader)];
|
||||
};
|
||||
|
||||
enum class State : uint32_t
|
||||
|
49
deps/rcheevos/CHANGELOG.md
vendored
49
deps/rcheevos/CHANGELOG.md
vendored
@ -1,3 +1,52 @@
|
||||
# v9.0.0
|
||||
|
||||
* new size: RC_MEMSIZE_BITCOUNT
|
||||
* new flag: RC_CONDITION_OR_NEXT
|
||||
* new flag: RC_CONDITION_TRIGGER
|
||||
* new flag: RC_CONDITION_MEASURED_IF
|
||||
* new operators: RC_OPERATOR_MULT / RC_OPERATOR_DIV
|
||||
* is_bcd removed from memref - now part of RC_MEMSIZE
|
||||
* add rc_runtime_t and associated functions
|
||||
* add rc_hash_ functions
|
||||
* add rc_error_str function
|
||||
* add game_hash parameter to rc_url_award_cheevo
|
||||
* remove hash parameter from rc_url_submit_lboard
|
||||
* add rc_url_ping function
|
||||
* add rc_console_ functions
|
||||
|
||||
# v8.1.0
|
||||
|
||||
* new flag: RC_CONDITION_MEASURED
|
||||
* new flag: RC_CONDITION_ADD_ADDRESS
|
||||
* add rc_evaluate_trigger - extended version of rc_test_trigger with more granular return codes
|
||||
* make rc_evaluate_value return a signed int (was unsigned int)
|
||||
* new formats: RC_FORMAT_MINUTES and RC_FORMAT_SECONDS_AS_MINUTES
|
||||
* removed " Points" text from RC_FORMAT_SCORE format
|
||||
* removed RC_FORMAT_OTHER format. "OTHER" format now parses to RC_FORMAT_SCORE
|
||||
* bugfix: AddHits will now honor AndNext on previous condition
|
||||
|
||||
# v8.0.1
|
||||
|
||||
* bugfix: prevent null reference exception if rich presence contains condition without display string
|
||||
* bugfix: 24-bit read from memory should only read 24-bits
|
||||
|
||||
# v8.0.0
|
||||
|
||||
* support for prior operand type
|
||||
* support for AndNext condition flag
|
||||
* support for rich presence
|
||||
* bugfix: update delta/prior memory values while group is paused
|
||||
* bugfix: allow floating point number without leading 0
|
||||
* bugfix: support empty alt groups
|
||||
|
||||
# v7.1.1
|
||||
|
||||
* Address signed/unsigned mismatch warnings
|
||||
|
||||
# v7.1.0
|
||||
|
||||
* Added the RC_DISABLE_LUA macro to compile rcheevos without Lua support
|
||||
|
||||
# v7.0.2
|
||||
|
||||
* Make sure the code is C89-compliant
|
||||
|
287
deps/rcheevos/README.md
vendored
287
deps/rcheevos/README.md
vendored
@ -59,10 +59,16 @@ enum {
|
||||
RC_INVALID_VALUE_FLAG = -20,
|
||||
RC_MISSING_VALUE_MEASURED = -21,
|
||||
RC_MULTIPLE_MEASURED = -22,
|
||||
RC_INVALID_MEASURED_TARGET = -23
|
||||
RC_INVALID_MEASURED_TARGET = -23,
|
||||
RC_INVALID_COMPARISON = -24
|
||||
};
|
||||
```
|
||||
|
||||
To convert the return code into something human-readable, pass it to:
|
||||
```c
|
||||
const char* rc_error_str(int ret);
|
||||
```
|
||||
|
||||
### Console identifiers
|
||||
|
||||
This enumeration uniquely identifies each of the supported platforms in RetroAchievements.
|
||||
@ -92,14 +98,38 @@ enum {
|
||||
RC_CONSOLE_PLAYSTATION_2 = 21,
|
||||
RC_CONSOLE_XBOX = 22,
|
||||
RC_CONSOLE_SKYNET = 23,
|
||||
RC_CONSOLE_XBOX_ONE = 24,
|
||||
RC_CONSOLE_POKEMON_MINI = 24,
|
||||
RC_CONSOLE_ATARI_2600 = 25,
|
||||
RC_CONSOLE_MS_DOS = 26,
|
||||
RC_CONSOLE_ARCADE = 27,
|
||||
RC_CONSOLE_VIRTUAL_BOY = 28,
|
||||
RC_CONSOLE_MSX = 29,
|
||||
RC_CONSOLE_COMMODORE_64 = 30,
|
||||
RC_CONSOLE_ZX81 = 31
|
||||
RC_CONSOLE_ZX81 = 31,
|
||||
RC_CONSOLE_ORIC = 32,
|
||||
RC_CONSOLE_SG1000 = 33,
|
||||
RC_CONSOLE_VIC20 = 34,
|
||||
RC_CONSOLE_AMIGA = 35,
|
||||
RC_CONSOLE_AMIGA_ST = 36,
|
||||
RC_CONSOLE_AMSTRAD_PC = 37,
|
||||
RC_CONSOLE_APPLE_II = 38,
|
||||
RC_CONSOLE_SATURN = 39,
|
||||
RC_CONSOLE_DREAMCAST = 40,
|
||||
RC_CONSOLE_PSP = 41,
|
||||
RC_CONSOLE_CDI = 42,
|
||||
RC_CONSOLE_3DO = 43,
|
||||
RC_CONSOLE_COLECOVISION = 44,
|
||||
RC_CONSOLE_INTELLIVISION = 45,
|
||||
RC_CONSOLE_VECTREX = 46,
|
||||
RC_CONSOLE_PC8800 = 47,
|
||||
RC_CONSOLE_PC9800 = 48,
|
||||
RC_CONSOLE_PCFX = 49,
|
||||
RC_CONSOLE_ATARI_5200 = 50,
|
||||
RC_CONSOLE_ATARI_7800 = 51,
|
||||
RC_CONSOLE_X68K = 52,
|
||||
RC_CONSOLE_WONDERSWAN = 53,
|
||||
RC_CONSOLE_CASSETTEVISION = 54,
|
||||
RC_CONSOLE_SUPER_CASSETTEVISION = 55
|
||||
};
|
||||
```
|
||||
|
||||
@ -115,27 +145,23 @@ An operand is the leaf node of RetroAchievements expressions, and can hold one o
|
||||
typedef struct {
|
||||
union {
|
||||
/* A value read from memory. */
|
||||
struct {
|
||||
/* The memory address or constant value of this variable. */
|
||||
unsigned value;
|
||||
/* The previous memory contents if RC_OPERAND_DELTA. */
|
||||
unsigned previous;
|
||||
rc_memref_value_t* memref;
|
||||
|
||||
/* The size of the variable. */
|
||||
char size;
|
||||
/* True if the value is in BCD. */
|
||||
char is_bcd;
|
||||
/* The type of the variable. */
|
||||
};
|
||||
/* An integer value. */
|
||||
unsigned num;
|
||||
|
||||
/* A floating point value. */
|
||||
double fp_value;
|
||||
double dbl;
|
||||
|
||||
/* A reference to the Lua function that provides the value. */
|
||||
int function_ref;
|
||||
int luafunc;
|
||||
};
|
||||
|
||||
/* specifies which member of the value union is being used */
|
||||
char type;
|
||||
|
||||
/* the actual RC_MEMSIZE of the operand - memref.size may differ */
|
||||
char size;
|
||||
}
|
||||
rc_operand_t;
|
||||
```
|
||||
@ -144,20 +170,21 @@ The `size` field, when applicable, holds one of these values:
|
||||
|
||||
```c
|
||||
enum {
|
||||
RC_OPERAND_BIT_0,
|
||||
RC_OPERAND_BIT_1,
|
||||
RC_OPERAND_BIT_2,
|
||||
RC_OPERAND_BIT_3,
|
||||
RC_OPERAND_BIT_4,
|
||||
RC_OPERAND_BIT_5,
|
||||
RC_OPERAND_BIT_6,
|
||||
RC_OPERAND_BIT_7,
|
||||
RC_OPERAND_LOW,
|
||||
RC_OPERAND_HIGH,
|
||||
RC_OPERAND_8_BITS,
|
||||
RC_OPERAND_16_BITS,
|
||||
RC_OPERAND_24_BITS,
|
||||
RC_OPERAND_32_BITS,
|
||||
RC_MEMSIZE_8_BITS,
|
||||
RC_MEMSIZE_16_BITS,
|
||||
RC_MEMSIZE_24_BITS,
|
||||
RC_MEMSIZE_32_BITS,
|
||||
RC_MEMSIZE_LOW,
|
||||
RC_MEMSIZE_HIGH,
|
||||
RC_MEMSIZE_BIT_0,
|
||||
RC_MEMSIZE_BIT_1,
|
||||
RC_MEMSIZE_BIT_2,
|
||||
RC_MEMSIZE_BIT_3,
|
||||
RC_MEMSIZE_BIT_4,
|
||||
RC_MEMSIZE_BIT_5,
|
||||
RC_MEMSIZE_BIT_6,
|
||||
RC_MEMSIZE_BIT_7,
|
||||
RC_MEMSIZE_BITCOUNT
|
||||
};
|
||||
```
|
||||
|
||||
@ -165,15 +192,18 @@ The `type` field is always valid, and holds one of these values:
|
||||
|
||||
```c
|
||||
enum {
|
||||
RC_OPERAND_ADDRESS, /* Compare to the value of a live address in RAM. */
|
||||
RC_OPERAND_DELTA, /* The value last known at this address. */
|
||||
RC_OPERAND_CONST, /* A 32-bit unsigned integer. */
|
||||
RC_OPERAND_FP, /* A floating point value. */
|
||||
RC_OPERAND_LUA /* A Lua function that provides the value. */
|
||||
RC_OPERAND_ADDRESS, /* The value of a live address in RAM. */
|
||||
RC_OPERAND_DELTA, /* The value last known at this address. */
|
||||
RC_OPERAND_CONST, /* A 32-bit unsigned integer. */
|
||||
RC_OPERAND_FP, /* A floating point value. */
|
||||
RC_OPERAND_LUA, /* A Lua function that provides the value. */
|
||||
RC_OPERAND_PRIOR, /* The last differing value at this address. */
|
||||
RC_OPERAND_BCD, /* The BCD-decoded value of a live address in RAM */
|
||||
RC_OPERAND_INVERTED /* The twos-complement value of a live address in RAM */
|
||||
};
|
||||
```
|
||||
|
||||
`RC_OPERAND_ADDRESS`, `RC_OPERAND_DELTA` and `RC_OPERAND_CONST` mean that the anonymous structure in the union is active. `RC_OPERAND_FP` means that `fp_value` is active. `RC_OPERAND_LUA` means `function_ref` is active.
|
||||
`RC_OPERAND_ADDRESS`, `RC_OPERAND_DELTA`, `RC_OPERAND_PRIOR`, `RC_OPERAND_BCD`, and `RC_OPERAND_INVERTED` mean that `memref` is active. `RC_OPERAND_CONST` means that `num` is active. `RC_OPERAND_FP` means that `dbl` is active. `RC_OPERAND_LUA` means `luafunc` is active.
|
||||
|
||||
|
||||
### `rc_condition_t`
|
||||
@ -184,9 +214,6 @@ A condition compares its two operands according to the defined operator. It also
|
||||
typedef struct rc_condition_t rc_condition_t;
|
||||
|
||||
struct rc_condition_t {
|
||||
/* The next condition in the chain. */
|
||||
rc_condition_t* next;
|
||||
|
||||
/* The condition's operands. */
|
||||
rc_operand_t operand1;
|
||||
rc_operand_t operand2;
|
||||
@ -196,6 +223,9 @@ struct rc_condition_t {
|
||||
/* Number of hits so far. */
|
||||
unsigned current_hits;
|
||||
|
||||
/* The next condition in the chain. */
|
||||
rc_condition_t* next;
|
||||
|
||||
/* The type of the condition. */
|
||||
char type;
|
||||
/* The comparison operator to use. */
|
||||
@ -219,7 +249,9 @@ enum {
|
||||
RC_CONDITION_ADD_HITS,
|
||||
RC_CONDITION_AND_NEXT,
|
||||
RC_CONDITION_MEASURED,
|
||||
RC_CONDITION_ADD_ADDRESS
|
||||
RC_CONDITION_ADD_ADDRESS,
|
||||
RC_CONDITION_TRIGGER,
|
||||
RC_CONDITION_MEASURED_IF
|
||||
};
|
||||
```
|
||||
|
||||
@ -227,13 +259,16 @@ enum {
|
||||
|
||||
```c
|
||||
enum {
|
||||
RC_CONDITION_EQ,
|
||||
RC_CONDITION_LT,
|
||||
RC_CONDITION_LE,
|
||||
RC_CONDITION_GT,
|
||||
RC_CONDITION_GE,
|
||||
RC_CONDITION_NE,
|
||||
RC_CONDITION_NONE
|
||||
RC_OPERATOR_EQ,
|
||||
RC_OPERATOR_LT,
|
||||
RC_OPERATOR_LE,
|
||||
RC_OPERATOR_GT,
|
||||
RC_OPERATOR_GE,
|
||||
RC_OPERATOR_NE,
|
||||
RC_OPERATOR_NONE,
|
||||
RC_OPERATOR_MULT,
|
||||
RC_OPERATOR_DIV,
|
||||
RC_OPERATOR_AND
|
||||
};
|
||||
```
|
||||
|
||||
@ -267,6 +302,9 @@ typedef struct {
|
||||
|
||||
/* The list of sub condition sets in this test. */
|
||||
rc_condset_t* alternative;
|
||||
|
||||
/* The memory references required by the trigger. */
|
||||
rc_memref_value_t* memrefs;
|
||||
}
|
||||
rc_trigger_t;
|
||||
```
|
||||
@ -313,7 +351,8 @@ enum {
|
||||
RC_TRIGGER_STATE_ACTIVE, /* achievement is active and may trigger */
|
||||
RC_TRIGGER_STATE_PAUSED, /* achievement is currently paused and will not trigger */
|
||||
RC_TRIGGER_STATE_RESET, /* achievement hit counts were reset */
|
||||
RC_TRIGGER_STATE_TRIGGERED /* achievement has triggered */
|
||||
RC_TRIGGER_STATE_TRIGGERED, /* achievement has triggered */
|
||||
RC_TRIGGER_STATE_PRIMED /* all non-Trigger conditions are true */
|
||||
};
|
||||
```
|
||||
|
||||
@ -323,52 +362,12 @@ Finally, `rc_reset_trigger` can be used to reset the internal state of a trigger
|
||||
void rc_reset_trigger(rc_trigger_t* self);
|
||||
```
|
||||
|
||||
### `rc_term_t`
|
||||
|
||||
A term is the leaf node of expressions used to compute values from operands. A term is evaluated by multiplying its two operands. `invert` is used to invert the bits of the second operand of the term, when the unary operator `~` is used.
|
||||
|
||||
```c
|
||||
typedef struct rc_term_t rc_term_t;
|
||||
|
||||
struct rc_term_t {
|
||||
/* The next term in this chain. */
|
||||
rc_term_t* next;
|
||||
|
||||
/* The first operand. */
|
||||
rc_operand_t operand1;
|
||||
/* The second operand. */
|
||||
rc_operand_t operand2;
|
||||
|
||||
/* A value that is applied to the second variable to invert its bits. */
|
||||
unsigned invert;
|
||||
};
|
||||
```
|
||||
|
||||
### `rc_expression_t`
|
||||
|
||||
An expression is a collection of terms. All terms in the collection are added together to give the value of the expression.
|
||||
|
||||
```c
|
||||
typedef struct rc_expression_t rc_expression_t;
|
||||
|
||||
struct rc_expression_t {
|
||||
/* The next expression in this chain. */
|
||||
rc_expression_t* next;
|
||||
|
||||
/* The list of terms in this expression. */
|
||||
rc_term_t* terms;
|
||||
};
|
||||
```
|
||||
|
||||
### `rc_value_t`
|
||||
|
||||
A value is a collection of expressions. It's used to give the value for a leaderboard, and it evaluates to value of the expression with the greatest value in the collection.
|
||||
A value is a collection of conditions that result in a single RC_CONDITION_MEASURED expression. It's used to calculate the value for a leaderboard and for lookups in rich presence.
|
||||
|
||||
```c
|
||||
typedef struct {
|
||||
/* The list of expression to evaluate. */
|
||||
rc_expression_t* expressions;
|
||||
|
||||
/* The list of conditions to evaluate. */
|
||||
rc_condset_t* conditions;
|
||||
|
||||
@ -413,9 +412,9 @@ typedef struct {
|
||||
rc_trigger_t cancel;
|
||||
rc_value_t value;
|
||||
rc_value_t* progress;
|
||||
rc_memref_value_t* memrefs;
|
||||
|
||||
char started;
|
||||
char submitted;
|
||||
char state;
|
||||
}
|
||||
rc_lboard_t;
|
||||
```
|
||||
@ -437,11 +436,12 @@ The function returns an action that must be performed by the caller, and `value`
|
||||
|
||||
```c
|
||||
enum {
|
||||
RC_LBOARD_INACTIVE,
|
||||
RC_LBOARD_ACTIVE,
|
||||
RC_LBOARD_STARTED,
|
||||
RC_LBOARD_CANCELED,
|
||||
RC_LBOARD_TRIGGERED
|
||||
RC_LBOARD_STATE_INACTIVE, /* leaderboard is not being processed */
|
||||
RC_LBOARD_STATE_WAITING, /* leaderboard cannot activate until the start condition has been false for at least one frame */
|
||||
RC_LBOARD_STATE_ACTIVE, /* leaderboard is active and may start */
|
||||
RC_LBOARD_STATE_STARTED, /* leaderboard attempt in progress */
|
||||
RC_LBOARD_STATE_CANCELED, /* leaderboard attempt canceled */
|
||||
RC_LBOARD_STATE_TRIGGERED /* leaderboard attempt complete, value should be submitted */
|
||||
};
|
||||
```
|
||||
|
||||
@ -458,6 +458,101 @@ The caller must keep track of these values and do the necessary actions:
|
||||
void rc_reset_lboard(rc_lboard_t* lboard);
|
||||
```
|
||||
|
||||
### `rc_runtime_t`
|
||||
|
||||
The runtime encapsulates a set of achievements and leaderboards and manages processing them for each frame. When important things occur, events are raised for the caller via a callback.
|
||||
|
||||
```c
|
||||
typedef struct rc_runtime_t {
|
||||
rc_runtime_trigger_t* triggers;
|
||||
unsigned trigger_count;
|
||||
unsigned trigger_capacity;
|
||||
|
||||
rc_runtime_lboard_t* lboards;
|
||||
unsigned lboard_count;
|
||||
unsigned lboard_capacity;
|
||||
|
||||
rc_runtime_richpresence_t* richpresence;
|
||||
char* richpresence_display_buffer;
|
||||
char richpresence_update_timer;
|
||||
|
||||
rc_memref_value_t* memrefs;
|
||||
rc_memref_value_t** next_memref;
|
||||
}
|
||||
rc_runtime_t;
|
||||
```
|
||||
|
||||
The runtime must first be initialized.
|
||||
```c
|
||||
void rc_runtime_init(rc_runtime_t* runtime);
|
||||
```
|
||||
|
||||
Then individual achievements, leaderboards, and even rich presence can be loaded into the runtime. These functions return RC_OK, or one of the negative value error codes listed above.
|
||||
```c
|
||||
int rc_runtime_activate_achievement(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
|
||||
int rc_runtime_activate_lboard(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
|
||||
int rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, lua_State* L, int funcs_idx);
|
||||
```
|
||||
|
||||
The runtime should be called once per frame to evaluate the state of the active achievements/leaderboards:
|
||||
```c
|
||||
void rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L);
|
||||
```
|
||||
|
||||
The `event_handler` is a callback function that is called for each event that occurs when processing the frame.
|
||||
```c
|
||||
typedef struct rc_runtime_event_t {
|
||||
unsigned id;
|
||||
int value;
|
||||
char type;
|
||||
}
|
||||
rc_runtime_event_t;
|
||||
|
||||
typedef void (*rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_event);
|
||||
```
|
||||
|
||||
The `event.type` field will be one of the following:
|
||||
* RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED (id=achievement id)
|
||||
An achievement starts in the RC_TRIGGER_STATE_WAITING state and cannot trigger until it has been false for at least one frame. This event indicates the achievement is no longer waiting and may trigger on a future frame.
|
||||
* RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED (id=achievement id)
|
||||
One or more conditions in the achievement have disabled the achievement.
|
||||
* RC_RUNTIME_EVENT_ACHIEVEMENT_RESET (id=achievement id)
|
||||
One or more conditions in the achievement have reset any progress captured in the achievement.
|
||||
* RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED (id=achievement id)
|
||||
All conditions for the achievement have been met and the user should be informed.
|
||||
NOTE: If `rc_runtime_reset` is called without deactivating the achievement, it may trigger again.
|
||||
* RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED (id=achievement id)
|
||||
All non-trigger conditions for the achievement have been met. This typically indicates the achievement is a challenge achievement and the challenge is active.
|
||||
* RC_RUNTIME_EVENT_LBOARD_STARTED (id=leaderboard id, value=leaderboard value)
|
||||
The leaderboard's start condition has been met and the user should be informed that a leaderboard attempt has started.
|
||||
* RC_RUNTIME_EVENT_LBOARD_CANCELED (id=leaderboard id, value=leaderboard value)
|
||||
The leaderboard's cancel condition has been met and the user should be informed that a leaderboard attempt has failed.
|
||||
* RC_RUNTIME_EVENT_LBOARD_UPDATED (id=leaderboard id, value=leaderboard value)
|
||||
The leaderboard value has changed.
|
||||
* RC_RUNTIME_EVENT_LBOARD_TRIGGERED (id=leaderboard id, value=leaderboard value)
|
||||
The leaderboard's submit condition has been met and the user should be informed that a leaderboard attempt was successful. The value should be submitted.
|
||||
|
||||
When an achievement triggers, it should be deactivated so it won't trigger again:
|
||||
```c
|
||||
void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, unsigned id);
|
||||
```
|
||||
Additionally, the unlock should be submitted to the server.
|
||||
|
||||
When a leaderboard triggers, it should not be deactivated in case the player wants to try again for a better score. The value should be submitted to the server.
|
||||
|
||||
`rc_runtime_do_frame` also periodically updates the rich presense string (every 60 frames). To get the current value, call
|
||||
```c
|
||||
const char* rc_runtime_get_richpresence(const rc_runtime_t* runtime);
|
||||
```
|
||||
|
||||
When the game is reset, the runtime should also be reset:
|
||||
```c
|
||||
void rc_runtime_reset(rc_runtime_t* runtime);
|
||||
```
|
||||
|
||||
This ensures any active achievements/leaderboards are set back to their initial states and prevents unexpected triggers when the memory changes in atypical way.
|
||||
|
||||
|
||||
### Value Formatting
|
||||
|
||||
**rcheevos** includes helper functions to parse formatting strings from RetroAchievements, and format values according to them.
|
||||
|
266
deps/rcheevos/include/rcheevos.h
vendored
266
deps/rcheevos/include/rcheevos.h
vendored
@ -35,46 +35,12 @@ enum {
|
||||
RC_INVALID_VALUE_FLAG = -20,
|
||||
RC_MISSING_VALUE_MEASURED = -21,
|
||||
RC_MULTIPLE_MEASURED = -22,
|
||||
RC_INVALID_MEASURED_TARGET = -23
|
||||
RC_INVALID_MEASURED_TARGET = -23,
|
||||
RC_INVALID_COMPARISON = -24,
|
||||
RC_INVALID_STATE = -25
|
||||
};
|
||||
|
||||
/*****************************************************************************\
|
||||
| Console identifiers |
|
||||
\*****************************************************************************/
|
||||
|
||||
enum {
|
||||
RC_CONSOLE_MEGA_DRIVE = 1,
|
||||
RC_CONSOLE_NINTENDO_64 = 2,
|
||||
RC_CONSOLE_SUPER_NINTENDO = 3,
|
||||
RC_CONSOLE_GAMEBOY = 4,
|
||||
RC_CONSOLE_GAMEBOY_ADVANCE = 5,
|
||||
RC_CONSOLE_GAMEBOY_COLOR = 6,
|
||||
RC_CONSOLE_NINTENDO = 7,
|
||||
RC_CONSOLE_PC_ENGINE = 8,
|
||||
RC_CONSOLE_SEGA_CD = 9,
|
||||
RC_CONSOLE_SEGA_32X = 10,
|
||||
RC_CONSOLE_MASTER_SYSTEM = 11,
|
||||
RC_CONSOLE_PLAYSTATION = 12,
|
||||
RC_CONSOLE_ATARI_LYNX = 13,
|
||||
RC_CONSOLE_NEOGEO_POCKET = 14,
|
||||
RC_CONSOLE_GAME_GEAR = 15,
|
||||
RC_CONSOLE_GAMECUBE = 16,
|
||||
RC_CONSOLE_ATARI_JAGUAR = 17,
|
||||
RC_CONSOLE_NINTENDO_DS = 18,
|
||||
RC_CONSOLE_WII = 19,
|
||||
RC_CONSOLE_WII_U = 20,
|
||||
RC_CONSOLE_PLAYSTATION_2 = 21,
|
||||
RC_CONSOLE_XBOX = 22,
|
||||
RC_CONSOLE_SKYNET = 23,
|
||||
RC_CONSOLE_XBOX_ONE = 24,
|
||||
RC_CONSOLE_ATARI_2600 = 25,
|
||||
RC_CONSOLE_MS_DOS = 26,
|
||||
RC_CONSOLE_ARCADE = 27,
|
||||
RC_CONSOLE_VIRTUAL_BOY = 28,
|
||||
RC_CONSOLE_MSX = 29,
|
||||
RC_CONSOLE_COMMODORE_64 = 30,
|
||||
RC_CONSOLE_ZX81 = 31
|
||||
};
|
||||
const char* rc_error_str(int ret);
|
||||
|
||||
/*****************************************************************************\
|
||||
| Callbacks |
|
||||
@ -93,6 +59,12 @@ typedef unsigned (*rc_peek_t)(unsigned address, unsigned num_bytes, void* ud);
|
||||
|
||||
/* Sizes. */
|
||||
enum {
|
||||
RC_MEMSIZE_8_BITS,
|
||||
RC_MEMSIZE_16_BITS,
|
||||
RC_MEMSIZE_24_BITS,
|
||||
RC_MEMSIZE_32_BITS,
|
||||
RC_MEMSIZE_LOW,
|
||||
RC_MEMSIZE_HIGH,
|
||||
RC_MEMSIZE_BIT_0,
|
||||
RC_MEMSIZE_BIT_1,
|
||||
RC_MEMSIZE_BIT_2,
|
||||
@ -101,12 +73,7 @@ enum {
|
||||
RC_MEMSIZE_BIT_5,
|
||||
RC_MEMSIZE_BIT_6,
|
||||
RC_MEMSIZE_BIT_7,
|
||||
RC_MEMSIZE_LOW,
|
||||
RC_MEMSIZE_HIGH,
|
||||
RC_MEMSIZE_8_BITS,
|
||||
RC_MEMSIZE_16_BITS,
|
||||
RC_MEMSIZE_24_BITS,
|
||||
RC_MEMSIZE_32_BITS
|
||||
RC_MEMSIZE_BITCOUNT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -114,8 +81,6 @@ typedef struct {
|
||||
unsigned address;
|
||||
/* The size of the variable. */
|
||||
char size;
|
||||
/* True if the value is in BCD. */
|
||||
char is_bcd;
|
||||
/* True if the reference will be used in indirection */
|
||||
char is_indirect;
|
||||
} rc_memref_t;
|
||||
@ -143,12 +108,14 @@ struct rc_memref_value_t {
|
||||
|
||||
/* types */
|
||||
enum {
|
||||
RC_OPERAND_ADDRESS, /* Compare to the value of a live address in RAM. */
|
||||
RC_OPERAND_DELTA, /* The value last known at this address. */
|
||||
RC_OPERAND_CONST, /* A 32-bit unsigned integer. */
|
||||
RC_OPERAND_FP, /* A floating point value. */
|
||||
RC_OPERAND_LUA, /* A Lua function that provides the value. */
|
||||
RC_OPERAND_PRIOR /* The last differing value at this address. */
|
||||
RC_OPERAND_ADDRESS, /* The value of a live address in RAM. */
|
||||
RC_OPERAND_DELTA, /* The value last known at this address. */
|
||||
RC_OPERAND_CONST, /* A 32-bit unsigned integer. */
|
||||
RC_OPERAND_FP, /* A floating point value. */
|
||||
RC_OPERAND_LUA, /* A Lua function that provides the value. */
|
||||
RC_OPERAND_PRIOR, /* The last differing value at this address. */
|
||||
RC_OPERAND_BCD, /* The BCD-decoded value of a live address in RAM */
|
||||
RC_OPERAND_INVERTED /* The twos-complement value of a live address in RAM */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -166,7 +133,11 @@ typedef struct {
|
||||
int luafunc;
|
||||
} value;
|
||||
|
||||
/* specifies which member of the value union is being used */
|
||||
char type;
|
||||
|
||||
/* the actual RC_MEMSIZE of the operand - memref.size may differ */
|
||||
char size;
|
||||
}
|
||||
rc_operand_t;
|
||||
|
||||
@ -184,18 +155,24 @@ enum {
|
||||
RC_CONDITION_ADD_HITS,
|
||||
RC_CONDITION_AND_NEXT,
|
||||
RC_CONDITION_MEASURED,
|
||||
RC_CONDITION_ADD_ADDRESS
|
||||
RC_CONDITION_ADD_ADDRESS,
|
||||
RC_CONDITION_OR_NEXT,
|
||||
RC_CONDITION_TRIGGER,
|
||||
RC_CONDITION_MEASURED_IF
|
||||
};
|
||||
|
||||
/* operators */
|
||||
enum {
|
||||
RC_CONDITION_EQ,
|
||||
RC_CONDITION_LT,
|
||||
RC_CONDITION_LE,
|
||||
RC_CONDITION_GT,
|
||||
RC_CONDITION_GE,
|
||||
RC_CONDITION_NE,
|
||||
RC_CONDITION_NONE
|
||||
RC_OPERATOR_EQ,
|
||||
RC_OPERATOR_LT,
|
||||
RC_OPERATOR_LE,
|
||||
RC_OPERATOR_GT,
|
||||
RC_OPERATOR_GE,
|
||||
RC_OPERATOR_NE,
|
||||
RC_OPERATOR_NONE,
|
||||
RC_OPERATOR_MULT,
|
||||
RC_OPERATOR_DIV,
|
||||
RC_OPERATOR_AND
|
||||
};
|
||||
|
||||
typedef struct rc_condition_t rc_condition_t;
|
||||
@ -256,7 +233,8 @@ enum {
|
||||
RC_TRIGGER_STATE_ACTIVE, /* achievement is active and may trigger */
|
||||
RC_TRIGGER_STATE_PAUSED, /* achievement is currently paused and will not trigger */
|
||||
RC_TRIGGER_STATE_RESET, /* achievement hit counts were reset */
|
||||
RC_TRIGGER_STATE_TRIGGERED /* achievement has triggered */
|
||||
RC_TRIGGER_STATE_TRIGGERED, /* achievement has triggered */
|
||||
RC_TRIGGER_STATE_PRIMED /* all non-Trigger conditions are true */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -290,38 +268,10 @@ int rc_test_trigger(rc_trigger_t* trigger, rc_peek_t peek, void* ud, lua_State*
|
||||
void rc_reset_trigger(rc_trigger_t* self);
|
||||
|
||||
/*****************************************************************************\
|
||||
| Expressions and values |
|
||||
| Values |
|
||||
\*****************************************************************************/
|
||||
|
||||
typedef struct rc_term_t rc_term_t;
|
||||
|
||||
struct rc_term_t {
|
||||
/* The next term in this chain. */
|
||||
rc_term_t* next;
|
||||
|
||||
/* The first operand. */
|
||||
rc_operand_t operand1;
|
||||
/* The second operand. */
|
||||
rc_operand_t operand2;
|
||||
|
||||
/* A value that is applied to the second variable to invert its bits. */
|
||||
unsigned invert;
|
||||
};
|
||||
|
||||
typedef struct rc_expression_t rc_expression_t;
|
||||
|
||||
struct rc_expression_t {
|
||||
/* The next expression in this chain. */
|
||||
rc_expression_t* next;
|
||||
|
||||
/* The list of terms in this expression. */
|
||||
rc_term_t* terms;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
/* The list of expression to evaluate. */
|
||||
rc_expression_t* expressions;
|
||||
|
||||
/* The list of conditions to evaluate. */
|
||||
rc_condset_t* conditions;
|
||||
|
||||
@ -340,11 +290,12 @@ int rc_evaluate_value(rc_value_t* value, rc_peek_t peek, void* ud, lua_State* L)
|
||||
|
||||
/* Return values for rc_evaluate_lboard. */
|
||||
enum {
|
||||
RC_LBOARD_INACTIVE,
|
||||
RC_LBOARD_ACTIVE,
|
||||
RC_LBOARD_STARTED,
|
||||
RC_LBOARD_CANCELED,
|
||||
RC_LBOARD_TRIGGERED
|
||||
RC_LBOARD_STATE_INACTIVE, /* leaderboard is not being processed */
|
||||
RC_LBOARD_STATE_WAITING, /* leaderboard cannot activate until the start condition has been false for at least one frame */
|
||||
RC_LBOARD_STATE_ACTIVE, /* leaderboard is active and may start */
|
||||
RC_LBOARD_STATE_STARTED, /* leaderboard attempt in progress */
|
||||
RC_LBOARD_STATE_CANCELED, /* leaderboard attempt canceled */
|
||||
RC_LBOARD_STATE_TRIGGERED /* leaderboard attempt complete, value should be submitted */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -355,8 +306,7 @@ typedef struct {
|
||||
rc_value_t* progress;
|
||||
rc_memref_value_t* memrefs;
|
||||
|
||||
char started;
|
||||
char submitted;
|
||||
char state;
|
||||
}
|
||||
rc_lboard_t;
|
||||
|
||||
@ -433,6 +383,128 @@ int rc_richpresence_size(const char* script);
|
||||
rc_richpresence_t* rc_parse_richpresence(void* buffer, const char* script, lua_State* L, int funcs_ndx);
|
||||
int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsigned buffersize, rc_peek_t peek, void* peek_ud, lua_State* L);
|
||||
|
||||
/*****************************************************************************\
|
||||
| Runtime |
|
||||
\*****************************************************************************/
|
||||
|
||||
typedef struct rc_runtime_trigger_t {
|
||||
unsigned id;
|
||||
rc_trigger_t* trigger;
|
||||
void* buffer;
|
||||
unsigned char md5[16];
|
||||
char owns_memrefs;
|
||||
}
|
||||
rc_runtime_trigger_t;
|
||||
|
||||
typedef struct rc_runtime_lboard_t {
|
||||
unsigned id;
|
||||
int value;
|
||||
rc_lboard_t* lboard;
|
||||
void* buffer;
|
||||
unsigned char md5[16];
|
||||
char owns_memrefs;
|
||||
}
|
||||
rc_runtime_lboard_t;
|
||||
|
||||
typedef struct rc_runtime_richpresence_t {
|
||||
rc_richpresence_t* richpresence;
|
||||
void* buffer;
|
||||
struct rc_runtime_richpresence_t* previous;
|
||||
char owns_memrefs;
|
||||
}
|
||||
rc_runtime_richpresence_t;
|
||||
|
||||
typedef struct rc_runtime_t {
|
||||
rc_runtime_trigger_t* triggers;
|
||||
unsigned trigger_count;
|
||||
unsigned trigger_capacity;
|
||||
|
||||
rc_runtime_lboard_t* lboards;
|
||||
unsigned lboard_count;
|
||||
unsigned lboard_capacity;
|
||||
|
||||
rc_runtime_richpresence_t* richpresence;
|
||||
char* richpresence_display_buffer;
|
||||
char richpresence_update_timer;
|
||||
|
||||
rc_memref_value_t* memrefs;
|
||||
rc_memref_value_t** next_memref;
|
||||
}
|
||||
rc_runtime_t;
|
||||
|
||||
void rc_runtime_init(rc_runtime_t* runtime);
|
||||
void rc_runtime_destroy(rc_runtime_t* runtime);
|
||||
|
||||
int rc_runtime_activate_achievement(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
|
||||
void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, unsigned id);
|
||||
rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* runtime, unsigned id);
|
||||
|
||||
int rc_runtime_activate_lboard(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
|
||||
void rc_runtime_deactivate_lboard(rc_runtime_t* runtime, unsigned id);
|
||||
rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* runtime, unsigned id);
|
||||
|
||||
int rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, lua_State* L, int funcs_idx);
|
||||
const char* rc_runtime_get_richpresence(const rc_runtime_t* runtime);
|
||||
|
||||
enum {
|
||||
RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED, /* from WAITING, PAUSED, or PRIMED to ACTIVE */
|
||||
RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED,
|
||||
RC_RUNTIME_EVENT_ACHIEVEMENT_RESET,
|
||||
RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED,
|
||||
RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED,
|
||||
RC_RUNTIME_EVENT_LBOARD_STARTED,
|
||||
RC_RUNTIME_EVENT_LBOARD_CANCELED,
|
||||
RC_RUNTIME_EVENT_LBOARD_UPDATED,
|
||||
RC_RUNTIME_EVENT_LBOARD_TRIGGERED
|
||||
};
|
||||
|
||||
typedef struct rc_runtime_event_t {
|
||||
unsigned id;
|
||||
int value;
|
||||
char type;
|
||||
}
|
||||
rc_runtime_event_t;
|
||||
|
||||
typedef void (*rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_event);
|
||||
|
||||
void rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L);
|
||||
void rc_runtime_reset(rc_runtime_t* runtime);
|
||||
|
||||
int rc_runtime_progress_size(const rc_runtime_t* runtime, lua_State* L);
|
||||
int rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, lua_State* L);
|
||||
int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const unsigned char* serialized, lua_State* L);
|
||||
|
||||
/*****************************************************************************\
|
||||
| Memory mapping |
|
||||
\*****************************************************************************/
|
||||
|
||||
enum {
|
||||
RC_MEMORY_TYPE_SYSTEM_RAM, /* normal system memory */
|
||||
RC_MEMORY_TYPE_SAVE_RAM, /* memory that persists between sessions */
|
||||
RC_MEMORY_TYPE_VIDEO_RAM, /* memory reserved for graphical processing */
|
||||
RC_MEMORY_TYPE_READONLY, /* memory that maps to read only data */
|
||||
RC_MEMORY_TYPE_HARDWARE_CONTROLLER, /* memory for interacting with system components */
|
||||
RC_MEMORY_TYPE_VIRTUAL_RAM, /* secondary address space that maps to real memory in system RAM */
|
||||
RC_MEMORY_TYPE_UNUSED /* these addresses don't really exist */
|
||||
};
|
||||
|
||||
typedef struct rc_memory_region_t {
|
||||
unsigned start_address; /* first address of block as queried by RetroAchievements */
|
||||
unsigned end_address; /* last address of block as queried by RetroAchievements */
|
||||
unsigned real_address; /* real address for first address of block */
|
||||
char type; /* RC_MEMORY_TYPE_ for block */
|
||||
const char* description; /* short description of block */
|
||||
}
|
||||
rc_memory_region_t;
|
||||
|
||||
typedef struct rc_memory_regions_t {
|
||||
const rc_memory_region_t* region;
|
||||
unsigned num_regions;
|
||||
}
|
||||
rc_memory_regions_t;
|
||||
|
||||
const rc_memory_regions_t* rc_console_memory_regions(int console_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
79
deps/rcheevos/include/rconsoles.h
vendored
Normal file
79
deps/rcheevos/include/rconsoles.h
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef RCONSOLES_H
|
||||
#define RCONSOLES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*****************************************************************************\
|
||||
| Console identifiers |
|
||||
\*****************************************************************************/
|
||||
|
||||
enum {
|
||||
RC_CONSOLE_MEGA_DRIVE = 1,
|
||||
RC_CONSOLE_NINTENDO_64 = 2,
|
||||
RC_CONSOLE_SUPER_NINTENDO = 3,
|
||||
RC_CONSOLE_GAMEBOY = 4,
|
||||
RC_CONSOLE_GAMEBOY_ADVANCE = 5,
|
||||
RC_CONSOLE_GAMEBOY_COLOR = 6,
|
||||
RC_CONSOLE_NINTENDO = 7,
|
||||
RC_CONSOLE_PC_ENGINE = 8,
|
||||
RC_CONSOLE_SEGA_CD = 9,
|
||||
RC_CONSOLE_SEGA_32X = 10,
|
||||
RC_CONSOLE_MASTER_SYSTEM = 11,
|
||||
RC_CONSOLE_PLAYSTATION = 12,
|
||||
RC_CONSOLE_ATARI_LYNX = 13,
|
||||
RC_CONSOLE_NEOGEO_POCKET = 14,
|
||||
RC_CONSOLE_GAME_GEAR = 15,
|
||||
RC_CONSOLE_GAMECUBE = 16,
|
||||
RC_CONSOLE_ATARI_JAGUAR = 17,
|
||||
RC_CONSOLE_NINTENDO_DS = 18,
|
||||
RC_CONSOLE_WII = 19,
|
||||
RC_CONSOLE_WII_U = 20,
|
||||
RC_CONSOLE_PLAYSTATION_2 = 21,
|
||||
RC_CONSOLE_XBOX = 22,
|
||||
/* 23 used to be EVENTS */
|
||||
RC_CONSOLE_POKEMON_MINI = 24,
|
||||
RC_CONSOLE_ATARI_2600 = 25,
|
||||
RC_CONSOLE_MS_DOS = 26,
|
||||
RC_CONSOLE_ARCADE = 27,
|
||||
RC_CONSOLE_VIRTUAL_BOY = 28,
|
||||
RC_CONSOLE_MSX = 29,
|
||||
RC_CONSOLE_COMMODORE_64 = 30,
|
||||
RC_CONSOLE_ZX81 = 31,
|
||||
RC_CONSOLE_ORIC = 32,
|
||||
RC_CONSOLE_SG1000 = 33,
|
||||
RC_CONSOLE_VIC20 = 34,
|
||||
RC_CONSOLE_AMIGA = 35,
|
||||
RC_CONSOLE_AMIGA_ST = 36,
|
||||
RC_CONSOLE_AMSTRAD_PC = 37,
|
||||
RC_CONSOLE_APPLE_II = 38,
|
||||
RC_CONSOLE_SATURN = 39,
|
||||
RC_CONSOLE_DREAMCAST = 40,
|
||||
RC_CONSOLE_PSP = 41,
|
||||
RC_CONSOLE_CDI = 42,
|
||||
RC_CONSOLE_3DO = 43,
|
||||
RC_CONSOLE_COLECOVISION = 44,
|
||||
RC_CONSOLE_INTELLIVISION = 45,
|
||||
RC_CONSOLE_VECTREX = 46,
|
||||
RC_CONSOLE_PC8800 = 47,
|
||||
RC_CONSOLE_PC9800 = 48,
|
||||
RC_CONSOLE_PCFX = 49,
|
||||
RC_CONSOLE_ATARI_5200 = 50,
|
||||
RC_CONSOLE_ATARI_7800 = 51,
|
||||
RC_CONSOLE_X68K = 52,
|
||||
RC_CONSOLE_WONDERSWAN = 53,
|
||||
RC_CONSOLE_CASSETTEVISION = 54,
|
||||
RC_CONSOLE_SUPER_CASSETTEVISION = 55,
|
||||
|
||||
RC_CONSOLE_HUBS = 100,
|
||||
RC_CONSOLE_EVENTS = 101
|
||||
};
|
||||
|
||||
const char* rc_console_name(int console_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RCONSOLES_H */
|
124
deps/rcheevos/include/rhash.h
vendored
Normal file
124
deps/rcheevos/include/rhash.h
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef RHASH_H
|
||||
#define RHASH_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "rconsoles.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
/* generates a hash from a block of memory.
|
||||
* returns non-zero on success, or zero on failure.
|
||||
*/
|
||||
int rc_hash_generate_from_buffer(char hash[33], int console_id, uint8_t* buffer, size_t buffer_size);
|
||||
|
||||
/* generates a hash from a file.
|
||||
* returns non-zero on success, or zero on failure.
|
||||
*/
|
||||
int rc_hash_generate_from_file(char hash[33], int console_id, const char* path);
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
/* data for rc_hash_iterate
|
||||
*/
|
||||
struct rc_hash_iterator
|
||||
{
|
||||
uint8_t* buffer;
|
||||
size_t buffer_size;
|
||||
uint8_t consoles[12];
|
||||
int index;
|
||||
const char* path;
|
||||
};
|
||||
|
||||
/* initializes a rc_hash_iterator
|
||||
* - path must be provided
|
||||
* - if buffer and buffer_size are provided, path may be a filename (i.e. for something extracted from a zip file)
|
||||
*/
|
||||
void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char* path, uint8_t* buffer, size_t buffer_size);
|
||||
|
||||
/* releases resources associated to a rc_hash_iterator
|
||||
*/
|
||||
void rc_hash_destroy_iterator(struct rc_hash_iterator* iterator);
|
||||
|
||||
/* generates the next hash for the data in the rc_hash_iterator.
|
||||
* returns non-zero if a hash was generated, or zero if no more hashes can be generated for the data.
|
||||
*/
|
||||
int rc_hash_iterate(char hash[33], struct rc_hash_iterator* iterator);
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
/* specifies a function to call when an error occurs to display the error message */
|
||||
typedef void (*rc_hash_message_callback)(const char*);
|
||||
void rc_hash_init_error_message_callback(rc_hash_message_callback callback);
|
||||
|
||||
/* specifies a function to call for verbose logging */
|
||||
void rc_hash_init_verbose_message_callback(rc_hash_message_callback callback);
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
/* opens a file */
|
||||
typedef void* (*rc_hash_filereader_open_file_handler)(const char* path_utf8);
|
||||
|
||||
/* moves the file pointer - standard fseek parameters */
|
||||
typedef void (*rc_hash_filereader_seek_handler)(void* file_handle, size_t offset, int origin);
|
||||
|
||||
/* locates the file pointer */
|
||||
typedef size_t (*rc_hash_filereader_tell_handler)(void* file_handle);
|
||||
|
||||
/* reads the specified number of bytes from the file starting at the read pointer.
|
||||
* returns the number of bytes actually read.
|
||||
*/
|
||||
typedef size_t (*rc_hash_filereader_read_handler)(void* file_handle, void* buffer, size_t requested_bytes);
|
||||
|
||||
/* closes the file */
|
||||
typedef void (*rc_hash_filereader_close_file_handler)(void* file_handle);
|
||||
|
||||
struct rc_hash_filereader
|
||||
{
|
||||
rc_hash_filereader_open_file_handler open;
|
||||
rc_hash_filereader_seek_handler seek;
|
||||
rc_hash_filereader_tell_handler tell;
|
||||
rc_hash_filereader_read_handler read;
|
||||
rc_hash_filereader_close_file_handler close;
|
||||
};
|
||||
|
||||
void rc_hash_init_custom_filereader(struct rc_hash_filereader* reader);
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
/* opens a track from the specified file. track 0 indicates the first data track should be opened.
|
||||
* returns a handle to be passed to the other functions, or NULL if the track could not be opened.
|
||||
*/
|
||||
typedef void* (*rc_hash_cdreader_open_track_handler)(const char* path, uint32_t track);
|
||||
|
||||
/* attempts to read the specified number of bytes from the file starting at the read pointer.
|
||||
* returns the number of bytes actually read.
|
||||
*/
|
||||
typedef size_t (*rc_hash_cdreader_read_sector_handler)(void* track_handle, uint32_t sector, void* buffer, size_t requested_bytes);
|
||||
|
||||
/* closes the track handle */
|
||||
typedef void (*rc_hash_cdreader_close_track_handler)(void* track_handle);
|
||||
|
||||
struct rc_hash_cdreader
|
||||
{
|
||||
rc_hash_cdreader_open_track_handler open_track;
|
||||
rc_hash_cdreader_read_sector_handler read_sector;
|
||||
rc_hash_cdreader_close_track_handler close_track;
|
||||
};
|
||||
|
||||
void rc_hash_init_default_cdreader();
|
||||
void rc_hash_init_custom_cdreader(struct rc_hash_cdreader* reader);
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RHASH_H */
|
9
deps/rcheevos/include/rurl.h
vendored
9
deps/rcheevos/include/rurl.h
vendored
@ -7,11 +7,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore);
|
||||
int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore, const char* game_hash);
|
||||
|
||||
int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value, const char* game_hash);
|
||||
int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value);
|
||||
|
||||
int rc_url_get_gameid(char* buffer, size_t size, unsigned char hash[16]);
|
||||
int rc_url_get_gameid(char* buffer, size_t size, const char* hash);
|
||||
|
||||
int rc_url_get_patch(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned gameid);
|
||||
|
||||
@ -25,6 +25,9 @@ int rc_url_get_unlock_list(char* buffer, size_t size, const char* user_name, con
|
||||
|
||||
int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned gameid);
|
||||
|
||||
int rc_url_ping(char* url_buffer, size_t url_buffer_size, char* post_buffer, size_t post_buffer_size,
|
||||
const char* user_name, const char* login_token, unsigned gameid, const char* rich_presence);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
34
deps/rcheevos/src/rcheevos/alloc.c
vendored
34
deps/rcheevos/src/rcheevos/alloc.c
vendored
@ -52,3 +52,37 @@ void rc_destroy_parse_state(rc_parse_state_t* parse)
|
||||
if (parse->scratch.memref != parse->scratch.memref_buffer)
|
||||
free(parse->scratch.memref);
|
||||
}
|
||||
|
||||
const char* rc_error_str(int ret)
|
||||
{
|
||||
switch (ret) {
|
||||
case RC_OK: return "OK";
|
||||
case RC_INVALID_LUA_OPERAND: return "Invalid Lua operand";
|
||||
case RC_INVALID_MEMORY_OPERAND: return "Invalid memory operand";
|
||||
case RC_INVALID_CONST_OPERAND: return "Invalid constant operand";
|
||||
case RC_INVALID_FP_OPERAND: return "Invalid floating-point operand";
|
||||
case RC_INVALID_CONDITION_TYPE: return "Invalid condition type";
|
||||
case RC_INVALID_OPERATOR: return "Invalid operator";
|
||||
case RC_INVALID_REQUIRED_HITS: return "Invalid required hits";
|
||||
case RC_DUPLICATED_START: return "Duplicated start condition";
|
||||
case RC_DUPLICATED_CANCEL: return "Duplicated cancel condition";
|
||||
case RC_DUPLICATED_SUBMIT: return "Duplicated submit condition";
|
||||
case RC_DUPLICATED_VALUE: return "Duplicated value expression";
|
||||
case RC_DUPLICATED_PROGRESS: return "Duplicated progress expression";
|
||||
case RC_MISSING_START: return "Missing start condition";
|
||||
case RC_MISSING_CANCEL: return "Missing cancel condition";
|
||||
case RC_MISSING_SUBMIT: return "Missing submit condition";
|
||||
case RC_MISSING_VALUE: return "Missing value expression";
|
||||
case RC_INVALID_LBOARD_FIELD: return "Invalid field in leaderboard";
|
||||
case RC_MISSING_DISPLAY_STRING: return "Missing display string";
|
||||
case RC_OUT_OF_MEMORY: return "Out of memory";
|
||||
case RC_INVALID_VALUE_FLAG: return "Invalid flag in value expression";
|
||||
case RC_MISSING_VALUE_MEASURED: return "Missing measured flag in value expression";
|
||||
case RC_MULTIPLE_MEASURED: return "Multiple measured targets";
|
||||
case RC_INVALID_MEASURED_TARGET: return "Invalid measured target";
|
||||
case RC_INVALID_COMPARISON: return "Invalid comparison";
|
||||
case RC_INVALID_STATE: return "Invalid state";
|
||||
|
||||
default: return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
44
deps/rcheevos/src/rcheevos/compat.c
vendored
Normal file
44
deps/rcheevos/src/rcheevos/compat.c
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
#include "compat.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int rc_strncasecmp(const char* left, const char* right, size_t length)
|
||||
{
|
||||
while (length)
|
||||
{
|
||||
if (*left != *right)
|
||||
{
|
||||
const int diff = tolower(*left) - tolower(*right);
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
}
|
||||
|
||||
++left;
|
||||
++right;
|
||||
--length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* rc_strdup(const char* str)
|
||||
{
|
||||
const size_t length = strlen(str);
|
||||
char* buffer = (char*)malloc(length + 1);
|
||||
memcpy(buffer, str, length + 1);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int rc_snprintf(char* buffer, size_t size, const char* format, ...)
|
||||
{
|
||||
int result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
/* assume buffer is large enough and ignore size */
|
||||
result = vsprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
return result;
|
||||
}
|
55
deps/rcheevos/src/rcheevos/compat.h
vendored
Normal file
55
deps/rcheevos/src/rcheevos/compat.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef RC_COMPAT_H
|
||||
#define RC_COMPAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MINGW) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
|
||||
/* MinGW redefinitions */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
/* Visual Studio redefinitions */
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
#ifndef strdup
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#elif __STDC_VERSION__ < 199901L
|
||||
|
||||
/* C89 redefinitions */
|
||||
|
||||
#ifndef snprintf
|
||||
extern int rc_snprintf(char* buffer, size_t size, const char* format, ...);
|
||||
#define snprintf rc_snprintf
|
||||
#endif
|
||||
|
||||
#ifndef strncasecmp
|
||||
extern int rc_strncasecmp(const char* left, const char* right, size_t length);
|
||||
#define strncasecmp rc_strncasecmp
|
||||
#endif
|
||||
|
||||
#ifndef strdup
|
||||
extern char* rc_strdup(const char* str);
|
||||
#define strdup rc_strdup
|
||||
#endif
|
||||
|
||||
#endif /* __STDC_VERSION__ < 199901L */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RC_COMPAT_H */
|
122
deps/rcheevos/src/rcheevos/condition.c
vendored
122
deps/rcheevos/src/rcheevos/condition.c
vendored
@ -6,6 +6,7 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
rc_condition_t* self;
|
||||
const char* aux;
|
||||
int ret2;
|
||||
int can_modify = 0;
|
||||
|
||||
aux = *memaddr;
|
||||
self = RC_ALLOC(rc_condition_t, parse);
|
||||
@ -15,12 +16,15 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
switch (*aux) {
|
||||
case 'p': case 'P': self->type = RC_CONDITION_PAUSE_IF; break;
|
||||
case 'r': case 'R': self->type = RC_CONDITION_RESET_IF; break;
|
||||
case 'a': case 'A': self->type = RC_CONDITION_ADD_SOURCE; break;
|
||||
case 'b': case 'B': self->type = RC_CONDITION_SUB_SOURCE; break;
|
||||
case 'a': case 'A': self->type = RC_CONDITION_ADD_SOURCE; can_modify = 1; break;
|
||||
case 'b': case 'B': self->type = RC_CONDITION_SUB_SOURCE; can_modify = 1; break;
|
||||
case 'c': case 'C': self->type = RC_CONDITION_ADD_HITS; break;
|
||||
case 'n': case 'N': self->type = RC_CONDITION_AND_NEXT; break;
|
||||
case 'o': case 'O': self->type = RC_CONDITION_OR_NEXT; break;
|
||||
case 'm': case 'M': self->type = RC_CONDITION_MEASURED; break;
|
||||
case 'i': case 'I': self->type = RC_CONDITION_ADD_ADDRESS; break;
|
||||
case 'q': case 'Q': self->type = RC_CONDITION_MEASURED_IF; break;
|
||||
case 'i': case 'I': self->type = RC_CONDITION_ADD_ADDRESS; can_modify = 1; break;
|
||||
case 't': case 'T': self->type = RC_CONDITION_TRIGGER; break;
|
||||
default: parse->offset = RC_INVALID_CONDITION_TYPE; return 0;
|
||||
}
|
||||
|
||||
@ -37,9 +41,14 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->operand1.type == RC_OPERAND_FP) {
|
||||
parse->offset = can_modify ? RC_INVALID_FP_OPERAND : RC_INVALID_COMPARISON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (*aux++) {
|
||||
case '=':
|
||||
self->oper = RC_CONDITION_EQ;
|
||||
self->oper = RC_OPERATOR_EQ;
|
||||
aux += *aux == '=';
|
||||
break;
|
||||
|
||||
@ -51,33 +60,45 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
return 0;
|
||||
}
|
||||
|
||||
self->oper = RC_CONDITION_NE;
|
||||
self->oper = RC_OPERATOR_NE;
|
||||
break;
|
||||
|
||||
case '<':
|
||||
self->oper = RC_CONDITION_LT;
|
||||
self->oper = RC_OPERATOR_LT;
|
||||
|
||||
if (*aux == '=') {
|
||||
self->oper = RC_CONDITION_LE;
|
||||
self->oper = RC_OPERATOR_LE;
|
||||
aux++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '>':
|
||||
self->oper = RC_CONDITION_GT;
|
||||
self->oper = RC_OPERATOR_GT;
|
||||
|
||||
if (*aux == '=') {
|
||||
self->oper = RC_CONDITION_GE;
|
||||
self->oper = RC_OPERATOR_GE;
|
||||
aux++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '*':
|
||||
self->oper = RC_OPERATOR_MULT;
|
||||
break;
|
||||
|
||||
case '/':
|
||||
self->oper = RC_OPERATOR_DIV;
|
||||
break;
|
||||
|
||||
case '&':
|
||||
self->oper = RC_OPERATOR_AND;
|
||||
break;
|
||||
|
||||
case '_':
|
||||
case ')':
|
||||
case '\0':
|
||||
self->oper = RC_CONDITION_NONE;
|
||||
self->oper = RC_OPERATOR_NONE;
|
||||
self->operand2.type = RC_OPERAND_CONST;
|
||||
self->operand2.value.num = 1;
|
||||
self->required_hits = 0;
|
||||
@ -85,6 +106,36 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
return self;
|
||||
}
|
||||
|
||||
switch (self->oper) {
|
||||
case RC_OPERATOR_MULT:
|
||||
case RC_OPERATOR_DIV:
|
||||
case RC_OPERATOR_AND:
|
||||
/* modifying operators are only valid on modifying statements */
|
||||
if (!can_modify) {
|
||||
parse->offset = RC_INVALID_OPERATOR;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* comparison operators are not valid on modifying statements */
|
||||
if (can_modify) {
|
||||
switch (self->type) {
|
||||
case RC_CONDITION_ADD_SOURCE:
|
||||
case RC_CONDITION_SUB_SOURCE:
|
||||
case RC_CONDITION_ADD_ADDRESS:
|
||||
/* prevent parse errors on legacy achievements where a condition was present before changing the type */
|
||||
self->oper = RC_OPERATOR_NONE;
|
||||
break;
|
||||
|
||||
default:
|
||||
parse->offset = RC_INVALID_OPERATOR;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ret2 = rc_parse_operand(&self->operand2, &aux, 1, is_indirect, parse);
|
||||
|
||||
if (ret2 < 0) {
|
||||
@ -92,6 +143,17 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->oper == RC_OPERATOR_NONE) {
|
||||
/* if operator is none, explicitly clear out the right side */
|
||||
self->operand2.type = RC_INVALID_CONST_OPERAND;
|
||||
self->operand2.value.num = 0;
|
||||
}
|
||||
|
||||
if (!can_modify && self->operand2.type == RC_OPERAND_FP) {
|
||||
parse->offset = RC_INVALID_COMPARISON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*aux == '(') {
|
||||
char* end;
|
||||
self->required_hits = (unsigned)strtoul(++aux, &end, 10);
|
||||
@ -127,13 +189,39 @@ int rc_test_condition(rc_condition_t* self, rc_eval_state_t* eval_state) {
|
||||
unsigned value2 = rc_evaluate_operand(&self->operand2, eval_state);
|
||||
|
||||
switch (self->oper) {
|
||||
case RC_CONDITION_EQ: return value1 == value2;
|
||||
case RC_CONDITION_NE: return value1 != value2;
|
||||
case RC_CONDITION_LT: return value1 < value2;
|
||||
case RC_CONDITION_LE: return value1 <= value2;
|
||||
case RC_CONDITION_GT: return value1 > value2;
|
||||
case RC_CONDITION_GE: return value1 >= value2;
|
||||
case RC_CONDITION_NONE: return 1;
|
||||
case RC_OPERATOR_EQ: return value1 == value2;
|
||||
case RC_OPERATOR_NE: return value1 != value2;
|
||||
case RC_OPERATOR_LT: return value1 < value2;
|
||||
case RC_OPERATOR_LE: return value1 <= value2;
|
||||
case RC_OPERATOR_GT: return value1 > value2;
|
||||
case RC_OPERATOR_GE: return value1 >= value2;
|
||||
case RC_OPERATOR_NONE: return 1;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int rc_evaluate_condition_value(rc_condition_t* self, rc_eval_state_t* eval_state) {
|
||||
unsigned value = rc_evaluate_operand(&self->operand1, eval_state);
|
||||
|
||||
switch (self->oper) {
|
||||
case RC_OPERATOR_MULT:
|
||||
if (self->operand2.type == RC_OPERAND_FP)
|
||||
value = (int)((double)value * self->operand2.value.dbl);
|
||||
else
|
||||
value *= rc_evaluate_operand(&self->operand2, eval_state);
|
||||
break;
|
||||
|
||||
case RC_OPERATOR_DIV:
|
||||
if (self->operand2.type == RC_OPERAND_FP)
|
||||
value = (int)((double)value / self->operand2.value.dbl);
|
||||
else
|
||||
value /= rc_evaluate_operand(&self->operand2, eval_state);
|
||||
break;
|
||||
|
||||
case RC_OPERATOR_AND:
|
||||
value &= rc_evaluate_operand(&self->operand2, eval_state);
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
183
deps/rcheevos/src/rcheevos/condset.c
vendored
183
deps/rcheevos/src/rcheevos/condset.c
vendored
@ -9,15 +9,16 @@ static void rc_update_condition_pause(rc_condition_t* condition, int* in_pause)
|
||||
case RC_CONDITION_PAUSE_IF:
|
||||
*in_pause = condition->pause = 1;
|
||||
break;
|
||||
|
||||
|
||||
case RC_CONDITION_ADD_SOURCE:
|
||||
case RC_CONDITION_SUB_SOURCE:
|
||||
case RC_CONDITION_ADD_HITS:
|
||||
case RC_CONDITION_AND_NEXT:
|
||||
case RC_CONDITION_OR_NEXT:
|
||||
case RC_CONDITION_ADD_ADDRESS:
|
||||
condition->pause = *in_pause;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
*in_pause = condition->pause = 0;
|
||||
break;
|
||||
@ -48,14 +49,15 @@ rc_condset_t* rc_parse_condset(const char** memaddr, rc_parse_state_t* parse) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*next)->oper == RC_CONDITION_NONE) {
|
||||
if ((*next)->oper == RC_OPERATOR_NONE) {
|
||||
switch ((*next)->type) {
|
||||
case RC_CONDITION_ADD_ADDRESS:
|
||||
case RC_CONDITION_ADD_HITS:
|
||||
case RC_CONDITION_ADD_SOURCE:
|
||||
case RC_CONDITION_SUB_SOURCE:
|
||||
case RC_CONDITION_AND_NEXT:
|
||||
break;
|
||||
case RC_CONDITION_OR_NEXT:
|
||||
break;
|
||||
|
||||
default:
|
||||
parse->offset = RC_INVALID_OPERATOR;
|
||||
@ -110,10 +112,14 @@ rc_condset_t* rc_parse_condset(const char** memaddr, rc_parse_state_t* parse) {
|
||||
|
||||
static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc_eval_state_t* eval_state) {
|
||||
rc_condition_t* condition;
|
||||
int set_valid, cond_valid, prev_cond;
|
||||
int set_valid, cond_valid, and_next, or_next;
|
||||
unsigned measured_value = 0;
|
||||
int can_measure = 1, measured_from_hits = 0;
|
||||
|
||||
eval_state->primed = 1;
|
||||
set_valid = 1;
|
||||
prev_cond = 1;
|
||||
and_next = 1;
|
||||
or_next = 0;
|
||||
eval_state->add_value = eval_state->add_hits = eval_state->add_address = 0;
|
||||
|
||||
for (condition = self->conditions; condition != 0; condition = condition->next) {
|
||||
@ -121,93 +127,107 @@ static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc
|
||||
continue;
|
||||
}
|
||||
|
||||
/* STEP 1: process modifier conditions */
|
||||
switch (condition->type) {
|
||||
case RC_CONDITION_ADD_SOURCE:
|
||||
eval_state->add_value += rc_evaluate_operand(&condition->operand1, eval_state);
|
||||
eval_state->add_value += rc_evaluate_condition_value(condition, eval_state);
|
||||
eval_state->add_address = 0;
|
||||
continue;
|
||||
|
||||
|
||||
case RC_CONDITION_SUB_SOURCE:
|
||||
eval_state->add_value -= rc_evaluate_operand(&condition->operand1, eval_state);
|
||||
eval_state->add_address = 0;
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_ADD_HITS:
|
||||
/* always evaluate the condition to ensure everything is updated correctly */
|
||||
cond_valid = rc_test_condition(condition, eval_state);
|
||||
|
||||
/* merge AndNext value and reset it for the next condition */
|
||||
cond_valid &= prev_cond;
|
||||
prev_cond = 1;
|
||||
|
||||
/* if the condition is true, tally it */
|
||||
if (cond_valid) {
|
||||
if (condition->required_hits == 0 || condition->current_hits < condition->required_hits) {
|
||||
condition->current_hits++;
|
||||
}
|
||||
|
||||
condition->is_true = (condition->required_hits == 0 || condition->current_hits >= condition->required_hits);
|
||||
}
|
||||
else {
|
||||
condition->is_true = 0;
|
||||
}
|
||||
|
||||
eval_state->add_value = 0;
|
||||
eval_state->add_address = 0;
|
||||
eval_state->add_hits += condition->current_hits;
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_AND_NEXT:
|
||||
prev_cond &= rc_test_condition(condition, eval_state);
|
||||
eval_state->add_value = 0;
|
||||
eval_state->add_value -= rc_evaluate_condition_value(condition, eval_state);
|
||||
eval_state->add_address = 0;
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_ADD_ADDRESS:
|
||||
eval_state->add_address = rc_evaluate_operand(&condition->operand1, eval_state);
|
||||
eval_state->add_address = rc_evaluate_condition_value(condition, eval_state);
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_MEASURED:
|
||||
if (condition->required_hits == 0) {
|
||||
/* Measured condition without a hit target measures the value of the left operand */
|
||||
measured_value = rc_evaluate_condition_value(condition, eval_state) + eval_state->add_value;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* always evaluate the condition to ensure everything is updated correctly */
|
||||
cond_valid = rc_test_condition(condition, eval_state);
|
||||
/* STEP 2: evaluate the current condition */
|
||||
condition->is_true = rc_test_condition(condition, eval_state);
|
||||
eval_state->add_value = 0;
|
||||
eval_state->add_address = 0;
|
||||
|
||||
/* merge AndNext value and reset it for the next condition */
|
||||
cond_valid &= prev_cond;
|
||||
prev_cond = 1;
|
||||
/* apply logic flags and reset them for the next condition */
|
||||
cond_valid = condition->is_true;
|
||||
cond_valid &= and_next;
|
||||
cond_valid |= or_next;
|
||||
and_next = 1;
|
||||
or_next = 0;
|
||||
|
||||
/* if the condition has a target hit count that has already been met, it's automatically true, even if not currently true. */
|
||||
if (condition->required_hits != 0 && (condition->current_hits + eval_state->add_hits) >= condition->required_hits) {
|
||||
cond_valid = 1;
|
||||
}
|
||||
else if (cond_valid) {
|
||||
condition->current_hits++;
|
||||
/* true conditions should update hit count */
|
||||
if (cond_valid) {
|
||||
eval_state->has_hits = 1;
|
||||
|
||||
if (condition->required_hits == 0) {
|
||||
/* not a hit-based requirement: ignore any additional logic! */
|
||||
/* no target hit count, just keep tallying */
|
||||
++condition->current_hits;
|
||||
}
|
||||
else if ((condition->current_hits + eval_state->add_hits) < condition->required_hits) {
|
||||
/* HitCount target has not yet been met, condition is not yet valid */
|
||||
cond_valid = 0;
|
||||
else if (condition->current_hits < condition->required_hits) {
|
||||
/* target hit count hasn't been met, tally and revalidate - only true if hit count becomes met */
|
||||
++condition->current_hits;
|
||||
cond_valid = (condition->current_hits == condition->required_hits);
|
||||
}
|
||||
else {
|
||||
/* target hit count has been met, do nothing */
|
||||
}
|
||||
}
|
||||
condition->is_true = cond_valid;
|
||||
eval_state->has_hits |= (condition->current_hits || eval_state->add_hits);
|
||||
else if (condition->current_hits > 0) {
|
||||
/* target has been true in the past, if the hit target is met, consider it true now */
|
||||
eval_state->has_hits = 1;
|
||||
cond_valid = (condition->current_hits == condition->required_hits);
|
||||
}
|
||||
|
||||
/* capture measured state */
|
||||
if (condition->type == RC_CONDITION_MEASURED) {
|
||||
unsigned int measured_value;
|
||||
if (condition->required_hits > 0)
|
||||
/* STEP 3: handle logic flags */
|
||||
switch (condition->type) {
|
||||
case RC_CONDITION_ADD_HITS:
|
||||
eval_state->add_hits += condition->current_hits;
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_AND_NEXT:
|
||||
and_next = cond_valid;
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_OR_NEXT:
|
||||
or_next = cond_valid;
|
||||
continue;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (eval_state->add_hits) {
|
||||
if (condition->required_hits != 0) {
|
||||
/* if the condition has a target hit count, we have to recalculate cond_valid including the AddHits counter */
|
||||
measured_from_hits = 1;
|
||||
measured_value = condition->current_hits + eval_state->add_hits;
|
||||
else
|
||||
measured_value = rc_evaluate_operand(&condition->operand1, eval_state) + eval_state->add_value;
|
||||
cond_valid = (measured_value >= condition->required_hits);
|
||||
}
|
||||
else {
|
||||
/* no target hit count. we can't tell if the add_hits value is from this frame or not, so ignore it.
|
||||
complex condition will only be true if the current condition is true */
|
||||
}
|
||||
|
||||
if (measured_value > eval_state->measured_value)
|
||||
eval_state->measured_value = measured_value;
|
||||
eval_state->add_hits = 0;
|
||||
}
|
||||
else if (condition->required_hits != 0) {
|
||||
/* if there's a hit target, capture the current hits for recording Measured value later */
|
||||
measured_from_hits = 1;
|
||||
measured_value = condition->current_hits;
|
||||
}
|
||||
|
||||
/* reset AddHits and AddSource/SubSource values */
|
||||
eval_state->add_value = eval_state->add_hits = eval_state->add_address = 0;
|
||||
|
||||
/* STEP 4: handle special flags */
|
||||
switch (condition->type) {
|
||||
case RC_CONDITION_PAUSE_IF:
|
||||
/* as soon as we find a PauseIf that evaluates to true, stop processing the rest of the group */
|
||||
@ -227,20 +247,38 @@ static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc
|
||||
/* PauseIf has a HitCount that hasn't been met, ignore it for now. */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_RESET_IF:
|
||||
if (cond_valid) {
|
||||
eval_state->was_reset = 1; /* let caller know to reset all hit counts */
|
||||
set_valid = 0; /* cannot be valid if we've hit a reset condition */
|
||||
}
|
||||
continue;
|
||||
|
||||
case RC_CONDITION_MEASURED_IF:
|
||||
if (!cond_valid)
|
||||
can_measure = 0;
|
||||
break;
|
||||
|
||||
case RC_CONDITION_TRIGGER:
|
||||
/* update truthiness of set, but do not update truthiness of primed state */
|
||||
set_valid &= cond_valid;
|
||||
continue;
|
||||
|
||||
default:
|
||||
set_valid &= cond_valid;
|
||||
break;
|
||||
}
|
||||
|
||||
/* STEP 5: update overall truthiness of set and primed state */
|
||||
eval_state->primed &= cond_valid;
|
||||
set_valid &= cond_valid;
|
||||
}
|
||||
|
||||
/* if not suppressed, update the measured value */
|
||||
if (measured_value > eval_state->measured_value && can_measure) {
|
||||
eval_state->measured_value = measured_value;
|
||||
eval_state->measured_from_hits = measured_from_hits;
|
||||
}
|
||||
|
||||
return set_valid;
|
||||
@ -255,6 +293,7 @@ int rc_test_condset(rc_condset_t* self, rc_eval_state_t* eval_state) {
|
||||
if (self->has_pause) {
|
||||
if ((self->is_paused = rc_test_condset_internal(self, 1, eval_state))) {
|
||||
/* one or more Pause conditions exists, if any of them are true, stop processing this group */
|
||||
eval_state->primed = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
573
deps/rcheevos/src/rcheevos/consoleinfo.c
vendored
Normal file
573
deps/rcheevos/src/rcheevos/consoleinfo.c
vendored
Normal file
@ -0,0 +1,573 @@
|
||||
#include "rcheevos.h"
|
||||
#include "rconsoles.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
const char* rc_console_name(int console_id)
|
||||
{
|
||||
switch (console_id)
|
||||
{
|
||||
case RC_CONSOLE_3DO:
|
||||
return "3DO";
|
||||
|
||||
case RC_CONSOLE_AMIGA:
|
||||
return "Amiga";
|
||||
|
||||
case RC_CONSOLE_AMIGA_ST:
|
||||
return "Amiga ST";
|
||||
|
||||
case RC_CONSOLE_AMSTRAD_PC:
|
||||
return "Amstrad CPC";
|
||||
|
||||
case RC_CONSOLE_APPLE_II:
|
||||
return "Apple II";
|
||||
|
||||
case RC_CONSOLE_ARCADE:
|
||||
return "Arcade";
|
||||
|
||||
case RC_CONSOLE_ATARI_2600:
|
||||
return "Atari 2600";
|
||||
|
||||
case RC_CONSOLE_ATARI_5200:
|
||||
return "Atari 5200";
|
||||
|
||||
case RC_CONSOLE_ATARI_7800:
|
||||
return "Atari 7800";
|
||||
|
||||
case RC_CONSOLE_ATARI_JAGUAR:
|
||||
return "Atari Jaguar";
|
||||
|
||||
case RC_CONSOLE_ATARI_LYNX:
|
||||
return "Atari Lynx";
|
||||
|
||||
case RC_CONSOLE_CASSETTEVISION:
|
||||
return "CassetteVision";
|
||||
|
||||
case RC_CONSOLE_CDI:
|
||||
return "CD-I";
|
||||
|
||||
case RC_CONSOLE_COLECOVISION:
|
||||
return "ColecoVision";
|
||||
|
||||
case RC_CONSOLE_COMMODORE_64:
|
||||
return "Commodore 64";
|
||||
|
||||
case RC_CONSOLE_DREAMCAST:
|
||||
return "Dreamcast";
|
||||
|
||||
case RC_CONSOLE_EVENTS:
|
||||
return "Events";
|
||||
|
||||
case RC_CONSOLE_GAMEBOY:
|
||||
return "GameBoy";
|
||||
|
||||
case RC_CONSOLE_GAMEBOY_ADVANCE:
|
||||
return "GameBoy Advance";
|
||||
|
||||
case RC_CONSOLE_GAMEBOY_COLOR:
|
||||
return "GameBoy Color";
|
||||
|
||||
case RC_CONSOLE_GAMECUBE:
|
||||
return "GameCube";
|
||||
|
||||
case RC_CONSOLE_GAME_GEAR:
|
||||
return "Game Gear";
|
||||
|
||||
case RC_CONSOLE_HUBS:
|
||||
return "Hubs";
|
||||
|
||||
case RC_CONSOLE_INTELLIVISION:
|
||||
return "Intellivision";
|
||||
|
||||
case RC_CONSOLE_MASTER_SYSTEM:
|
||||
return "Master System";
|
||||
|
||||
case RC_CONSOLE_MEGA_DRIVE:
|
||||
return "Sega Genesis";
|
||||
|
||||
case RC_CONSOLE_MS_DOS:
|
||||
return "MS-DOS";
|
||||
|
||||
case RC_CONSOLE_MSX:
|
||||
return "MSX";
|
||||
|
||||
case RC_CONSOLE_NINTENDO:
|
||||
return "Nintendo Entertainment System";
|
||||
|
||||
case RC_CONSOLE_NINTENDO_64:
|
||||
return "Nintendo 64";
|
||||
|
||||
case RC_CONSOLE_NINTENDO_DS:
|
||||
return "Nintendo DS";
|
||||
|
||||
case RC_CONSOLE_NEOGEO_POCKET:
|
||||
return "Neo Geo Pocket";
|
||||
|
||||
case RC_CONSOLE_ORIC:
|
||||
return "Oric";
|
||||
|
||||
case RC_CONSOLE_PC8800:
|
||||
return "PC-8000/8800";
|
||||
|
||||
case RC_CONSOLE_PC9800:
|
||||
return "PC-9800";
|
||||
|
||||
case RC_CONSOLE_PCFX:
|
||||
return "PCFX";
|
||||
|
||||
case RC_CONSOLE_PC_ENGINE:
|
||||
return "PCEngine";
|
||||
|
||||
case RC_CONSOLE_PLAYSTATION:
|
||||
return "PlayStation";
|
||||
|
||||
case RC_CONSOLE_PLAYSTATION_2:
|
||||
return "PlayStation 2";
|
||||
|
||||
case RC_CONSOLE_PSP:
|
||||
return "PlayStation Portable";
|
||||
|
||||
case RC_CONSOLE_POKEMON_MINI:
|
||||
return "Pokemon Mini";
|
||||
|
||||
case RC_CONSOLE_SEGA_32X:
|
||||
return "Sega 32X";
|
||||
|
||||
case RC_CONSOLE_SEGA_CD:
|
||||
return "Sega CD";
|
||||
|
||||
case RC_CONSOLE_SATURN:
|
||||
return "Sega Saturn";
|
||||
|
||||
case RC_CONSOLE_SG1000:
|
||||
return "SG-1000";
|
||||
|
||||
case RC_CONSOLE_SUPER_NINTENDO:
|
||||
return "Super Nintendo Entertainment System";
|
||||
|
||||
case RC_CONSOLE_SUPER_CASSETTEVISION:
|
||||
return "Super CassetteVision";
|
||||
|
||||
case RC_CONSOLE_WONDERSWAN:
|
||||
return "WonderSwan";
|
||||
|
||||
case RC_CONSOLE_VECTREX:
|
||||
return "Vectrex";
|
||||
|
||||
case RC_CONSOLE_VIC20:
|
||||
return "VIC-20";
|
||||
|
||||
case RC_CONSOLE_VIRTUAL_BOY:
|
||||
return "Virtual Boy";
|
||||
|
||||
case RC_CONSOLE_WII:
|
||||
return "Wii";
|
||||
|
||||
case RC_CONSOLE_WII_U:
|
||||
return "Wii-U";
|
||||
|
||||
case RC_CONSOLE_X68K:
|
||||
return "X68K";
|
||||
|
||||
case RC_CONSOLE_XBOX:
|
||||
return "XBOX";
|
||||
|
||||
case RC_CONSOLE_ZX81:
|
||||
return "ZX-81";
|
||||
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== 3DO ===== */
|
||||
/* http://www.arcaderestoration.com/memorymap/48/3DO+Bios.aspx */
|
||||
/* NOTE: the Opera core attempts to expose the NVRAM as RETRO_SAVE_RAM, but the 3DO documentation
|
||||
* says that applications should only access NVRAM through API calls as it's shared across mulitple
|
||||
* games. This suggests that even if the core does expose it, it may change depending on which other
|
||||
* games the user has played - so ignore it.
|
||||
*/
|
||||
static const rc_memory_region_t _rc_memory_regions_3do[] = {
|
||||
{ 0x000000U, 0x1FFFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" },
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_3do = { _rc_memory_regions_3do, 1 };
|
||||
|
||||
/* ===== Apple II ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_appleii[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" },
|
||||
{ 0x010000U, 0x01FFFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Auxillary RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_appleii = { _rc_memory_regions_appleii, 2 };
|
||||
|
||||
/* ===== Atari 2600 ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_atari2600[] = {
|
||||
{ 0x000000U, 0x00007FU, 0x000080U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_atari2600 = { _rc_memory_regions_atari2600, 1 };
|
||||
|
||||
/* ===== Atari 7800 ===== */
|
||||
/* http://www.atarihq.com/danb/files/78map.txt */
|
||||
/* http://pdf.textfiles.com/technical/7800_devkit.pdf */
|
||||
static const rc_memory_region_t _rc_memory_regions_atari7800[] = {
|
||||
{ 0x000000U, 0x0017FFU, 0x000000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware Interface" },
|
||||
{ 0x001800U, 0x0027FFU, 0x001800U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x002800U, 0x002FFFU, 0x002800U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" },
|
||||
{ 0x003000U, 0x0037FFU, 0x003000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" },
|
||||
{ 0x003800U, 0x003FFFU, 0x003800U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" },
|
||||
{ 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" },
|
||||
{ 0x008000U, 0x00FFFFU, 0x008000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_atari7800 = { _rc_memory_regions_atari7800, 7 };
|
||||
|
||||
/* ===== Atari Jaguar ===== */
|
||||
/* https://www.mulle-kybernetik.com/jagdox/memorymap.html */
|
||||
static const rc_memory_region_t _rc_memory_regions_atari_jaguar[] = {
|
||||
{ 0x000000U, 0x1FFFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_atari_jaguar = { _rc_memory_regions_atari_jaguar, 1 };
|
||||
|
||||
/* ===== Atari Lynx ===== */
|
||||
/* http://www.retroisle.com/atari/lynx/Technical/Programming/lynxprgdumm.php */
|
||||
static const rc_memory_region_t _rc_memory_regions_atari_lynx[] = {
|
||||
{ 0x000000U, 0x0000FFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Zero Page" },
|
||||
{ 0x000100U, 0x0001FFU, 0x000100U, RC_MEMORY_TYPE_SYSTEM_RAM, "Stack" },
|
||||
{ 0x000200U, 0x00FBFFU, 0x000200U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x00FC00U, 0x00FCFFU, 0x00FC00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "SUZY hardware access" },
|
||||
{ 0x00FD00U, 0x00FDFFU, 0x00FD00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "MIKEY hardware access" },
|
||||
{ 0x00FE00U, 0x00FFF7U, 0x00FE00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Boot ROM" },
|
||||
{ 0x00FFF8U, 0x00FFFFU, 0x00FFF8U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware vectors" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_atari_lynx = { _rc_memory_regions_atari_lynx, 7 };
|
||||
|
||||
/* ===== ColecoVision ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_colecovision[] = {
|
||||
{ 0x000000U, 0x0003FFU, 0x006000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_colecovision = { _rc_memory_regions_colecovision, 1 };
|
||||
|
||||
/* ===== GameBoy / GameBoy Color ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_gameboy[] = {
|
||||
{ 0x000000U, 0x0000FFU, 0x000000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Interrupt vector" },
|
||||
{ 0x000100U, 0x00014FU, 0x000100U, RC_MEMORY_TYPE_READONLY, "Cartridge header" },
|
||||
{ 0x000150U, 0x003FFFU, 0x000150U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM (fixed)" }, /* bank 0 */
|
||||
{ 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM (paged)" }, /* bank 1-XX (switchable) */
|
||||
{ 0x008000U, 0x0097FFU, 0x008000U, RC_MEMORY_TYPE_VIDEO_RAM, "Tile RAM" },
|
||||
{ 0x009800U, 0x009BFFU, 0x009800U, RC_MEMORY_TYPE_VIDEO_RAM, "BG1 map data" },
|
||||
{ 0x009C00U, 0x009FFFU, 0x009C00U, RC_MEMORY_TYPE_VIDEO_RAM, "BG2 map data" },
|
||||
{ 0x00A000U, 0x00BFFFU, 0x00A000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM"},
|
||||
{ 0x00C000U, 0x00CFFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (fixed)" },
|
||||
{ 0x00D000U, 0x00DFFFU, 0x00D000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (bank 1)" },
|
||||
{ 0x00E000U, 0x00FDFFU, 0x00C000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Echo RAM" },
|
||||
{ 0x00FE00U, 0x00FE9FU, 0x00FE00U, RC_MEMORY_TYPE_VIDEO_RAM, "Sprite RAM"},
|
||||
{ 0x00FEA0U, 0x00FEFFU, 0x00FEA0U, RC_MEMORY_TYPE_READONLY, "Unusable"},
|
||||
{ 0x00FF00U, 0x00FF7FU, 0x00FF00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware I/O"},
|
||||
{ 0x00FF80U, 0x00FFFEU, 0x00FF80U, RC_MEMORY_TYPE_SYSTEM_RAM, "Quick RAM"},
|
||||
{ 0x00FFFFU, 0x00FFFFU, 0x00FFFFU, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Interrupt enable"},
|
||||
|
||||
/* GameBoy Color provides six extra banks of memory that can be paged out through the $DXXX
|
||||
* memory space, but the timing of that does not correspond with blanks, which is when achievements
|
||||
* are processed. As such, it is desirable to always have access to these extra banks. We do this
|
||||
* by expecting the extra banks to be addressable at addresses not supported by the native system. */
|
||||
{ 0x010000U, 0x015FFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (banks 2-7, GBC only)" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_gameboy = { _rc_memory_regions_gameboy, 16 };
|
||||
static const rc_memory_regions_t rc_memory_regions_gameboy_color = { _rc_memory_regions_gameboy, 17 };
|
||||
|
||||
/* ===== GameBoy Advance ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_gameboy_advance[] = {
|
||||
{ 0x000000U, 0x007FFFU, 0x03000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" },
|
||||
{ 0x008000U, 0x047FFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_gameboy_advance = { _rc_memory_regions_gameboy_advance, 2 };
|
||||
|
||||
/* ===== Game Gear ===== */
|
||||
/* http://www.smspower.org/Development/MemoryMap */
|
||||
static const rc_memory_region_t _rc_memory_regions_game_gear[] = {
|
||||
{ 0x000000U, 0x001FFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_game_gear = { _rc_memory_regions_game_gear, 1 };
|
||||
|
||||
/* ===== Intellivision ===== */
|
||||
/* http://wiki.intellivision.us/index.php%3Ftitle%3DMemory_Map */
|
||||
static const rc_memory_region_t _rc_memory_regions_intellivision[] = {
|
||||
{ 0x000000U, 0x00007FU, 0x000000U, RC_MEMORY_TYPE_VIDEO_RAM, "STIC Registers" },
|
||||
{ 0x000080U, 0x0000FFU, 0x000080U, RC_MEMORY_TYPE_UNUSED, "" },
|
||||
{ 0x000100U, 0x00035FU, 0x000100U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x000360U, 0x0003FFU, 0x000360U, RC_MEMORY_TYPE_UNUSED, "" },
|
||||
{ 0x000400U, 0x000FFFU, 0x000400U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" },
|
||||
{ 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_UNUSED, "" },
|
||||
{ 0x002000U, 0x002FFFU, 0x002000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" },
|
||||
{ 0x003000U, 0x003FFFU, 0x003000U, RC_MEMORY_TYPE_VIDEO_RAM, "Video RAM" },
|
||||
{ 0x004000U, 0x00FFFFU, 0x004000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" },
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_intellivision = { _rc_memory_regions_intellivision, 9 };
|
||||
|
||||
/* ===== Master System ===== */
|
||||
/* http://www.smspower.org/Development/MemoryMap */
|
||||
static const rc_memory_region_t _rc_memory_regions_master_system[] = {
|
||||
{ 0x000000U, 0x001FFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_master_system = { _rc_memory_regions_master_system, 1 };
|
||||
|
||||
/* ===== MegaDrive (Genesis) ===== */
|
||||
/* http://www.smspower.org/Development/MemoryMap */
|
||||
static const rc_memory_region_t _rc_memory_regions_megadrive[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0xFF0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x010000U, 0x01FFFFU, 0x000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_megadrive = { _rc_memory_regions_megadrive, 2 };
|
||||
|
||||
/* ===== Neo Geo Pocket ===== */
|
||||
/* http://neopocott.emuunlim.com/docs/tech-11.txt */
|
||||
static const rc_memory_region_t _rc_memory_regions_neo_geo_pocket[] = {
|
||||
/* MednafenNGP exposes 16KB, but the doc suggests there's 24-32KB */
|
||||
{ 0x000000U, 0x003FFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_neo_geo_pocket = { _rc_memory_regions_neo_geo_pocket, 1 };
|
||||
|
||||
/* ===== Nintendo Entertainment System ===== */
|
||||
/* https://wiki.nesdev.com/w/index.php/CPU_memory_map */
|
||||
static const rc_memory_region_t _rc_memory_regions_nes[] = {
|
||||
{ 0x0000U, 0x07FFU, 0x0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x0800U, 0x0FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
|
||||
{ 0x1000U, 0x17FFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
|
||||
{ 0x1800U, 0x1FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */
|
||||
{ 0x2000U, 0x2007U, 0x2000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "PPU Register" },
|
||||
{ 0x2008U, 0x3FFFU, 0x2008U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored PPU Register" }, /* repeats every 8 bytes */
|
||||
{ 0x4000U, 0x4017U, 0x4000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O register" },
|
||||
{ 0x4018U, 0x401FU, 0x4018U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O test register" },
|
||||
{ 0x4020U, 0x5FFFU, 0x4020U, RC_MEMORY_TYPE_READONLY, "Cartridge data"}, /* varies by mapper */
|
||||
{ 0x6000U, 0x7FFFU, 0x6000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM"},
|
||||
{ 0x8000U, 0xFFFFU, 0x8000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM"},
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_nes = { _rc_memory_regions_nes, 11 };
|
||||
|
||||
/* ===== Nintendo 64 ===== */
|
||||
/* https://raw.githubusercontent.com/mikeryan/n64dev/master/docs/n64ops/n64ops%23h.txt */
|
||||
static const rc_memory_region_t _rc_memory_regions_n64[] = {
|
||||
{ 0x000000U, 0x1FFFFFU, 0x00000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RDRAM 1 */
|
||||
{ 0x200000U, 0x3FFFFFU, 0x00020000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RDRAM 2 */
|
||||
{ 0x400000U, 0x7FFFFFU, 0x80000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } /* expansion pak - cannot find any details for real address */
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_n64 = { _rc_memory_regions_n64, 3 };
|
||||
|
||||
/* ===== Nintendo DS ===== */
|
||||
/* https://www.akkit.org/info/gbatek.htm#dsmemorymaps */
|
||||
static const rc_memory_region_t _rc_memory_regions_nintendo_ds[] = {
|
||||
{ 0x000000U, 0x3FFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_nintendo_ds = { _rc_memory_regions_nintendo_ds, 1 };
|
||||
|
||||
/* ===== Oric ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_oric[] = {
|
||||
/* actual size depends on machine type - up to 64KB */
|
||||
{ 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_oric = { _rc_memory_regions_oric, 1 };
|
||||
|
||||
/* ===== PC-8800 ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_pc8800[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" },
|
||||
{ 0x010000U, 0x010FFFU, 0x010000U, RC_MEMORY_TYPE_VIDEO_RAM, "Text VRAM" } /* technically VRAM, but often used as system RAM */
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_pc8800 = { _rc_memory_regions_pc8800, 2 };
|
||||
|
||||
/* ===== PC Engine ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_pcengine[] = {
|
||||
{ 0x000000U, 0x001FFFU, 0x1F0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x002000U, 0x011FFFU, 0x100000U, RC_MEMORY_TYPE_SYSTEM_RAM, "CD RAM" },
|
||||
{ 0x012000U, 0x041FFFU, 0x0D0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Super System Card RAM" },
|
||||
{ 0x042000U, 0x0427FFU, 0x1EE000U, RC_MEMORY_TYPE_SAVE_RAM, "CD Battery-backed RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_pcengine = { _rc_memory_regions_pcengine, 4 };
|
||||
|
||||
/* ===== PlayStation ===== */
|
||||
/* http://www.raphnet.net/electronique/psx_adaptor/Playstation.txt */
|
||||
static const rc_memory_region_t _rc_memory_regions_playstation[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Kernel RAM" },
|
||||
{ 0x010000U, 0x1FFFFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_playstation = { _rc_memory_regions_playstation, 2 };
|
||||
|
||||
/* ===== Pokemon Mini ===== */
|
||||
/* https://www.pokemon-mini.net/documentation/memory-map/ */
|
||||
static const rc_memory_region_t _rc_memory_regions_pokemini[] = {
|
||||
{ 0x000000U, 0x000FFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "BIOS RAM" },
|
||||
{ 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_pokemini = { _rc_memory_regions_pokemini, 2 };
|
||||
|
||||
/* ===== Sega CD ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_segacd[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0x00FF0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "68000 RAM" },
|
||||
{ 0x010000U, 0x08FFFFU, 0x80000000U, RC_MEMORY_TYPE_SAVE_RAM, "CD PRG RAM" } /* normally banked into $020000-$03FFFF */
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_segacd = { _rc_memory_regions_segacd, 2 };
|
||||
|
||||
/* ===== Sega Saturn ===== */
|
||||
/* https://segaretro.org/Sega_Saturn_hardware_notes_(2004-04-27) */
|
||||
static const rc_memory_region_t _rc_memory_regions_saturn[] = {
|
||||
{ 0x000000U, 0x0FFFFFU, 0x00200000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Work RAM Low" },
|
||||
{ 0x100000U, 0x1FFFFFU, 0x06000000U, RC_MEMORY_TYPE_SAVE_RAM, "Work RAM High" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_saturn = { _rc_memory_regions_saturn, 2 };
|
||||
|
||||
/* ===== SG-1000 ===== */
|
||||
/* http://www.smspower.org/Development/MemoryMap */
|
||||
static const rc_memory_region_t _rc_memory_regions_sg1000[] = {
|
||||
{ 0x000000U, 0x0003FFU, 0xC000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
/* TODO: should cartridge memory be exposed ($0000-$BFFF)? it's usually just ROM data, but may contain on-cartridge RAM
|
||||
* This not is also concerning: http://www.smspower.org/Development/MemoryMap
|
||||
* Cartridges may disable the system RAM and thus take over the full 64KB address space. */
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_sg1000 = { _rc_memory_regions_sg1000, 1 };
|
||||
|
||||
/* ===== Super Cassette Vision ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_scv[] = {
|
||||
{ 0x000000U, 0x000FFFU, 0x000000U, RC_MEMORY_TYPE_READONLY, "System ROM" },
|
||||
{ 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_UNUSED, "" },
|
||||
{ 0x002000U, 0x003FFFU, 0x002000U, RC_MEMORY_TYPE_VIDEO_RAM, "Video RAM" },
|
||||
{ 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_UNUSED, "" },
|
||||
{ 0x008000U, 0x00DFFFU, 0x008000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM" },
|
||||
{ 0x00E000U, 0x00FF7FU, 0x00E000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" },
|
||||
{ 0x00FF80U, 0x00FFFFU, 0x00FF80U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_scv = { _rc_memory_regions_scv, 7 };
|
||||
|
||||
/* ===== Super Nintendo ===== */
|
||||
/* https://segaretro.org/Sega_Saturn_hardware_notes_(2004-04-27) */
|
||||
static const rc_memory_region_t _rc_memory_regions_snes[] = {
|
||||
{ 0x000000U, 0x01FFFFU, 0x7E0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x020000U, 0x03FFFFU, 0xFE0000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_snes = { _rc_memory_regions_snes, 2 };
|
||||
|
||||
/* ===== WonderSwan ===== */
|
||||
/* http://daifukkat.su/docs/wsman/#ovr_memmap */
|
||||
static const rc_memory_region_t _rc_memory_regions_wonderswan[] = {
|
||||
/* RAM ends at 0x3FFF for WonderSwan, WonderSwan color uses all 64KB */
|
||||
{ 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_wonderswan = { _rc_memory_regions_wonderswan, 1 };
|
||||
|
||||
/* ===== Vectrex ===== */
|
||||
/* https://roadsidethoughts.com/vectrex/vectrex-memory-map.htm */
|
||||
static const rc_memory_region_t _rc_memory_regions_vectrex[] = {
|
||||
{ 0x000000U, 0x0003FFU, 0x00C800U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_vectrex = { _rc_memory_regions_vectrex, 1 };
|
||||
|
||||
/* ===== Virtual Boy ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_virtualboy[] = {
|
||||
{ 0x000000U, 0x00FFFFU, 0x05000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x010000U, 0x01FFFFU, 0x06000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_virtualboy = { _rc_memory_regions_virtualboy, 2 };
|
||||
|
||||
/* ===== default ===== */
|
||||
static const rc_memory_regions_t rc_memory_regions_none = { 0, 0 };
|
||||
|
||||
const rc_memory_regions_t* rc_console_memory_regions(int console_id)
|
||||
{
|
||||
switch (console_id)
|
||||
{
|
||||
case RC_CONSOLE_3DO:
|
||||
return &rc_memory_regions_3do;
|
||||
|
||||
case RC_CONSOLE_APPLE_II:
|
||||
return &rc_memory_regions_appleii;
|
||||
|
||||
case RC_CONSOLE_ATARI_2600:
|
||||
return &rc_memory_regions_atari2600;
|
||||
|
||||
case RC_CONSOLE_ATARI_7800:
|
||||
return &rc_memory_regions_atari7800;
|
||||
|
||||
case RC_CONSOLE_ATARI_JAGUAR:
|
||||
return &rc_memory_regions_atari_jaguar;
|
||||
|
||||
case RC_CONSOLE_ATARI_LYNX:
|
||||
return &rc_memory_regions_atari_lynx;
|
||||
|
||||
case RC_CONSOLE_COLECOVISION:
|
||||
return &rc_memory_regions_colecovision;
|
||||
|
||||
case RC_CONSOLE_GAMEBOY:
|
||||
return &rc_memory_regions_gameboy;
|
||||
|
||||
case RC_CONSOLE_GAMEBOY_COLOR:
|
||||
return &rc_memory_regions_gameboy_color;
|
||||
|
||||
case RC_CONSOLE_GAMEBOY_ADVANCE:
|
||||
return &rc_memory_regions_gameboy_advance;
|
||||
|
||||
case RC_CONSOLE_GAME_GEAR:
|
||||
return &rc_memory_regions_game_gear;
|
||||
|
||||
case RC_CONSOLE_INTELLIVISION:
|
||||
return &rc_memory_regions_intellivision;
|
||||
|
||||
case RC_CONSOLE_MASTER_SYSTEM:
|
||||
return &rc_memory_regions_master_system;
|
||||
|
||||
case RC_CONSOLE_MEGA_DRIVE:
|
||||
case RC_CONSOLE_SEGA_32X:
|
||||
/* NOTE: 32x adds an extra 512KB of memory (256KB RAM + 256KB VRAM) to the
|
||||
* Genesis, but we currently don't support it. */
|
||||
return &rc_memory_regions_megadrive;
|
||||
|
||||
case RC_CONSOLE_NEOGEO_POCKET:
|
||||
return &rc_memory_regions_neo_geo_pocket;
|
||||
|
||||
case RC_CONSOLE_NINTENDO:
|
||||
return &rc_memory_regions_nes;
|
||||
|
||||
case RC_CONSOLE_NINTENDO_64:
|
||||
return &rc_memory_regions_n64;
|
||||
|
||||
case RC_CONSOLE_NINTENDO_DS:
|
||||
return &rc_memory_regions_nintendo_ds;
|
||||
|
||||
case RC_CONSOLE_ORIC:
|
||||
return &rc_memory_regions_oric;
|
||||
|
||||
case RC_CONSOLE_PC8800:
|
||||
return &rc_memory_regions_pc8800;
|
||||
|
||||
case RC_CONSOLE_PC_ENGINE:
|
||||
return &rc_memory_regions_pcengine;
|
||||
|
||||
case RC_CONSOLE_PLAYSTATION:
|
||||
return &rc_memory_regions_playstation;
|
||||
|
||||
case RC_CONSOLE_POKEMON_MINI:
|
||||
return &rc_memory_regions_pokemini;
|
||||
|
||||
case RC_CONSOLE_SATURN:
|
||||
return &rc_memory_regions_saturn;
|
||||
|
||||
case RC_CONSOLE_SEGA_CD:
|
||||
return &rc_memory_regions_segacd;
|
||||
|
||||
case RC_CONSOLE_SG1000:
|
||||
return &rc_memory_regions_sg1000;
|
||||
|
||||
case RC_CONSOLE_SUPER_CASSETTEVISION:
|
||||
return &rc_memory_regions_scv;
|
||||
|
||||
case RC_CONSOLE_SUPER_NINTENDO:
|
||||
return &rc_memory_regions_snes;
|
||||
|
||||
case RC_CONSOLE_WONDERSWAN:
|
||||
return &rc_memory_regions_wonderswan;
|
||||
|
||||
case RC_CONSOLE_VECTREX:
|
||||
return &rc_memory_regions_vectrex;
|
||||
|
||||
case RC_CONSOLE_VIRTUAL_BOY:
|
||||
return &rc_memory_regions_virtualboy;
|
||||
|
||||
default:
|
||||
return &rc_memory_regions_none;
|
||||
}
|
||||
}
|
41
deps/rcheevos/src/rcheevos/expression.c
vendored
41
deps/rcheevos/src/rcheevos/expression.c
vendored
@ -1,41 +0,0 @@
|
||||
#include "internal.h"
|
||||
|
||||
rc_expression_t* rc_parse_expression(const char** memaddr, rc_parse_state_t* parse) {
|
||||
rc_expression_t* self;
|
||||
rc_term_t** next;
|
||||
|
||||
self = RC_ALLOC(rc_expression_t, parse);
|
||||
next = &self->terms;
|
||||
|
||||
for (;;) {
|
||||
*next = rc_parse_term(memaddr, 0, parse);
|
||||
|
||||
if (parse->offset < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
next = &(*next)->next;
|
||||
|
||||
if (**memaddr != '_') {
|
||||
break;
|
||||
}
|
||||
|
||||
(*memaddr)++;
|
||||
}
|
||||
|
||||
*next = 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
int rc_evaluate_expression(rc_expression_t* self, rc_eval_state_t* eval_state) {
|
||||
rc_term_t* term;
|
||||
int value;
|
||||
|
||||
value = 0;
|
||||
|
||||
for (term = self->terms; term != 0; term = term->next) {
|
||||
value += rc_evaluate_term(term, eval_state);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
8
deps/rcheevos/src/rcheevos/format.c
vendored
8
deps/rcheevos/src/rcheevos/format.c
vendored
@ -1,5 +1,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -11,7 +13,7 @@ int rc_parse_format(const char* format_str) {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'T':
|
||||
if (!strcmp(format_str, "IME")) {
|
||||
return RC_FORMAT_FRAMES;
|
||||
@ -21,7 +23,7 @@ int rc_parse_format(const char* format_str) {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'S':
|
||||
if (!strcmp(format_str, "ECS")) {
|
||||
return RC_FORMAT_SECONDS;
|
||||
@ -34,7 +36,7 @@ int rc_parse_format(const char* format_str) {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'M':
|
||||
if (!strcmp(format_str, "ILLISECS")) {
|
||||
return RC_FORMAT_CENTISECS;
|
||||
|
15
deps/rcheevos/src/rcheevos/internal.h
vendored
15
deps/rcheevos/src/rcheevos/internal.h
vendored
@ -6,7 +6,6 @@
|
||||
#define RC_ALLOW_ALIGN(T) struct __align_ ## T { char ch; T t; };
|
||||
RC_ALLOW_ALIGN(rc_condition_t)
|
||||
RC_ALLOW_ALIGN(rc_condset_t)
|
||||
RC_ALLOW_ALIGN(rc_expression_t)
|
||||
RC_ALLOW_ALIGN(rc_lboard_t)
|
||||
RC_ALLOW_ALIGN(rc_memref_value_t)
|
||||
RC_ALLOW_ALIGN(rc_operand_t)
|
||||
@ -15,7 +14,6 @@ RC_ALLOW_ALIGN(rc_richpresence_display_t)
|
||||
RC_ALLOW_ALIGN(rc_richpresence_display_part_t)
|
||||
RC_ALLOW_ALIGN(rc_richpresence_lookup_t)
|
||||
RC_ALLOW_ALIGN(rc_richpresence_lookup_item_t)
|
||||
RC_ALLOW_ALIGN(rc_term_t)
|
||||
RC_ALLOW_ALIGN(rc_trigger_t)
|
||||
RC_ALLOW_ALIGN(rc_value_t)
|
||||
RC_ALLOW_ALIGN(char)
|
||||
@ -36,8 +34,6 @@ typedef struct {
|
||||
rc_condition_t condition;
|
||||
rc_condset_t condset;
|
||||
rc_trigger_t trigger;
|
||||
rc_term_t term;
|
||||
rc_expression_t expression;
|
||||
rc_lboard_t lboard;
|
||||
rc_memref_value_t memref_value;
|
||||
rc_richpresence_t richpresence;
|
||||
@ -61,6 +57,8 @@ typedef struct {
|
||||
unsigned measured_value; /* Measured */
|
||||
char was_reset; /* ResetIf triggered */
|
||||
char has_hits; /* one of more hit counts is non-zero */
|
||||
char primed; /* true if all non-Trigger conditions are true */
|
||||
char measured_from_hits; /* true if the measured_value came from a condition's hit count */
|
||||
}
|
||||
rc_eval_state_t;
|
||||
|
||||
@ -86,7 +84,7 @@ void rc_destroy_parse_state(rc_parse_state_t* parse);
|
||||
void* rc_alloc(void* pointer, int* offset, int size, int alignment, rc_scratch_t* scratch);
|
||||
char* rc_alloc_str(rc_parse_state_t* parse, const char* text, int length);
|
||||
|
||||
rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect);
|
||||
rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_indirect);
|
||||
void rc_update_memref_values(rc_memref_value_t* memref, rc_peek_t peek, void* ud);
|
||||
void rc_update_memref_value(rc_memref_value_t* memref, rc_peek_t peek, void* ud);
|
||||
rc_memref_value_t* rc_get_indirect_memref(rc_memref_value_t* memref, rc_eval_state_t* eval_state);
|
||||
@ -99,16 +97,11 @@ void rc_reset_condset(rc_condset_t* self);
|
||||
|
||||
rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse, int is_indirect);
|
||||
int rc_test_condition(rc_condition_t* self, rc_eval_state_t* eval_state);
|
||||
int rc_evaluate_condition_value(rc_condition_t* self, rc_eval_state_t* eval_state);
|
||||
|
||||
int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse);
|
||||
unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state);
|
||||
|
||||
rc_term_t* rc_parse_term(const char** memaddr, int is_indirect, rc_parse_state_t* parse);
|
||||
int rc_evaluate_term(rc_term_t* self, rc_eval_state_t* eval_state);
|
||||
|
||||
rc_expression_t* rc_parse_expression(const char** memaddr, rc_parse_state_t* parse);
|
||||
int rc_evaluate_expression(rc_expression_t* self, rc_eval_state_t* eval_state);
|
||||
|
||||
void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse);
|
||||
|
||||
void rc_parse_lboard_internal(rc_lboard_t* self, const char* memaddr, rc_parse_state_t* parse);
|
||||
|
115
deps/rcheevos/src/rcheevos/lboard.c
vendored
115
deps/rcheevos/src/rcheevos/lboard.c
vendored
@ -133,7 +133,7 @@ void rc_parse_lboard_internal(rc_lboard_t* self, const char* memaddr, rc_parse_s
|
||||
return;
|
||||
}
|
||||
|
||||
self->started = self->submitted = 0;
|
||||
self->state = RC_LBOARD_STATE_WAITING;
|
||||
}
|
||||
|
||||
int rc_lboard_size(const char* memaddr) {
|
||||
@ -164,82 +164,89 @@ rc_lboard_t* rc_parse_lboard(void* buffer, const char* memaddr, lua_State* L, in
|
||||
|
||||
int rc_evaluate_lboard(rc_lboard_t* self, int* value, rc_peek_t peek, void* peek_ud, lua_State* L) {
|
||||
int start_ok, cancel_ok, submit_ok;
|
||||
int action = -1;
|
||||
|
||||
rc_update_memref_values(self->memrefs, peek, peek_ud);
|
||||
|
||||
/* ASSERT: these are always tested once every frame, to ensure delta variables work properly */
|
||||
if (self->state == RC_LBOARD_STATE_INACTIVE)
|
||||
return RC_LBOARD_STATE_INACTIVE;
|
||||
|
||||
/* these are always tested once every frame, to ensure hit counts work properly */
|
||||
start_ok = rc_test_trigger(&self->start, peek, peek_ud, L);
|
||||
cancel_ok = rc_test_trigger(&self->cancel, peek, peek_ud, L);
|
||||
submit_ok = rc_test_trigger(&self->submit, peek, peek_ud, L);
|
||||
|
||||
if (self->submitted) {
|
||||
/* if we've already submitted or canceled the leaderboard, don't reactivate it until it becomes inactive. */
|
||||
if (!start_ok) {
|
||||
self->submitted = 0;
|
||||
}
|
||||
}
|
||||
else if (!self->started) {
|
||||
/* leaderboard is not active, if the start condition is true, activate it */
|
||||
if (start_ok && !cancel_ok) {
|
||||
if (submit_ok) {
|
||||
/* start and submit both true in the same frame, just submit without announcing the leaderboard is available */
|
||||
action = RC_LBOARD_TRIGGERED;
|
||||
/* prevent multiple submissions/notifications */
|
||||
self->submitted = 1;
|
||||
switch (self->state)
|
||||
{
|
||||
case RC_LBOARD_STATE_WAITING:
|
||||
case RC_LBOARD_STATE_TRIGGERED:
|
||||
case RC_LBOARD_STATE_CANCELED:
|
||||
/* don't activate/reactivate until the start condition becomes false */
|
||||
if (start_ok) {
|
||||
*value = 0;
|
||||
return RC_LBOARD_STATE_INACTIVE; /* just return inactive for all of these */
|
||||
}
|
||||
else if (self->start.requirement != 0 || self->start.alternative != 0) {
|
||||
self->started = 1;
|
||||
action = RC_LBOARD_STARTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* leaderboard is active */
|
||||
if (cancel_ok) {
|
||||
/* cancel condition is true, deactivate the leaderboard */
|
||||
self->started = 0;
|
||||
action = RC_LBOARD_CANCELED;
|
||||
/* prevent multiple cancel notifications */
|
||||
self->submitted = 1;
|
||||
}
|
||||
else if (submit_ok) {
|
||||
/* submit condition is true, submit the current value */
|
||||
self->started = 0;
|
||||
action = RC_LBOARD_TRIGGERED;
|
||||
self->submitted = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == -1) {
|
||||
action = self->started ? RC_LBOARD_ACTIVE : RC_LBOARD_INACTIVE;
|
||||
/* start condition is false, allow the leaderboard to start on future frames */
|
||||
self->state = RC_LBOARD_STATE_ACTIVE;
|
||||
break;
|
||||
|
||||
case RC_LBOARD_STATE_ACTIVE:
|
||||
/* leaderboard attempt is not in progress. if the start condition is true and the cancel condition is not, start the attempt */
|
||||
if (start_ok && !cancel_ok) {
|
||||
if (submit_ok) {
|
||||
/* start and submit are both true in the same frame, just submit without announcing the leaderboard is available */
|
||||
self->state = RC_LBOARD_STATE_TRIGGERED;
|
||||
}
|
||||
else if (self->start.requirement == 0 && self->start.alternative == 0) {
|
||||
/* start condition is empty - this leaderboard is submit-only with no measured progress */
|
||||
}
|
||||
else {
|
||||
/* start the leaderboard attempt */
|
||||
self->state = RC_LBOARD_STATE_STARTED;
|
||||
|
||||
/* reset any hit counts in the value */
|
||||
if (self->value.conditions)
|
||||
rc_reset_condset(self->value.conditions);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_LBOARD_STATE_STARTED:
|
||||
/* leaderboard attempt in progress */
|
||||
if (cancel_ok) {
|
||||
/* cancel condition is true, abort the attempt */
|
||||
self->state = RC_LBOARD_STATE_CANCELED;
|
||||
}
|
||||
else if (submit_ok) {
|
||||
/* submit condition is true, submit the current value */
|
||||
self->state = RC_LBOARD_STATE_TRIGGERED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Calculate the value */
|
||||
switch (action) {
|
||||
case RC_LBOARD_STARTED:
|
||||
if (self->value.conditions)
|
||||
rc_reset_condset(self->value.conditions);
|
||||
/* fall through */
|
||||
case RC_LBOARD_ACTIVE:
|
||||
*value = rc_evaluate_value(self->progress != 0 ? self->progress : &self->value, peek, peek_ud, L);
|
||||
break;
|
||||
switch (self->state) {
|
||||
case RC_LBOARD_STATE_STARTED:
|
||||
if (self->progress) {
|
||||
*value = rc_evaluate_value(self->progress, peek, peek_ud, L);
|
||||
break;
|
||||
}
|
||||
/* fallthrough to RC_LBOARD_STATE_TRIGGERED */
|
||||
|
||||
case RC_LBOARD_TRIGGERED:
|
||||
case RC_LBOARD_STATE_TRIGGERED:
|
||||
*value = rc_evaluate_value(&self->value, peek, peek_ud, L);
|
||||
break;
|
||||
|
||||
case RC_LBOARD_INACTIVE:
|
||||
case RC_LBOARD_CANCELED:
|
||||
default:
|
||||
*value = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return action;
|
||||
return self->state;
|
||||
}
|
||||
|
||||
void rc_reset_lboard(rc_lboard_t* self) {
|
||||
self->started = self->submitted = 0;
|
||||
self->state = RC_LBOARD_STATE_WAITING;
|
||||
|
||||
rc_reset_trigger(&self->start);
|
||||
rc_reset_trigger(&self->submit);
|
||||
|
61
deps/rcheevos/src/rcheevos/memref.c
vendored
61
deps/rcheevos/src/rcheevos/memref.c
vendored
@ -5,7 +5,7 @@
|
||||
|
||||
#define MEMREF_PLACEHOLDER_ADDRESS 0xFFFFFFFF
|
||||
|
||||
static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) {
|
||||
static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) {
|
||||
rc_memref_t* memref;
|
||||
int i;
|
||||
|
||||
@ -20,7 +20,7 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa
|
||||
/* have to track unique address/size/bcd combinations - use scratch.memref for sizing mode */
|
||||
for (i = 0; i < parse->scratch.memref_count; ++i) {
|
||||
memref = &parse->scratch.memref[i];
|
||||
if (memref->address == address && memref->size == size && memref->is_bcd == is_bcd) {
|
||||
if (memref->address == address && memref->size == size) {
|
||||
return &parse->scratch.obj.memref_value;
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,6 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa
|
||||
memref = &parse->scratch.memref[parse->scratch.memref_count++];
|
||||
memref->address = address;
|
||||
memref->size = size;
|
||||
memref->is_bcd = is_bcd;
|
||||
memref->is_indirect = is_indirect;
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa
|
||||
return RC_ALLOC(rc_memref_value_t, parse);
|
||||
}
|
||||
|
||||
static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) {
|
||||
static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) {
|
||||
rc_memref_value_t** next_memref_value;
|
||||
rc_memref_value_t* memref_value;
|
||||
rc_memref_value_t* indirect_memref_value;
|
||||
@ -75,8 +74,8 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t*
|
||||
next_memref_value = parse->first_memref;
|
||||
while (*next_memref_value) {
|
||||
memref_value = *next_memref_value;
|
||||
if (!memref_value->memref.is_indirect && memref_value->memref.address == address &&
|
||||
memref_value->memref.size == size && memref_value->memref.is_bcd == is_bcd) {
|
||||
if (!memref_value->memref.is_indirect && memref_value->memref.address == address &&
|
||||
memref_value->memref.size == size) {
|
||||
return memref_value;
|
||||
}
|
||||
|
||||
@ -96,7 +95,6 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t*
|
||||
memref_value = RC_ALLOC(rc_memref_value_t, parse);
|
||||
memref_value->memref.address = address;
|
||||
memref_value->memref.size = size;
|
||||
memref_value->memref.is_bcd = is_bcd;
|
||||
memref_value->memref.is_indirect = is_indirect;
|
||||
memref_value->value = 0;
|
||||
memref_value->previous = 0;
|
||||
@ -110,7 +108,6 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t*
|
||||
indirect_memref_value = RC_ALLOC(rc_memref_value_t, parse);
|
||||
indirect_memref_value->memref.address = MEMREF_PLACEHOLDER_ADDRESS;
|
||||
indirect_memref_value->memref.size = size;
|
||||
indirect_memref_value->memref.is_bcd = is_bcd;
|
||||
indirect_memref_value->memref.is_indirect = 1;
|
||||
indirect_memref_value->value = 0;
|
||||
indirect_memref_value->previous = 0;
|
||||
@ -123,16 +120,19 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t*
|
||||
return memref_value;
|
||||
}
|
||||
|
||||
rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) {
|
||||
rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) {
|
||||
if (!parse->first_memref)
|
||||
return rc_alloc_memref_value_sizing_mode(parse, address, size, is_bcd, is_indirect);
|
||||
return rc_alloc_memref_value_sizing_mode(parse, address, size, is_indirect);
|
||||
|
||||
return rc_alloc_memref_value_constuct_mode(parse, address, size, is_bcd, is_indirect);
|
||||
return rc_alloc_memref_value_constuct_mode(parse, address, size, is_indirect);
|
||||
}
|
||||
|
||||
static unsigned rc_memref_get_value(rc_memref_t* self, rc_peek_t peek, void* ud) {
|
||||
unsigned value;
|
||||
|
||||
if (!peek)
|
||||
return 0;
|
||||
|
||||
switch (self->size)
|
||||
{
|
||||
case RC_MEMSIZE_BIT_0:
|
||||
@ -177,56 +177,19 @@ static unsigned rc_memref_get_value(rc_memref_t* self, rc_peek_t peek, void* ud)
|
||||
|
||||
case RC_MEMSIZE_8_BITS:
|
||||
value = peek(self->address, 1, ud);
|
||||
|
||||
if (self->is_bcd) {
|
||||
value = ((value >> 4) & 0x0f) * 10 + (value & 0x0f);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_16_BITS:
|
||||
value = peek(self->address, 2, ud);
|
||||
|
||||
if (self->is_bcd) {
|
||||
value = ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value >> 0) & 0x0f) * 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_24_BITS:
|
||||
/* peek 4 bytes - don't expect the caller to understand 24-bit numbers */
|
||||
value = peek(self->address, 4, ud);
|
||||
|
||||
if (self->is_bcd) {
|
||||
value = ((value >> 20) & 0x0f) * 100000
|
||||
+ ((value >> 16) & 0x0f) * 10000
|
||||
+ ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value >> 0) & 0x0f) * 1;
|
||||
} else {
|
||||
value &= 0x00FFFFFF;
|
||||
}
|
||||
|
||||
value = peek(self->address, 4, ud) & 0x00FFFFFF;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_32_BITS:
|
||||
value = peek(self->address, 4, ud);
|
||||
|
||||
if (self->is_bcd) {
|
||||
value = ((value >> 28) & 0x0f) * 10000000
|
||||
+ ((value >> 24) & 0x0f) * 1000000
|
||||
+ ((value >> 20) & 0x0f) * 100000
|
||||
+ ((value >> 16) & 0x0f) * 10000
|
||||
+ ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value >> 0) & 0x0f) * 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
390
deps/rcheevos/src/rcheevos/operand.c
vendored
390
deps/rcheevos/src/rcheevos/operand.c
vendored
@ -70,7 +70,6 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
const char* aux = *memaddr;
|
||||
char* end;
|
||||
unsigned long address;
|
||||
char is_bcd = 0;
|
||||
char size;
|
||||
|
||||
switch (*aux++) {
|
||||
@ -78,15 +77,18 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
self->type = RC_OPERAND_DELTA;
|
||||
break;
|
||||
|
||||
case 'b': case 'B':
|
||||
self->type = RC_OPERAND_ADDRESS;
|
||||
is_bcd = 1;
|
||||
break;
|
||||
|
||||
case 'p': case 'P':
|
||||
self->type = RC_OPERAND_PRIOR;
|
||||
break;
|
||||
|
||||
case 'b': case 'B':
|
||||
self->type = RC_OPERAND_BCD;
|
||||
break;
|
||||
|
||||
case '~':
|
||||
self->type = RC_OPERAND_INVERTED;
|
||||
break;
|
||||
|
||||
default:
|
||||
self->type = RC_OPERAND_ADDRESS;
|
||||
aux--;
|
||||
@ -104,25 +106,33 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
aux++;
|
||||
|
||||
switch (*aux++) {
|
||||
case 'm': case 'M': size = RC_MEMSIZE_BIT_0; break;
|
||||
case 'n': case 'N': size = RC_MEMSIZE_BIT_1; break;
|
||||
case 'o': case 'O': size = RC_MEMSIZE_BIT_2; break;
|
||||
case 'p': case 'P': size = RC_MEMSIZE_BIT_3; break;
|
||||
case 'q': case 'Q': size = RC_MEMSIZE_BIT_4; break;
|
||||
case 'r': case 'R': size = RC_MEMSIZE_BIT_5; break;
|
||||
case 's': case 'S': size = RC_MEMSIZE_BIT_6; break;
|
||||
case 't': case 'T': size = RC_MEMSIZE_BIT_7; break;
|
||||
case 'l': case 'L': size = RC_MEMSIZE_LOW; break;
|
||||
case 'u': case 'U': size = RC_MEMSIZE_HIGH; break;
|
||||
case 'h': case 'H': size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'w': case 'W': size = RC_MEMSIZE_24_BITS; break;
|
||||
case 'x': case 'X': size = RC_MEMSIZE_32_BITS; break;
|
||||
case 'm': case 'M': self->size = RC_MEMSIZE_BIT_0; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'n': case 'N': self->size = RC_MEMSIZE_BIT_1; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'o': case 'O': self->size = RC_MEMSIZE_BIT_2; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'p': case 'P': self->size = RC_MEMSIZE_BIT_3; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'q': case 'Q': self->size = RC_MEMSIZE_BIT_4; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'r': case 'R': self->size = RC_MEMSIZE_BIT_5; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 's': case 'S': self->size = RC_MEMSIZE_BIT_6; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 't': case 'T': self->size = RC_MEMSIZE_BIT_7; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'l': case 'L': self->size = RC_MEMSIZE_LOW; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'u': case 'U': self->size = RC_MEMSIZE_HIGH; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'k': case 'K': self->size = RC_MEMSIZE_BITCOUNT; size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'h': case 'H': self->size = size = RC_MEMSIZE_8_BITS; break;
|
||||
case 'w': case 'W': self->size = size = RC_MEMSIZE_24_BITS; break;
|
||||
case 'x': case 'X': self->size = size = RC_MEMSIZE_32_BITS; break;
|
||||
|
||||
default: /* fall through */
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
aux--;
|
||||
/* fallthrough */
|
||||
case ' ':
|
||||
size = RC_MEMSIZE_16_BITS;
|
||||
self->size = size = RC_MEMSIZE_16_BITS;
|
||||
break;
|
||||
|
||||
default:
|
||||
return RC_INVALID_MEMORY_OPERAND;
|
||||
}
|
||||
|
||||
address = strtoul(aux, &end, 16);
|
||||
@ -135,7 +145,7 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
address = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->value.memref = rc_alloc_memref_value(parse, address, size, is_bcd, is_indirect);
|
||||
self->value.memref = rc_alloc_memref_value(parse, address, size, is_indirect);
|
||||
if (parse->offset < 0)
|
||||
return parse->offset;
|
||||
|
||||
@ -143,14 +153,17 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, int is_indirect, rc_parse_state_t* parse) {
|
||||
int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse) {
|
||||
const char* aux = *memaddr;
|
||||
char* end;
|
||||
int ret;
|
||||
unsigned long value;
|
||||
int negative;
|
||||
|
||||
self->size = RC_MEMSIZE_32_BITS;
|
||||
|
||||
switch (*aux) {
|
||||
case 'h': case 'H':
|
||||
case 'h': case 'H': /* hex constant */
|
||||
if (aux[2] == 'x' || aux[2] == 'X') {
|
||||
/* H0x1234 is a typo - either H1234 or 0xH1234 was probably meant */
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
@ -171,115 +184,9 @@ static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, in
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case '0':
|
||||
if (aux[1] == 'x' || aux[1] == 'X') {
|
||||
/* fall through */
|
||||
default:
|
||||
ret = rc_parse_operand_memory(self, &aux, parse, is_indirect);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* fall through */
|
||||
case '+': case '-':
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
value = strtoul(aux, &end, 10);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
}
|
||||
|
||||
if (value > 0xffffffffU) {
|
||||
value = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case '@':
|
||||
ret = rc_parse_operand_lua(self, &aux, parse);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*memaddr = aux;
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int is_indirect, rc_parse_state_t* parse) {
|
||||
const char* aux = *memaddr;
|
||||
char* end;
|
||||
int ret;
|
||||
unsigned long value;
|
||||
long svalue;
|
||||
|
||||
switch (*aux) {
|
||||
case 'h': case 'H':
|
||||
value = strtoul(++aux, &end, 16);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
}
|
||||
|
||||
if (value > 0xffffffffU) {
|
||||
value = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case 'v': case 'V':
|
||||
svalue = strtol(++aux, &end, 10);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
}
|
||||
|
||||
if (svalue > 0xffffffffU) {
|
||||
svalue = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value.num = (unsigned)svalue;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case '0':
|
||||
if (aux[1] == 'x' || aux[1] == 'X') {
|
||||
/* fall through */
|
||||
default:
|
||||
ret = rc_parse_operand_memory(self, &aux, parse, is_indirect);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* fall through */
|
||||
case '.':
|
||||
case '+': case '-':
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
self->value.dbl = strtod(aux, &end);
|
||||
case 'f': case 'F': /* floating point constant */
|
||||
self->value.dbl = strtod(++aux, &end);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_FP_OPERAND;
|
||||
@ -292,9 +199,77 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int i
|
||||
else {
|
||||
self->type = RC_OPERAND_FP;
|
||||
}
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
|
||||
case 'v': case 'V': /* signed integer constant */
|
||||
negative = 0;
|
||||
++aux;
|
||||
|
||||
if (*aux == '-')
|
||||
{
|
||||
negative = 1;
|
||||
++aux;
|
||||
}
|
||||
else if (*aux == '+')
|
||||
{
|
||||
++aux;
|
||||
}
|
||||
|
||||
value = strtoul(aux, &end, 10);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
}
|
||||
|
||||
if (value > 0x7fffffffU) {
|
||||
value = 0x7fffffffU;
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
|
||||
if (negative)
|
||||
self->value.num = (unsigned)(-((long)value));
|
||||
else
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case '0':
|
||||
if (aux[1] == 'x' || aux[1] == 'X') {
|
||||
/* fall through */
|
||||
default:
|
||||
ret = rc_parse_operand_memory(self, &aux, parse, is_indirect);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* fall through for case '0' where not '0x' */
|
||||
case '+': case '-':
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
value = strtoul(aux, &end, 10);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_CONST_OPERAND;
|
||||
}
|
||||
|
||||
if (value > 0xffffffffU) {
|
||||
value = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
|
||||
case '@':
|
||||
ret = rc_parse_operand_lua(self, &aux, parse);
|
||||
|
||||
@ -309,15 +284,6 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int i
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse) {
|
||||
if (is_trigger) {
|
||||
return rc_parse_operand_trigger(self, memaddr, is_indirect, parse);
|
||||
}
|
||||
else {
|
||||
return rc_parse_operand_term(self, memaddr, is_indirect, parse);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RC_DISABLE_LUA
|
||||
|
||||
typedef struct {
|
||||
@ -339,6 +305,8 @@ static int rc_luapeek(lua_State* L) {
|
||||
|
||||
#endif /* RC_DISABLE_LUA */
|
||||
|
||||
static const unsigned char rc_bits_set[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
|
||||
|
||||
unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) {
|
||||
#ifndef RC_DISABLE_LUA
|
||||
rc_luapeek_t luapeek;
|
||||
@ -346,15 +314,15 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) {
|
||||
|
||||
unsigned value = 0;
|
||||
|
||||
/* step 1: read memory */
|
||||
switch (self->type) {
|
||||
case RC_OPERAND_CONST:
|
||||
value = self->value.num;
|
||||
break;
|
||||
return self->value.num;
|
||||
|
||||
case RC_OPERAND_FP:
|
||||
/* This is handled by rc_evaluate_expression. */
|
||||
/* This is handled by rc_evaluate_condition_value. */
|
||||
return 0;
|
||||
|
||||
|
||||
case RC_OPERAND_LUA:
|
||||
#ifndef RC_DISABLE_LUA
|
||||
|
||||
@ -366,7 +334,7 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) {
|
||||
luapeek.ud = eval_state->peek_userdata;
|
||||
|
||||
lua_pushlightuserdata(eval_state->L, &luapeek);
|
||||
|
||||
|
||||
if (lua_pcall(eval_state->L, 2, 1, 0) == LUA_OK) {
|
||||
if (lua_isboolean(eval_state->L, -1)) {
|
||||
value = lua_toboolean(eval_state->L, -1);
|
||||
@ -384,6 +352,8 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) {
|
||||
break;
|
||||
|
||||
case RC_OPERAND_ADDRESS:
|
||||
case RC_OPERAND_BCD:
|
||||
case RC_OPERAND_INVERTED:
|
||||
value = rc_get_indirect_memref(self->value.memref, eval_state)->value;
|
||||
break;
|
||||
|
||||
@ -396,5 +366,131 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* step 2: mask off appropriate bits */
|
||||
switch (self->size)
|
||||
{
|
||||
case RC_MEMSIZE_BIT_0:
|
||||
value = (value >> 0) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_1:
|
||||
value = (value >> 1) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_2:
|
||||
value = (value >> 2) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_3:
|
||||
value = (value >> 3) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_4:
|
||||
value = (value >> 4) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_5:
|
||||
value = (value >> 5) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_6:
|
||||
value = (value >> 6) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BIT_7:
|
||||
value = (value >> 7) & 1;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_LOW:
|
||||
value = value & 0x0f;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_HIGH:
|
||||
value = (value >> 4) & 0x0f;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_BITCOUNT:
|
||||
value = rc_bits_set[(value & 0x0F)]
|
||||
+ rc_bits_set[((value >> 4) & 0x0F)];
|
||||
break;
|
||||
}
|
||||
|
||||
/* step 3: apply logic */
|
||||
switch (self->type)
|
||||
{
|
||||
case RC_OPERAND_BCD:
|
||||
switch (self->size)
|
||||
{
|
||||
case RC_MEMSIZE_8_BITS:
|
||||
value = ((value >> 4) & 0x0f) * 10
|
||||
+ ((value ) & 0x0f);
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_16_BITS:
|
||||
value = ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value ) & 0x0f);
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_24_BITS:
|
||||
value = ((value >> 20) & 0x0f) * 100000
|
||||
+ ((value >> 16) & 0x0f) * 10000
|
||||
+ ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value ) & 0x0f);
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_32_BITS:
|
||||
value = ((value >> 28) & 0x0f) * 10000000
|
||||
+ ((value >> 24) & 0x0f) * 1000000
|
||||
+ ((value >> 20) & 0x0f) * 100000
|
||||
+ ((value >> 16) & 0x0f) * 10000
|
||||
+ ((value >> 12) & 0x0f) * 1000
|
||||
+ ((value >> 8) & 0x0f) * 100
|
||||
+ ((value >> 4) & 0x0f) * 10
|
||||
+ ((value ) & 0x0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_OPERAND_INVERTED:
|
||||
switch (self->size)
|
||||
{
|
||||
case RC_MEMSIZE_LOW:
|
||||
case RC_MEMSIZE_HIGH:
|
||||
value ^= 0x0f;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_8_BITS:
|
||||
value ^= 0xff;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_16_BITS:
|
||||
value ^= 0xffff;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_24_BITS:
|
||||
value ^= 0xffffff;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_32_BITS:
|
||||
value ^= 0xffffffff;
|
||||
break;
|
||||
|
||||
default:
|
||||
value ^= 0x01;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
58
deps/rcheevos/src/rcheevos/richpresence.c
vendored
58
deps/rcheevos/src/rcheevos/richpresence.c
vendored
@ -1,9 +1,8 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* special formats only used by rc_richpresence_display_part_t.display_type. must not overlap other RC_FORMAT values */
|
||||
enum {
|
||||
@ -116,6 +115,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c
|
||||
/* just calculating size, can't confirm lookup exists */
|
||||
part = RC_ALLOC(rc_richpresence_display_part_t, parse);
|
||||
|
||||
in = line;
|
||||
line = ++ptr;
|
||||
while (ptr < endline && *ptr != ')')
|
||||
++ptr;
|
||||
@ -124,6 +124,10 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c
|
||||
if (parse->offset < 0)
|
||||
return 0;
|
||||
++ptr;
|
||||
} else {
|
||||
/* no closing parenthesis - allocate space for the invalid string */
|
||||
--in; /* already skipped over @ */
|
||||
rc_alloc_str(parse, line, (int)(ptr - in));
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -139,6 +143,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c
|
||||
part->first_lookup_item = lookup->first_item;
|
||||
part->display_type = lookup->format;
|
||||
|
||||
in = line;
|
||||
line = ++ptr;
|
||||
while (ptr < endline && *ptr != ')')
|
||||
++ptr;
|
||||
@ -149,6 +154,12 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c
|
||||
return 0;
|
||||
++ptr;
|
||||
}
|
||||
else {
|
||||
/* non-terminated macro, dump the macro and the remaining portion of the line */
|
||||
--in; /* already skipped over @ */
|
||||
part->display_type = RC_FORMAT_STRING;
|
||||
part->text = rc_alloc_str(parse, in, (int)(ptr - in));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -170,7 +181,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c
|
||||
|
||||
/* assert: the allocated string is going to be smaller than the memory used for the parameter of the macro */
|
||||
part->display_type = RC_FORMAT_UNKNOWN_MACRO;
|
||||
part->text = rc_alloc_str(parse, line, ptr - line);
|
||||
part->text = rc_alloc_str(parse, line, (int)(ptr - line));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,7 +205,7 @@ static const char* rc_parse_richpresence_lookup(rc_richpresence_lookup_t* lookup
|
||||
const char* defaultlabel = 0;
|
||||
char* endptr = 0;
|
||||
unsigned key;
|
||||
int chars;
|
||||
unsigned chars;
|
||||
|
||||
next = &lookup->first_item;
|
||||
|
||||
@ -372,7 +383,7 @@ int rc_richpresence_size(const char* script) {
|
||||
rc_richpresence_t* self;
|
||||
rc_parse_state_t parse;
|
||||
rc_init_parse_state(&parse, 0, 0, 0);
|
||||
|
||||
|
||||
self = RC_ALLOC(rc_richpresence_t, &parse);
|
||||
rc_parse_richpresence_internal(self, script, &parse);
|
||||
|
||||
@ -389,7 +400,7 @@ rc_richpresence_t* rc_parse_richpresence(void* buffer, const char* script, lua_S
|
||||
rc_init_parse_state_memrefs(&parse, &self->memrefs);
|
||||
|
||||
rc_parse_richpresence_internal(self, script, &parse);
|
||||
|
||||
|
||||
rc_destroy_parse_state(&parse);
|
||||
return parse.offset >= 0 ? self : 0;
|
||||
}
|
||||
@ -398,8 +409,10 @@ int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsi
|
||||
rc_richpresence_display_t* display;
|
||||
rc_richpresence_display_part_t* part;
|
||||
rc_richpresence_lookup_item_t* item;
|
||||
char tmp[256];
|
||||
char* ptr;
|
||||
int chars;
|
||||
const char* text;
|
||||
size_t chars;
|
||||
unsigned value;
|
||||
|
||||
rc_update_memref_values(richpresence->memrefs, peek, peek_ud);
|
||||
@ -412,37 +425,52 @@ int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsi
|
||||
while (part) {
|
||||
switch (part->display_type) {
|
||||
case RC_FORMAT_STRING:
|
||||
chars = snprintf(ptr, buffersize, "%s", part->text);
|
||||
text = part->text;
|
||||
chars = strlen(text);
|
||||
break;
|
||||
|
||||
case RC_FORMAT_LOOKUP:
|
||||
value = rc_evaluate_value(&part->value, peek, peek_ud, L);
|
||||
item = part->first_lookup_item;
|
||||
if (!item) {
|
||||
text = "";
|
||||
chars = 0;
|
||||
} else {
|
||||
while (item->next_item && item->value != value)
|
||||
item = item->next_item;
|
||||
|
||||
chars = snprintf(ptr, buffersize, "%s", item->label);
|
||||
text = item->label;
|
||||
chars = strlen(text);
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_FORMAT_UNKNOWN_MACRO:
|
||||
chars = snprintf(ptr, buffersize, "[Unknown macro]%s", part->text);
|
||||
chars = snprintf(tmp, sizeof(tmp), "[Unknown macro]%s", part->text);
|
||||
text = tmp;
|
||||
break;
|
||||
|
||||
default:
|
||||
value = rc_evaluate_value(&part->value, peek, peek_ud, L);
|
||||
chars = rc_format_value(ptr, buffersize, value, part->display_type);
|
||||
chars = rc_format_value(tmp, sizeof(tmp), value, part->display_type);
|
||||
text = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
if (chars > 0) {
|
||||
ptr += chars;
|
||||
buffersize -= chars;
|
||||
if (chars > 0 && buffersize > 0) {
|
||||
if ((unsigned)chars >= buffersize) {
|
||||
/* prevent write past end of buffer */
|
||||
memcpy(ptr, text, buffersize - 1);
|
||||
ptr[buffersize - 1] = '\0';
|
||||
buffersize = 0;
|
||||
}
|
||||
else {
|
||||
memcpy(ptr, text, chars);
|
||||
ptr[chars] = '\0';
|
||||
buffersize -= (unsigned)chars;
|
||||
}
|
||||
}
|
||||
|
||||
ptr += chars;
|
||||
part = part->next;
|
||||
}
|
||||
|
||||
|
589
deps/rcheevos/src/rcheevos/runtime.c
vendored
Normal file
589
deps/rcheevos/src/rcheevos/runtime.c
vendored
Normal file
@ -0,0 +1,589 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include "../rhash/md5.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE 256
|
||||
|
||||
void rc_runtime_init(rc_runtime_t* self) {
|
||||
memset(self, 0, sizeof(rc_runtime_t));
|
||||
self->next_memref = &self->memrefs;
|
||||
}
|
||||
|
||||
void rc_runtime_destroy(rc_runtime_t* self) {
|
||||
unsigned i;
|
||||
|
||||
if (self->triggers) {
|
||||
for (i = 0; i < self->trigger_count; ++i)
|
||||
free(self->triggers[i].buffer);
|
||||
|
||||
free(self->triggers);
|
||||
self->triggers = NULL;
|
||||
|
||||
self->trigger_count = self->trigger_capacity = 0;
|
||||
}
|
||||
|
||||
if (self->lboards) {
|
||||
free(self->lboards);
|
||||
self->lboards = NULL;
|
||||
|
||||
self->lboard_count = self->lboard_capacity = 0;
|
||||
}
|
||||
|
||||
while (self->richpresence) {
|
||||
rc_runtime_richpresence_t* previous = self->richpresence->previous;
|
||||
|
||||
free(self->richpresence->buffer);
|
||||
free(self->richpresence);
|
||||
self->richpresence = previous;
|
||||
}
|
||||
|
||||
if (self->richpresence_display_buffer) {
|
||||
free(self->richpresence_display_buffer);
|
||||
self->richpresence_display_buffer = NULL;
|
||||
}
|
||||
|
||||
self->next_memref = 0;
|
||||
self->memrefs = 0;
|
||||
}
|
||||
|
||||
static void rc_runtime_checksum(const char* memaddr, unsigned char* md5) {
|
||||
md5_state_t state;
|
||||
md5_init(&state);
|
||||
md5_append(&state, (unsigned char*)memaddr, (int)strlen(memaddr));
|
||||
md5_finish(&state, md5);
|
||||
}
|
||||
|
||||
static void rc_runtime_deactivate_trigger_by_index(rc_runtime_t* self, unsigned index) {
|
||||
if (self->triggers[index].owns_memrefs) {
|
||||
/* if the trigger has one or more memrefs in its buffer, we can't free the buffer.
|
||||
* just null out the trigger so the runtime processor will skip it
|
||||
*/
|
||||
rc_reset_trigger(self->triggers[index].trigger);
|
||||
self->triggers[index].trigger = NULL;
|
||||
}
|
||||
else {
|
||||
/* trigger doesn't own any memrefs, go ahead and free it, then replace it with the last trigger */
|
||||
free(self->triggers[index].buffer);
|
||||
|
||||
if (--self->trigger_count > index)
|
||||
memcpy(&self->triggers[index], &self->triggers[self->trigger_count], sizeof(rc_runtime_trigger_t));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_runtime_deactivate_achievement(rc_runtime_t* self, unsigned id) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
if (self->triggers[i].id == id && self->triggers[i].trigger != NULL)
|
||||
rc_runtime_deactivate_trigger_by_index(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
int rc_runtime_activate_achievement(rc_runtime_t* self, unsigned id, const char* memaddr, lua_State* L, int funcs_idx) {
|
||||
void* trigger_buffer;
|
||||
rc_trigger_t* trigger;
|
||||
rc_parse_state_t parse;
|
||||
unsigned char md5[16];
|
||||
int size;
|
||||
char owns_memref;
|
||||
unsigned i;
|
||||
|
||||
if (memaddr == NULL)
|
||||
return RC_INVALID_MEMORY_OPERAND;
|
||||
|
||||
rc_runtime_checksum(memaddr, md5);
|
||||
|
||||
/* check to see if the id is already registered with an active trigger */
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
if (self->triggers[i].id == id && self->triggers[i].trigger != NULL) {
|
||||
if (memcmp(self->triggers[i].md5, md5, 16) == 0) {
|
||||
/* if the checksum hasn't changed, we can reuse the existing item */
|
||||
rc_reset_trigger(self->triggers[i].trigger);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* checksum has changed, deactivate the the item */
|
||||
rc_runtime_deactivate_trigger_by_index(self, i);
|
||||
|
||||
/* deactivate may reorder the list so we should continue from the current index. however, we
|
||||
* assume that only one trigger is active per id, so having found that, just stop scanning.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check to see if a disabled trigger for the specific id matches the trigger being registered */
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
if (self->triggers[i].id == id && memcmp(self->triggers[i].md5, md5, 16) == 0) {
|
||||
/* retrieve the trigger pointer from the buffer */
|
||||
size = 0;
|
||||
trigger = (rc_trigger_t*)rc_alloc(self->triggers[i].buffer, &size, sizeof(rc_trigger_t), RC_ALIGNOF(rc_trigger_t), 0);
|
||||
self->triggers[i].trigger = trigger;
|
||||
|
||||
rc_reset_trigger(trigger);
|
||||
return RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* item has not been previously registered, determine how much space we need for it, and allocate it */
|
||||
size = rc_trigger_size(memaddr);
|
||||
if (size < 0)
|
||||
return size;
|
||||
|
||||
trigger_buffer = malloc(size);
|
||||
if (!trigger_buffer)
|
||||
return RC_OUT_OF_MEMORY;
|
||||
|
||||
/* populate the item, using the communal memrefs pool */
|
||||
rc_init_parse_state(&parse, trigger_buffer, L, funcs_idx);
|
||||
parse.first_memref = &self->memrefs;
|
||||
trigger = RC_ALLOC(rc_trigger_t, &parse);
|
||||
rc_parse_trigger_internal(trigger, &memaddr, &parse);
|
||||
rc_destroy_parse_state(&parse);
|
||||
|
||||
if (parse.offset < 0) {
|
||||
free(trigger_buffer);
|
||||
*self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */
|
||||
return parse.offset;
|
||||
}
|
||||
|
||||
/* if at least one memref was allocated within the trigger, we can't free the buffer when the trigger is deactivated */
|
||||
owns_memref = (*self->next_memref != NULL);
|
||||
if (owns_memref) {
|
||||
/* advance through the new memrefs so we're ready for the next allocation */
|
||||
do {
|
||||
self->next_memref = &(*self->next_memref)->next;
|
||||
} while (*self->next_memref != NULL);
|
||||
}
|
||||
|
||||
/* grow the trigger buffer if necessary */
|
||||
if (self->trigger_count == self->trigger_capacity) {
|
||||
self->trigger_capacity += 32;
|
||||
if (!self->triggers)
|
||||
self->triggers = (rc_runtime_trigger_t*)malloc(self->trigger_capacity * sizeof(rc_runtime_trigger_t));
|
||||
else
|
||||
self->triggers = (rc_runtime_trigger_t*)realloc(self->triggers, self->trigger_capacity * sizeof(rc_runtime_trigger_t));
|
||||
}
|
||||
|
||||
/* assign the new trigger */
|
||||
self->triggers[self->trigger_count].id = id;
|
||||
self->triggers[self->trigger_count].trigger = trigger;
|
||||
self->triggers[self->trigger_count].buffer = trigger_buffer;
|
||||
memcpy(self->triggers[self->trigger_count].md5, md5, 16);
|
||||
self->triggers[self->trigger_count].owns_memrefs = owns_memref;
|
||||
++self->trigger_count;
|
||||
|
||||
/* reset it, and return it */
|
||||
trigger->memrefs = NULL;
|
||||
rc_reset_trigger(trigger);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* self, unsigned id)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
if (self->triggers[i].id == id && self->triggers[i].trigger != NULL)
|
||||
return self->triggers[i].trigger;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void rc_runtime_deactivate_lboard_by_index(rc_runtime_t* self, unsigned index) {
|
||||
if (self->lboards[index].owns_memrefs) {
|
||||
/* if the lboard has one or more memrefs in its buffer, we can't free the buffer.
|
||||
* just null out the lboard so the runtime processor will skip it
|
||||
*/
|
||||
rc_reset_lboard(self->lboards[index].lboard);
|
||||
self->lboards[index].lboard = NULL;
|
||||
}
|
||||
else {
|
||||
/* lboard doesn't own any memrefs, go ahead and free it, then replace it with the last lboard */
|
||||
free(self->lboards[index].buffer);
|
||||
|
||||
if (--self->lboard_count > index)
|
||||
memcpy(&self->lboards[index], &self->lboards[self->lboard_count], sizeof(rc_runtime_lboard_t));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_runtime_deactivate_lboard(rc_runtime_t* self, unsigned id) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
if (self->lboards[i].id == id && self->lboards[i].lboard != NULL)
|
||||
rc_runtime_deactivate_lboard_by_index(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
int rc_runtime_activate_lboard(rc_runtime_t* self, unsigned id, const char* memaddr, lua_State* L, int funcs_idx) {
|
||||
void* lboard_buffer;
|
||||
unsigned char md5[16];
|
||||
rc_lboard_t* lboard;
|
||||
rc_parse_state_t parse;
|
||||
int size;
|
||||
char owns_memref;
|
||||
unsigned i;
|
||||
|
||||
if (memaddr == 0)
|
||||
return RC_INVALID_MEMORY_OPERAND;
|
||||
|
||||
rc_runtime_checksum(memaddr, md5);
|
||||
|
||||
/* check to see if the id is already registered with an active lboard */
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
if (self->lboards[i].id == id && self->lboards[i].lboard != NULL) {
|
||||
if (memcmp(self->lboards[i].md5, md5, 16) == 0) {
|
||||
/* if the checksum hasn't changed, we can reuse the existing item */
|
||||
rc_reset_lboard(self->lboards[i].lboard);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* checksum has changed, deactivate the the item */
|
||||
rc_runtime_deactivate_lboard_by_index(self, i);
|
||||
|
||||
/* deactivate may reorder the list so we should continue from the current index. however, we
|
||||
* assume that only one trigger is active per id, so having found that, just stop scanning.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check to see if a disabled lboard for the specific id matches the lboard being registered */
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
if (self->lboards[i].id == id && memcmp(self->lboards[i].md5, md5, 16) == 0) {
|
||||
/* retrieve the lboard pointer from the buffer */
|
||||
size = 0;
|
||||
lboard = (rc_lboard_t*)rc_alloc(self->lboards[i].buffer, &size, sizeof(rc_lboard_t), RC_ALIGNOF(rc_lboard_t), 0);
|
||||
self->lboards[i].lboard = lboard;
|
||||
|
||||
rc_reset_lboard(lboard);
|
||||
return RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* item has not been previously registered, determine how much space we need for it, and allocate it */
|
||||
size = rc_lboard_size(memaddr);
|
||||
if (size < 0)
|
||||
return size;
|
||||
|
||||
lboard_buffer = malloc(size);
|
||||
if (!lboard_buffer)
|
||||
return RC_OUT_OF_MEMORY;
|
||||
|
||||
/* populate the item, using the communal memrefs pool */
|
||||
rc_init_parse_state(&parse, lboard_buffer, L, funcs_idx);
|
||||
lboard = RC_ALLOC(rc_lboard_t, &parse);
|
||||
parse.first_memref = &self->memrefs;
|
||||
rc_parse_lboard_internal(lboard, memaddr, &parse);
|
||||
rc_destroy_parse_state(&parse);
|
||||
|
||||
if (parse.offset < 0) {
|
||||
free(lboard_buffer);
|
||||
*self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */
|
||||
return parse.offset;
|
||||
}
|
||||
|
||||
/* if at least one memref was allocated within the trigger, we can't free the buffer when the trigger is deactivated */
|
||||
owns_memref = (*self->next_memref != NULL);
|
||||
if (owns_memref) {
|
||||
/* advance through the new memrefs so we're ready for the next allocation */
|
||||
do {
|
||||
self->next_memref = &(*self->next_memref)->next;
|
||||
} while (*self->next_memref != NULL);
|
||||
}
|
||||
|
||||
/* grow the lboard buffer if necessary */
|
||||
if (self->lboard_count == self->lboard_capacity) {
|
||||
self->lboard_capacity += 16;
|
||||
if (!self->lboards)
|
||||
self->lboards = (rc_runtime_lboard_t*)malloc(self->lboard_capacity * sizeof(rc_runtime_lboard_t));
|
||||
else
|
||||
self->lboards = (rc_runtime_lboard_t*)realloc(self->lboards, self->lboard_capacity * sizeof(rc_runtime_lboard_t));
|
||||
}
|
||||
|
||||
/* assign the new lboard */
|
||||
self->lboards[self->lboard_count].id = id;
|
||||
self->lboards[self->lboard_count].value = 0;
|
||||
self->lboards[self->lboard_count].lboard = lboard;
|
||||
self->lboards[self->lboard_count].buffer = lboard_buffer;
|
||||
memcpy(self->lboards[self->lboard_count].md5, md5, 16);
|
||||
self->lboards[self->lboard_count].owns_memrefs = owns_memref;
|
||||
++self->lboard_count;
|
||||
|
||||
/* reset it, and return it */
|
||||
lboard->memrefs = NULL;
|
||||
rc_reset_lboard(lboard);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* self, unsigned id)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
if (self->lboards[i].id == id && self->lboards[i].lboard != NULL)
|
||||
return self->lboards[i].lboard;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int rc_runtime_activate_richpresence(rc_runtime_t* self, const char* script, lua_State* L, int funcs_idx) {
|
||||
rc_richpresence_t* richpresence;
|
||||
rc_runtime_richpresence_t* previous;
|
||||
rc_richpresence_display_t* display;
|
||||
rc_parse_state_t parse;
|
||||
int size;
|
||||
|
||||
if (script == NULL)
|
||||
return RC_MISSING_DISPLAY_STRING;
|
||||
|
||||
size = rc_richpresence_size(script);
|
||||
if (size < 0)
|
||||
return size;
|
||||
|
||||
if (!self->richpresence_display_buffer) {
|
||||
self->richpresence_display_buffer = (char*)malloc(RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE * sizeof(char));
|
||||
if (!self->richpresence_display_buffer)
|
||||
return RC_OUT_OF_MEMORY;
|
||||
}
|
||||
self->richpresence_display_buffer[0] = '\0';
|
||||
|
||||
previous = self->richpresence;
|
||||
if (previous) {
|
||||
if (!previous->owns_memrefs) {
|
||||
free(previous->buffer);
|
||||
previous = previous->previous;
|
||||
}
|
||||
}
|
||||
|
||||
self->richpresence = (rc_runtime_richpresence_t*)malloc(sizeof(rc_runtime_richpresence_t));
|
||||
if (!self->richpresence)
|
||||
return RC_OUT_OF_MEMORY;
|
||||
|
||||
self->richpresence->previous = previous;
|
||||
self->richpresence->owns_memrefs = 0;
|
||||
self->richpresence->buffer = malloc(size);
|
||||
|
||||
if (!self->richpresence->buffer)
|
||||
return RC_OUT_OF_MEMORY;
|
||||
|
||||
rc_init_parse_state(&parse, self->richpresence->buffer, L, funcs_idx);
|
||||
self->richpresence->richpresence = richpresence = RC_ALLOC(rc_richpresence_t, &parse);
|
||||
parse.first_memref = &self->memrefs;
|
||||
rc_parse_richpresence_internal(richpresence, script, &parse);
|
||||
rc_destroy_parse_state(&parse);
|
||||
|
||||
if (parse.offset < 0) {
|
||||
free(self->richpresence->buffer);
|
||||
free(self->richpresence);
|
||||
self->richpresence = previous;
|
||||
*self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */
|
||||
return parse.offset;
|
||||
}
|
||||
|
||||
/* if at least one memref was allocated within the rich presence, we can't free the buffer when the rich presence is deactivated */
|
||||
self->richpresence->owns_memrefs = (*self->next_memref != NULL);
|
||||
if (self->richpresence->owns_memrefs) {
|
||||
/* advance through the new memrefs so we're ready for the next allocation */
|
||||
do {
|
||||
self->next_memref = &(*self->next_memref)->next;
|
||||
} while (*self->next_memref != NULL);
|
||||
}
|
||||
|
||||
richpresence->memrefs = NULL;
|
||||
self->richpresence_update_timer = 0;
|
||||
|
||||
if (!richpresence->first_display || !richpresence->first_display->display) {
|
||||
/* non-existant rich presence, treat like static empty string */
|
||||
*self->richpresence_display_buffer = '\0';
|
||||
self->richpresence->richpresence = NULL;
|
||||
}
|
||||
else if (richpresence->first_display->next || /* has conditional display strings */
|
||||
richpresence->first_display->display->next || /* has macros */
|
||||
richpresence->first_display->display->value.conditions) { /* is only a macro */
|
||||
/* dynamic rich presence - reset all of the conditions */
|
||||
display = richpresence->first_display;
|
||||
while (display != NULL) {
|
||||
rc_reset_trigger(&display->trigger);
|
||||
display = display->next;
|
||||
}
|
||||
|
||||
rc_evaluate_richpresence(self->richpresence->richpresence, self->richpresence_display_buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1, NULL, NULL, L);
|
||||
}
|
||||
else {
|
||||
/* static rich presence - copy the static string */
|
||||
const char* src = richpresence->first_display->display->text;
|
||||
char* dst = self->richpresence_display_buffer;
|
||||
const char* end = dst + RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1;
|
||||
while (*src && dst < end)
|
||||
*dst++ = *src++;
|
||||
*dst = '\0';
|
||||
|
||||
/* by setting self->richpresence to null, it won't be evaluated in do_frame() */
|
||||
self->richpresence = NULL;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
const char* rc_runtime_get_richpresence(const rc_runtime_t* self)
|
||||
{
|
||||
if (self->richpresence_display_buffer)
|
||||
return self->richpresence_display_buffer;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void rc_runtime_do_frame(rc_runtime_t* self, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L) {
|
||||
rc_runtime_event_t runtime_event;
|
||||
unsigned i;
|
||||
|
||||
runtime_event.value = 0;
|
||||
|
||||
rc_update_memref_values(self->memrefs, peek, ud);
|
||||
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
rc_trigger_t* trigger = self->triggers[i].trigger;
|
||||
int trigger_state;
|
||||
|
||||
if (!trigger)
|
||||
continue;
|
||||
|
||||
trigger_state = trigger->state;
|
||||
|
||||
switch (rc_evaluate_trigger(trigger, peek, ud, L))
|
||||
{
|
||||
case RC_TRIGGER_STATE_RESET:
|
||||
runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_RESET;
|
||||
runtime_event.id = self->triggers[i].id;
|
||||
event_handler(&runtime_event);
|
||||
break;
|
||||
|
||||
case RC_TRIGGER_STATE_TRIGGERED:
|
||||
runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED;
|
||||
runtime_event.id = self->triggers[i].id;
|
||||
event_handler(&runtime_event);
|
||||
break;
|
||||
|
||||
case RC_TRIGGER_STATE_PAUSED:
|
||||
if (trigger_state != RC_TRIGGER_STATE_PAUSED) {
|
||||
runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED;
|
||||
runtime_event.id = self->triggers[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_TRIGGER_STATE_PRIMED:
|
||||
if (trigger_state != RC_TRIGGER_STATE_PRIMED) {
|
||||
runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED;
|
||||
runtime_event.id = self->triggers[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_TRIGGER_STATE_ACTIVE:
|
||||
if (trigger_state != RC_TRIGGER_STATE_ACTIVE) {
|
||||
runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED;
|
||||
runtime_event.id = self->triggers[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
rc_lboard_t* lboard = self->lboards[i].lboard;
|
||||
int lboard_state;
|
||||
|
||||
if (!lboard)
|
||||
continue;
|
||||
|
||||
lboard_state = lboard->state;
|
||||
switch (rc_evaluate_lboard(lboard, &runtime_event.value, peek, ud, L))
|
||||
{
|
||||
case RC_LBOARD_STATE_STARTED: /* leaderboard is running */
|
||||
if (lboard_state != RC_LBOARD_STATE_STARTED) {
|
||||
self->lboards[i].value = runtime_event.value;
|
||||
|
||||
runtime_event.type = RC_RUNTIME_EVENT_LBOARD_STARTED;
|
||||
runtime_event.id = self->lboards[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
else if (runtime_event.value != self->lboards[i].value) {
|
||||
self->lboards[i].value = runtime_event.value;
|
||||
|
||||
runtime_event.type = RC_RUNTIME_EVENT_LBOARD_UPDATED;
|
||||
runtime_event.id = self->lboards[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_LBOARD_STATE_CANCELED:
|
||||
if (lboard_state != RC_LBOARD_STATE_CANCELED) {
|
||||
runtime_event.type = RC_RUNTIME_EVENT_LBOARD_CANCELED;
|
||||
runtime_event.id = self->lboards[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_LBOARD_STATE_TRIGGERED:
|
||||
if (lboard_state != RC_RUNTIME_EVENT_LBOARD_TRIGGERED) {
|
||||
runtime_event.type = RC_RUNTIME_EVENT_LBOARD_TRIGGERED;
|
||||
runtime_event.id = self->lboards[i].id;
|
||||
event_handler(&runtime_event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (self->richpresence && self->richpresence->richpresence) {
|
||||
if (self->richpresence_update_timer == 0) {
|
||||
/* generate into a temporary buffer so we don't get a partially updated string if it's read while its being updated */
|
||||
char buffer[RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE];
|
||||
int len = rc_evaluate_richpresence(self->richpresence->richpresence, buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1, peek, ud, L);
|
||||
|
||||
/* copy into the real buffer - write the 0 terminator first to ensure reads don't overflow the buffer */
|
||||
if (len > 0) {
|
||||
buffer[RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1] = '\0';
|
||||
memcpy(self->richpresence_display_buffer, buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/* schedule the next update for 60 frames later - most systems use a 60 fps framerate (some use more 50 or 75)
|
||||
* since we're only sending to the server every two minutes, that's only every 7200 frames while active, which
|
||||
* is evenly divisible by 50, 60, and 75.
|
||||
*/
|
||||
self->richpresence_update_timer = 59;
|
||||
}
|
||||
else {
|
||||
self->richpresence_update_timer--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rc_runtime_reset(rc_runtime_t* self) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < self->trigger_count; ++i) {
|
||||
if (self->triggers[i].trigger)
|
||||
rc_reset_trigger(self->triggers[i].trigger);
|
||||
}
|
||||
|
||||
for (i = 0; i < self->lboard_count; ++i) {
|
||||
if (self->lboards[i].lboard)
|
||||
rc_reset_lboard(self->lboards[i].lboard);
|
||||
}
|
||||
|
||||
if (self->richpresence) {
|
||||
rc_richpresence_display_t* display = self->richpresence->richpresence->first_display;
|
||||
while (display != 0) {
|
||||
rc_reset_trigger(&display->trigger);
|
||||
display = display->next;
|
||||
}
|
||||
}
|
||||
}
|
445
deps/rcheevos/src/rcheevos/runtime_progress.c
vendored
Normal file
445
deps/rcheevos/src/rcheevos/runtime_progress.c
vendored
Normal file
@ -0,0 +1,445 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include "../rhash/md5.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define RC_RUNTIME_MARKER 0x0A504152 /* RAP\n */
|
||||
|
||||
#define RC_RUNTIME_CHUNK_MEMREFS 0x4645524D /* MREF */
|
||||
#define RC_RUNTIME_CHUNK_ACHIEVEMENT 0x56484341 /* ACHV */
|
||||
|
||||
#define RC_RUNTIME_CHUNK_DONE 0x454E4F44 /* DONE */
|
||||
|
||||
typedef struct rc_runtime_progress_t {
|
||||
rc_runtime_t* runtime;
|
||||
|
||||
int offset;
|
||||
unsigned char* buffer;
|
||||
|
||||
int chunk_size_offset;
|
||||
|
||||
lua_State* L;
|
||||
} rc_runtime_progress_t;
|
||||
|
||||
#define RC_TRIGGER_STATE_UNUPDATED 0x7F
|
||||
|
||||
#define RC_MEMREF_FLAG_PREV_IS_PRIOR 0x00010000
|
||||
|
||||
static void rc_runtime_progress_write_uint(rc_runtime_progress_t* progress, unsigned value)
|
||||
{
|
||||
if (progress->buffer) {
|
||||
progress->buffer[progress->offset + 0] = value & 0xFF; value >>= 8;
|
||||
progress->buffer[progress->offset + 1] = value & 0xFF; value >>= 8;
|
||||
progress->buffer[progress->offset + 2] = value & 0xFF; value >>= 8;
|
||||
progress->buffer[progress->offset + 3] = value & 0xFF;
|
||||
}
|
||||
|
||||
progress->offset += 4;
|
||||
}
|
||||
|
||||
static unsigned rc_runtime_progress_read_uint(rc_runtime_progress_t* progress)
|
||||
{
|
||||
unsigned value = progress->buffer[progress->offset + 0] |
|
||||
(progress->buffer[progress->offset + 1] << 8) |
|
||||
(progress->buffer[progress->offset + 2] << 16) |
|
||||
(progress->buffer[progress->offset + 3] << 24);
|
||||
|
||||
progress->offset += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
static void rc_runtime_progress_write_md5(rc_runtime_progress_t* progress, unsigned char* md5)
|
||||
{
|
||||
if (progress->buffer)
|
||||
memcpy(&progress->buffer[progress->offset], md5, 16);
|
||||
|
||||
progress->offset += 16;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_match_md5(rc_runtime_progress_t* progress, unsigned char* md5)
|
||||
{
|
||||
int result = 0;
|
||||
if (progress->buffer)
|
||||
result = (memcmp(&progress->buffer[progress->offset], md5, 16) == 0);
|
||||
|
||||
progress->offset += 16;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void rc_runtime_progress_start_chunk(rc_runtime_progress_t* progress, unsigned chunk_id)
|
||||
{
|
||||
rc_runtime_progress_write_uint(progress, chunk_id);
|
||||
|
||||
progress->chunk_size_offset = progress->offset;
|
||||
|
||||
progress->offset += 4;
|
||||
}
|
||||
|
||||
static void rc_runtime_progress_end_chunk(rc_runtime_progress_t* progress)
|
||||
{
|
||||
unsigned length;
|
||||
int offset;
|
||||
|
||||
progress->offset = (progress->offset + 3) & ~0x03; /* align to 4 byte boundary */
|
||||
|
||||
if (progress->buffer) {
|
||||
/* ignore chunk size field when calculating chunk size */
|
||||
length = (unsigned)(progress->offset - progress->chunk_size_offset - 4);
|
||||
|
||||
/* temporarily update the write pointer to write the chunk size field */
|
||||
offset = progress->offset;
|
||||
progress->offset = progress->chunk_size_offset;
|
||||
rc_runtime_progress_write_uint(progress, length);
|
||||
progress->offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
static void rc_runtime_progress_init(rc_runtime_progress_t* progress, rc_runtime_t* runtime, lua_State* L)
|
||||
{
|
||||
memset(progress, 0, sizeof(rc_runtime_progress_t));
|
||||
progress->runtime = runtime;
|
||||
progress->L = L;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_write_memrefs(rc_runtime_progress_t* progress)
|
||||
{
|
||||
rc_memref_value_t* memref = progress->runtime->memrefs;
|
||||
unsigned int flags = 0;
|
||||
|
||||
rc_runtime_progress_start_chunk(progress, RC_RUNTIME_CHUNK_MEMREFS);
|
||||
|
||||
while (memref) {
|
||||
flags = memref->memref.size;
|
||||
if (memref->previous == memref->prior)
|
||||
flags |= RC_MEMREF_FLAG_PREV_IS_PRIOR;
|
||||
|
||||
rc_runtime_progress_write_uint(progress, memref->memref.address);
|
||||
rc_runtime_progress_write_uint(progress, flags);
|
||||
rc_runtime_progress_write_uint(progress, memref->value);
|
||||
rc_runtime_progress_write_uint(progress, memref->prior);
|
||||
|
||||
memref = memref->next;
|
||||
}
|
||||
|
||||
rc_runtime_progress_end_chunk(progress);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_read_memrefs(rc_runtime_progress_t* progress)
|
||||
{
|
||||
unsigned entries;
|
||||
unsigned address, flags, value, prior;
|
||||
char size;
|
||||
rc_memref_value_t* memref;
|
||||
|
||||
/* re-read the chunk size to determine how many memrefs are present */
|
||||
progress->offset -= 4;
|
||||
entries = rc_runtime_progress_read_uint(progress) / 16;
|
||||
|
||||
while (entries != 0) {
|
||||
address = rc_runtime_progress_read_uint(progress);
|
||||
flags = rc_runtime_progress_read_uint(progress);
|
||||
value = rc_runtime_progress_read_uint(progress);
|
||||
prior = rc_runtime_progress_read_uint(progress);
|
||||
|
||||
size = flags & 0xFF;
|
||||
|
||||
memref = progress->runtime->memrefs;
|
||||
while (memref) {
|
||||
if (memref->memref.address == address && memref->memref.size == size) {
|
||||
memref->value = value;
|
||||
memref->previous = (flags & RC_MEMREF_FLAG_PREV_IS_PRIOR) ? prior : value;
|
||||
memref->prior = prior;
|
||||
}
|
||||
|
||||
memref = memref->next;
|
||||
}
|
||||
|
||||
--entries;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_write_condset(rc_runtime_progress_t* progress, rc_condset_t* condset)
|
||||
{
|
||||
rc_condition_t* cond;
|
||||
|
||||
rc_runtime_progress_write_uint(progress, condset->is_paused);
|
||||
|
||||
cond = condset->conditions;
|
||||
while (cond) {
|
||||
rc_runtime_progress_write_uint(progress, cond->current_hits);
|
||||
rc_runtime_progress_write_uint(progress, cond->is_true);
|
||||
|
||||
cond = cond->next;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_read_condset(rc_runtime_progress_t* progress, rc_condset_t* condset)
|
||||
{
|
||||
rc_condition_t* cond;
|
||||
|
||||
condset->is_paused = rc_runtime_progress_read_uint(progress);
|
||||
|
||||
cond = condset->conditions;
|
||||
while (cond) {
|
||||
cond->current_hits = rc_runtime_progress_read_uint(progress);
|
||||
cond->is_true = rc_runtime_progress_read_uint(progress) & 0xFF;
|
||||
|
||||
cond = cond->next;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_write_trigger(rc_runtime_progress_t* progress, rc_trigger_t* trigger)
|
||||
{
|
||||
rc_condset_t* condset;
|
||||
int result;
|
||||
|
||||
rc_runtime_progress_write_uint(progress, trigger->state);
|
||||
rc_runtime_progress_write_uint(progress, trigger->measured_value);
|
||||
|
||||
if (trigger->requirement) {
|
||||
result = rc_runtime_progress_write_condset(progress, trigger->requirement);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
condset = trigger->alternative;
|
||||
while (condset)
|
||||
{
|
||||
result = rc_runtime_progress_write_condset(progress, condset);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
|
||||
condset = condset->next;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_read_trigger(rc_runtime_progress_t* progress, rc_trigger_t* trigger)
|
||||
{
|
||||
rc_condset_t* condset;
|
||||
int result;
|
||||
|
||||
trigger->state = rc_runtime_progress_read_uint(progress);
|
||||
trigger->measured_value = rc_runtime_progress_read_uint(progress);
|
||||
|
||||
if (trigger->requirement) {
|
||||
result = rc_runtime_progress_read_condset(progress, trigger->requirement);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
condset = trigger->alternative;
|
||||
while (condset)
|
||||
{
|
||||
result = rc_runtime_progress_read_condset(progress, condset);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
|
||||
condset = condset->next;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_write_achievements(rc_runtime_progress_t* progress)
|
||||
{
|
||||
unsigned i;
|
||||
int result;
|
||||
|
||||
for (i = 0; i < progress->runtime->trigger_count; ++i)
|
||||
{
|
||||
rc_runtime_trigger_t* runtime_trigger = &progress->runtime->triggers[i];
|
||||
if (!runtime_trigger->trigger)
|
||||
continue;
|
||||
|
||||
switch (runtime_trigger->trigger->state)
|
||||
{
|
||||
case RC_TRIGGER_STATE_INACTIVE:
|
||||
case RC_TRIGGER_STATE_TRIGGERED:
|
||||
/* don't store state for inactive or triggered achievements */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
rc_runtime_progress_start_chunk(progress, RC_RUNTIME_CHUNK_ACHIEVEMENT);
|
||||
rc_runtime_progress_write_uint(progress, runtime_trigger->id);
|
||||
rc_runtime_progress_write_md5(progress, runtime_trigger->md5);
|
||||
|
||||
result = rc_runtime_progress_write_trigger(progress, runtime_trigger->trigger);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
|
||||
rc_runtime_progress_end_chunk(progress);
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_read_achievement(rc_runtime_progress_t* progress)
|
||||
{
|
||||
unsigned id = rc_runtime_progress_read_uint(progress);
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < progress->runtime->trigger_count; ++i) {
|
||||
rc_runtime_trigger_t* runtime_trigger = &progress->runtime->triggers[i];
|
||||
if (runtime_trigger->id == id && runtime_trigger->trigger != NULL) {
|
||||
/* ignore triggered and waiting achievements */
|
||||
if (runtime_trigger->trigger->state == RC_TRIGGER_STATE_UNUPDATED) {
|
||||
/* only update state if definition hasn't changed (md5 matches) */
|
||||
if (rc_runtime_progress_match_md5(progress, runtime_trigger->md5))
|
||||
return rc_runtime_progress_read_trigger(progress, runtime_trigger->trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static int rc_runtime_progress_serialize_internal(rc_runtime_progress_t* progress)
|
||||
{
|
||||
md5_state_t state;
|
||||
unsigned char md5[16];
|
||||
int result;
|
||||
|
||||
rc_runtime_progress_write_uint(progress, RC_RUNTIME_MARKER);
|
||||
|
||||
if ((result = rc_runtime_progress_write_memrefs(progress)) != RC_OK)
|
||||
return result;
|
||||
|
||||
if ((result = rc_runtime_progress_write_achievements(progress)) != RC_OK)
|
||||
return result;
|
||||
|
||||
rc_runtime_progress_write_uint(progress, RC_RUNTIME_CHUNK_DONE);
|
||||
rc_runtime_progress_write_uint(progress, 16);
|
||||
|
||||
if (progress->buffer) {
|
||||
md5_init(&state);
|
||||
md5_append(&state, progress->buffer, progress->offset);
|
||||
md5_finish(&state, md5);
|
||||
}
|
||||
|
||||
rc_runtime_progress_write_md5(progress, md5);
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
int rc_runtime_progress_size(const rc_runtime_t* runtime, lua_State* L)
|
||||
{
|
||||
rc_runtime_progress_t progress;
|
||||
int result;
|
||||
|
||||
rc_runtime_progress_init(&progress, (rc_runtime_t*)runtime, L);
|
||||
|
||||
result = rc_runtime_progress_serialize_internal(&progress);
|
||||
if (result != RC_OK)
|
||||
return result;
|
||||
|
||||
return progress.offset;
|
||||
}
|
||||
|
||||
int rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, lua_State* L)
|
||||
{
|
||||
rc_runtime_progress_t progress;
|
||||
|
||||
rc_runtime_progress_init(&progress, (rc_runtime_t*)runtime, L);
|
||||
progress.buffer = (unsigned char*)buffer;
|
||||
|
||||
return rc_runtime_progress_serialize_internal(&progress);
|
||||
}
|
||||
|
||||
int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const unsigned char* serialized, lua_State* L)
|
||||
{
|
||||
rc_runtime_progress_t progress;
|
||||
md5_state_t state;
|
||||
unsigned char md5[16];
|
||||
unsigned chunk_id;
|
||||
unsigned chunk_size;
|
||||
unsigned next_chunk_offset;
|
||||
unsigned i;
|
||||
int result = RC_OK;
|
||||
|
||||
rc_runtime_progress_init(&progress, runtime, L);
|
||||
progress.buffer = (unsigned char*)serialized;
|
||||
|
||||
if (rc_runtime_progress_read_uint(&progress) != RC_RUNTIME_MARKER) {
|
||||
rc_runtime_reset(runtime);
|
||||
return RC_INVALID_STATE;
|
||||
}
|
||||
|
||||
for (i = 0; i < runtime->trigger_count; ++i) {
|
||||
rc_runtime_trigger_t* runtime_trigger = &runtime->triggers[i];
|
||||
if (runtime_trigger->trigger) {
|
||||
switch (runtime_trigger->trigger->state)
|
||||
{
|
||||
case RC_TRIGGER_STATE_INACTIVE:
|
||||
case RC_TRIGGER_STATE_TRIGGERED:
|
||||
/* don't update state for inactive or triggered achievements */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* mark active achievements as unupdated. anything that's still unupdated
|
||||
* after deserializing the progress will be reset to waiting */
|
||||
runtime_trigger->trigger->state = RC_TRIGGER_STATE_UNUPDATED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
chunk_id = rc_runtime_progress_read_uint(&progress);
|
||||
chunk_size = rc_runtime_progress_read_uint(&progress);
|
||||
next_chunk_offset = progress.offset + chunk_size;
|
||||
|
||||
switch (chunk_id)
|
||||
{
|
||||
case RC_RUNTIME_CHUNK_MEMREFS:
|
||||
result = rc_runtime_progress_read_memrefs(&progress);
|
||||
break;
|
||||
|
||||
case RC_RUNTIME_CHUNK_ACHIEVEMENT:
|
||||
result = rc_runtime_progress_read_achievement(&progress);
|
||||
break;
|
||||
|
||||
case RC_RUNTIME_CHUNK_DONE:
|
||||
md5_init(&state);
|
||||
md5_append(&state, progress.buffer, progress.offset);
|
||||
md5_finish(&state, md5);
|
||||
if (!rc_runtime_progress_match_md5(&progress, md5))
|
||||
result = RC_INVALID_STATE;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (chunk_size & 0xFFFF0000)
|
||||
result = RC_INVALID_STATE; /* assume unknown chunk > 64KB is invalid */
|
||||
break;
|
||||
}
|
||||
|
||||
progress.offset = next_chunk_offset;
|
||||
} while (result == RC_OK && chunk_id != RC_RUNTIME_CHUNK_DONE);
|
||||
|
||||
if (result != RC_OK) {
|
||||
rc_runtime_reset(runtime);
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < runtime->trigger_count; ++i) {
|
||||
rc_trigger_t* trigger = runtime->triggers[i].trigger;
|
||||
if (trigger && trigger->state == RC_TRIGGER_STATE_UNUPDATED)
|
||||
rc_reset_trigger(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
103
deps/rcheevos/src/rcheevos/term.c
vendored
103
deps/rcheevos/src/rcheevos/term.c
vendored
@ -1,103 +0,0 @@
|
||||
#include "internal.h"
|
||||
|
||||
rc_term_t* rc_parse_term(const char** memaddr, int is_indirect, rc_parse_state_t* parse) {
|
||||
rc_term_t* self;
|
||||
const char* aux;
|
||||
char size;
|
||||
int ret2;
|
||||
|
||||
aux = *memaddr;
|
||||
self = RC_ALLOC(rc_term_t, parse);
|
||||
self->invert = 0;
|
||||
|
||||
ret2 = rc_parse_operand(&self->operand1, &aux, 0, is_indirect, parse);
|
||||
|
||||
if (ret2 < 0) {
|
||||
parse->offset = ret2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*aux == '*') {
|
||||
aux++;
|
||||
|
||||
if (*aux == '~') {
|
||||
aux++;
|
||||
self->invert = 1;
|
||||
}
|
||||
|
||||
ret2 = rc_parse_operand(&self->operand2, &aux, 0, is_indirect, parse);
|
||||
|
||||
if (ret2 < 0) {
|
||||
parse->offset = ret2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->invert) {
|
||||
switch (self->operand2.type) {
|
||||
case RC_OPERAND_ADDRESS:
|
||||
case RC_OPERAND_DELTA:
|
||||
case RC_OPERAND_PRIOR:
|
||||
size = self->operand2.value.memref->memref.size;
|
||||
break;
|
||||
default:
|
||||
size = RC_MEMSIZE_32_BITS;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
case RC_MEMSIZE_BIT_0:
|
||||
case RC_MEMSIZE_BIT_1:
|
||||
case RC_MEMSIZE_BIT_2:
|
||||
case RC_MEMSIZE_BIT_3:
|
||||
case RC_MEMSIZE_BIT_4:
|
||||
case RC_MEMSIZE_BIT_5:
|
||||
case RC_MEMSIZE_BIT_6:
|
||||
case RC_MEMSIZE_BIT_7:
|
||||
/* invert is already 1 */
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_LOW:
|
||||
case RC_MEMSIZE_HIGH:
|
||||
self->invert = 0xf;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_8_BITS:
|
||||
self->invert = 0xffU;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_16_BITS:
|
||||
self->invert = 0xffffU;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_24_BITS:
|
||||
self->invert = 0xffffffU;
|
||||
break;
|
||||
|
||||
case RC_MEMSIZE_32_BITS:
|
||||
self->invert = 0xffffffffU;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
self->operand2.type = RC_OPERAND_CONST;
|
||||
self->operand2.value.num = 1;
|
||||
}
|
||||
|
||||
*memaddr = aux;
|
||||
return self;
|
||||
}
|
||||
|
||||
int rc_evaluate_term(rc_term_t* self, rc_eval_state_t* eval_state) {
|
||||
/* Operands are usually memory references and are always retrieved as unsigned. The floating
|
||||
* point operand is signed, and will automatically make the result signed. Otherwise, multiply
|
||||
* by the secondary operand (which is usually 1) and cast to signed.
|
||||
*/
|
||||
unsigned value = rc_evaluate_operand(&self->operand1, eval_state);
|
||||
|
||||
if (self->operand2.type != RC_OPERAND_FP) {
|
||||
return (int)(value * (rc_evaluate_operand(&self->operand2, eval_state) ^ self->invert));
|
||||
}
|
||||
|
||||
return (int)((double)value * self->operand2.value.dbl);
|
||||
}
|
72
deps/rcheevos/src/rcheevos/trigger.c
vendored
72
deps/rcheevos/src/rcheevos/trigger.c
vendored
@ -1,10 +1,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <string.h> /* memset */
|
||||
|
||||
void rc_parse_trigger_internal(rc_trigger_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
rc_condset_t** next;
|
||||
@ -36,7 +33,7 @@ void rc_parse_trigger_internal(rc_trigger_t* self, const char** memaddr, rc_pars
|
||||
|
||||
next = &(*next)->next;
|
||||
}
|
||||
|
||||
|
||||
*next = 0;
|
||||
*memaddr = aux;
|
||||
|
||||
@ -62,7 +59,7 @@ rc_trigger_t* rc_parse_trigger(void* buffer, const char* memaddr, lua_State* L,
|
||||
rc_trigger_t* self;
|
||||
rc_parse_state_t parse;
|
||||
rc_init_parse_state(&parse, buffer, L, funcs_ndx);
|
||||
|
||||
|
||||
self = RC_ALLOC(rc_trigger_t, &parse);
|
||||
rc_init_parse_state_memrefs(&parse, &self->memrefs);
|
||||
|
||||
@ -92,14 +89,15 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State*
|
||||
rc_condset_t* condset;
|
||||
int ret;
|
||||
char is_paused;
|
||||
char is_primed;
|
||||
|
||||
/* previously triggered, do nothing - return INACTIVE so caller doesn't report a repeated trigger */
|
||||
if (self->state == RC_TRIGGER_STATE_TRIGGERED)
|
||||
return RC_TRIGGER_STATE_INACTIVE;
|
||||
return RC_TRIGGER_STATE_INACTIVE;
|
||||
|
||||
rc_update_memref_values(self->memrefs, peek, ud);
|
||||
|
||||
/* not yet active, only update the memrefs - so deltas are corrent when it becomes active */
|
||||
/* not yet active, only update the memrefs - so deltas are correct when it becomes active */
|
||||
if (self->state == RC_TRIGGER_STATE_INACTIVE)
|
||||
return RC_TRIGGER_STATE_INACTIVE;
|
||||
|
||||
@ -109,22 +107,41 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State*
|
||||
eval_state.peek_userdata = ud;
|
||||
eval_state.L = L;
|
||||
|
||||
ret = self->requirement != 0 ? rc_test_condset(self->requirement, &eval_state) : 1;
|
||||
condset = self->alternative;
|
||||
if (self->requirement != NULL) {
|
||||
ret = rc_test_condset(self->requirement, &eval_state);
|
||||
is_paused = self->requirement->is_paused;
|
||||
is_primed = eval_state.primed;
|
||||
} else {
|
||||
ret = 1;
|
||||
is_paused = 0;
|
||||
is_primed = 1;
|
||||
}
|
||||
|
||||
condset = self->alternative;
|
||||
if (condset) {
|
||||
int sub = 0;
|
||||
char sub_paused = 1;
|
||||
char sub_primed = 0;
|
||||
|
||||
do {
|
||||
sub |= rc_test_condset(condset, &eval_state);
|
||||
condset = condset->next;
|
||||
}
|
||||
while (condset != 0);
|
||||
sub_paused &= condset->is_paused;
|
||||
sub_primed |= eval_state.primed;
|
||||
|
||||
condset = condset->next;
|
||||
} while (condset != 0);
|
||||
|
||||
/* to trigger, the core must be true and at least one alt must be true */
|
||||
ret &= sub;
|
||||
is_primed &= sub_primed;
|
||||
|
||||
/* if the core is not paused, all alts must be paused to count as a paused trigger */
|
||||
is_paused |= sub_paused;
|
||||
}
|
||||
|
||||
self->measured_value = eval_state.measured_value;
|
||||
/* if paused, the measured value may not be captured, keep the old value */
|
||||
if (!is_paused)
|
||||
self->measured_value = eval_state.measured_value;
|
||||
|
||||
/* if the state is WAITING and the trigger is ready to fire, ignore it and reset the hit counts */
|
||||
/* otherwise, if the state is WAITING, proceed to activating the trigger */
|
||||
@ -138,6 +155,10 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State*
|
||||
/* if any ResetIf condition was true, reset the hit counts */
|
||||
rc_reset_trigger_hitcounts(self);
|
||||
|
||||
/* if the measured value came from a hit count, reset it too */
|
||||
if (eval_state.measured_from_hits)
|
||||
self->measured_value = 0;
|
||||
|
||||
/* if there were hit counts to clear, return RESET, but don't change the state */
|
||||
if (self->has_hits) {
|
||||
self->has_hits = 0;
|
||||
@ -146,6 +167,7 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State*
|
||||
|
||||
/* any hits that were tallied were just reset */
|
||||
eval_state.has_hits = 0;
|
||||
is_primed = 0;
|
||||
}
|
||||
else if (ret) {
|
||||
/* trigger was triggered */
|
||||
@ -156,20 +178,16 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State*
|
||||
/* did not trigger this frame - update the information we'll need for next time */
|
||||
self->has_hits = eval_state.has_hits;
|
||||
|
||||
/* check to see if the trigger is paused */
|
||||
is_paused = (self->requirement != NULL) ? self->requirement->is_paused : 0;
|
||||
if (!is_paused) {
|
||||
/* if the core is not paused, all alts must be paused to count as a paused trigger */
|
||||
is_paused = (self->alternative != NULL);
|
||||
for (condset = self->alternative; condset != NULL; condset = condset->next) {
|
||||
if (!condset->is_paused) {
|
||||
is_paused = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_paused) {
|
||||
self->state = RC_TRIGGER_STATE_PAUSED;
|
||||
}
|
||||
else if (is_primed) {
|
||||
self->state = RC_TRIGGER_STATE_PRIMED;
|
||||
}
|
||||
else {
|
||||
self->state = RC_TRIGGER_STATE_ACTIVE;
|
||||
}
|
||||
|
||||
self->state = is_paused ? RC_TRIGGER_STATE_PAUSED : RC_TRIGGER_STATE_ACTIVE;
|
||||
return self->state;
|
||||
}
|
||||
|
||||
@ -184,4 +202,6 @@ void rc_reset_trigger(rc_trigger_t* self) {
|
||||
rc_reset_trigger_hitcounts(self);
|
||||
|
||||
self->state = RC_TRIGGER_STATE_WAITING;
|
||||
self->measured_value = 0;
|
||||
self->has_hits = 0;
|
||||
}
|
||||
|
169
deps/rcheevos/src/rcheevos/value.c
vendored
169
deps/rcheevos/src/rcheevos/value.c
vendored
@ -1,9 +1,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <string.h> /* memset */
|
||||
#include <ctype.h> /* isdigit */
|
||||
|
||||
static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
rc_condition_t** next;
|
||||
@ -12,12 +10,10 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse
|
||||
|
||||
has_measured = 0;
|
||||
in_add_address = 0;
|
||||
self->expressions = 0;
|
||||
|
||||
/* this largely duplicates rc_parse_condset, but we cannot call it directly, as we need to check the
|
||||
/* this largely duplicates rc_parse_condset, but we cannot call it directly, as we need to check the
|
||||
* type of each condition as we go */
|
||||
self->conditions = RC_ALLOC(rc_condset_t, parse);
|
||||
self->conditions->next = 0;
|
||||
self->conditions->has_pause = 0;
|
||||
|
||||
next = &self->conditions->conditions;
|
||||
@ -49,7 +45,7 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse
|
||||
return;
|
||||
}
|
||||
has_measured = 1;
|
||||
if ((*next)->required_hits == 0 && (*next)->oper != RC_CONDITION_NONE)
|
||||
if ((*next)->required_hits == 0 && (*next)->oper != RC_OPERATOR_NONE)
|
||||
(*next)->required_hits = (unsigned)-1;
|
||||
break;
|
||||
|
||||
@ -69,42 +65,125 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse
|
||||
(*memaddr)++;
|
||||
}
|
||||
|
||||
*next = 0;
|
||||
|
||||
if (!has_measured) {
|
||||
parse->offset = RC_MISSING_VALUE_MEASURED;
|
||||
}
|
||||
|
||||
if (parse->buffer) {
|
||||
*next = 0;
|
||||
self->conditions->next = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
rc_expression_t** next;
|
||||
void rc_parse_legacy_value(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
rc_condition_t** next;
|
||||
rc_condset_t** next_clause;
|
||||
rc_condition_t* cond;
|
||||
char buffer[64] = "A:";
|
||||
const char* buffer_ptr;
|
||||
char* ptr;
|
||||
int end_of_clause;
|
||||
|
||||
/* if it starts with a condition flag (M: A: B: C:), parse the conditions */
|
||||
if ((*memaddr)[1] == ':') {
|
||||
rc_parse_cond_value(self, memaddr, parse);
|
||||
return;
|
||||
}
|
||||
/* convert legacy format into condset */
|
||||
self->conditions = RC_ALLOC(rc_condset_t, parse);
|
||||
self->conditions->has_pause = 0;
|
||||
|
||||
self->conditions = 0;
|
||||
next = &self->expressions;
|
||||
next = &self->conditions->conditions;
|
||||
next_clause = &self->conditions->next;
|
||||
|
||||
for (;;) {
|
||||
*next = rc_parse_expression(memaddr, parse);
|
||||
ptr = &buffer[2];
|
||||
end_of_clause = 0;
|
||||
|
||||
do {
|
||||
switch (**memaddr) {
|
||||
case '_': /* add next */
|
||||
case '$': /* maximum of */
|
||||
case '\0': /* end of string */
|
||||
case ':': /* end of leaderboard clause */
|
||||
case ')': /* end of rich presence macro */
|
||||
end_of_clause = 1;
|
||||
*ptr = '\0';
|
||||
break;
|
||||
|
||||
case '*':
|
||||
*ptr++ = '*';
|
||||
|
||||
buffer_ptr = *memaddr + 1;
|
||||
if (*buffer_ptr == '-') {
|
||||
/* negative value automatically needs prefix, 'f' handles both float and digits, so use it */
|
||||
*ptr++ = 'f';
|
||||
}
|
||||
else {
|
||||
/* if it looks like a floating point number, add the 'f' prefix */
|
||||
while (isdigit(*buffer_ptr))
|
||||
++buffer_ptr;
|
||||
if (*buffer_ptr == '.')
|
||||
*ptr++ = 'f';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
*ptr++ = **memaddr;
|
||||
break;
|
||||
}
|
||||
|
||||
++(*memaddr);
|
||||
} while (!end_of_clause);
|
||||
|
||||
buffer_ptr = buffer;
|
||||
cond = rc_parse_condition(&buffer_ptr, parse, 0);
|
||||
if (parse->offset < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
next = &(*next)->next;
|
||||
switch (cond->oper) {
|
||||
case RC_OPERATOR_MULT:
|
||||
case RC_OPERATOR_DIV:
|
||||
case RC_OPERATOR_AND:
|
||||
case RC_OPERATOR_NONE:
|
||||
break;
|
||||
|
||||
if (**memaddr != '$') {
|
||||
break;
|
||||
default:
|
||||
parse->offset = RC_INVALID_OPERATOR;
|
||||
return;
|
||||
}
|
||||
|
||||
(*memaddr)++;
|
||||
}
|
||||
cond->pause = 0;
|
||||
*next = cond;
|
||||
|
||||
*next = 0;
|
||||
switch ((*memaddr)[-1]) {
|
||||
case '_': /* add next */
|
||||
next = &cond->next;
|
||||
break;
|
||||
|
||||
case '$': /* max of */
|
||||
cond->type = RC_CONDITION_MEASURED;
|
||||
cond->next = 0;
|
||||
*next_clause = RC_ALLOC(rc_condset_t, parse);
|
||||
(*next_clause)->has_pause = 0;
|
||||
next = &(*next_clause)->conditions;
|
||||
next_clause = &(*next_clause)->next;
|
||||
break;
|
||||
|
||||
default: /* end of valid string */
|
||||
--(*memaddr); /* undo the increment we performed when copying the string */
|
||||
cond->type = RC_CONDITION_MEASURED;
|
||||
cond->next = 0;
|
||||
*next_clause = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
/* if it starts with a condition flag (M: A: B: C:), parse the conditions */
|
||||
if ((*memaddr)[1] == ':') {
|
||||
rc_parse_cond_value(self, memaddr, parse);
|
||||
}
|
||||
else {
|
||||
rc_parse_legacy_value(self, memaddr, parse);
|
||||
}
|
||||
}
|
||||
|
||||
int rc_value_size(const char* memaddr) {
|
||||
@ -123,7 +202,7 @@ rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int
|
||||
rc_value_t* self;
|
||||
rc_parse_state_t parse;
|
||||
rc_init_parse_state(&parse, buffer, L, funcs_ndx);
|
||||
|
||||
|
||||
self = RC_ALLOC(rc_value_t, &parse);
|
||||
rc_init_parse_state_memrefs(&parse, &self->memrefs);
|
||||
|
||||
@ -133,26 +212,11 @@ rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int
|
||||
return parse.offset >= 0 ? self : 0;
|
||||
}
|
||||
|
||||
static int rc_evaluate_expr_value(rc_value_t* self, rc_eval_state_t* eval_state) {
|
||||
rc_expression_t* exp;
|
||||
int value, max;
|
||||
|
||||
exp = self->expressions;
|
||||
max = rc_evaluate_expression(exp, eval_state);
|
||||
|
||||
for (exp = exp->next; exp != 0; exp = exp->next) {
|
||||
value = rc_evaluate_expression(exp, eval_state);
|
||||
|
||||
if (value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
int rc_evaluate_value(rc_value_t* self, rc_peek_t peek, void* ud, lua_State* L) {
|
||||
rc_eval_state_t eval_state;
|
||||
rc_condset_t* condset;
|
||||
int result = 0;
|
||||
|
||||
memset(&eval_state, 0, sizeof(eval_state));
|
||||
eval_state.peek = peek;
|
||||
eval_state.peek_userdata = ud;
|
||||
@ -160,10 +224,17 @@ int rc_evaluate_value(rc_value_t* self, rc_peek_t peek, void* ud, lua_State* L)
|
||||
|
||||
rc_update_memref_values(self->memrefs, peek, ud);
|
||||
|
||||
if (self->expressions) {
|
||||
return rc_evaluate_expr_value(self, &eval_state);
|
||||
rc_test_condset(self->conditions, &eval_state);
|
||||
result = (int)eval_state.measured_value;
|
||||
|
||||
condset = self->conditions->next;
|
||||
while (condset != NULL) {
|
||||
rc_test_condset(condset, &eval_state);
|
||||
if ((int)eval_state.measured_value > result)
|
||||
result = (int)eval_state.measured_value;
|
||||
|
||||
condset = condset->next;
|
||||
}
|
||||
|
||||
rc_test_condset(self->conditions, &eval_state);
|
||||
return (int)eval_state.measured_value;
|
||||
return result;
|
||||
}
|
||||
|
1491
deps/rcheevos/src/rhash/hash.c
vendored
Normal file
1491
deps/rcheevos/src/rhash/hash.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
deps/rcheevos/src/rhash/md5.h
vendored
Normal file
18
deps/rcheevos/src/rhash/md5.h
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef RC_MD5_H
|
||||
#define RC_MD5_H
|
||||
|
||||
/* NOTE: this is NOT the md5.h included in the rcheevos repository. It provides the same
|
||||
* functionality using code already present in RetroArch */
|
||||
|
||||
/* android build has libretro-common/include in path, but not the base directory.
|
||||
* other builds prioritize rcheevos/include over libretro-common/include.
|
||||
* to ensure we get the correct include file, use a complicated relative path */
|
||||
#include <../../../libretro-common/include/rhash.h>
|
||||
|
||||
#define md5_state_t MD5_CTX
|
||||
#define md5_byte_t unsigned char
|
||||
#define md5_init(state) MD5_Init(state)
|
||||
#define md5_append(state, buffer, size) MD5_Update(state, buffer, size)
|
||||
#define md5_finish(state, hash) MD5_Final(hash, state)
|
||||
|
||||
#endif
|
203
deps/rcheevos/src/rurl/url.c
vendored
203
deps/rcheevos/src/rurl/url.c
vendored
@ -1,15 +1,7 @@
|
||||
#include "rurl.h"
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include <rhash.h> /* libretro-common/include/rhash.h */
|
||||
#define md5_state_t MD5_CTX
|
||||
#define md5_byte_t unsigned char
|
||||
#define md5_init(state) MD5_Init(state)
|
||||
#define md5_append(state, buffer, size) MD5_Update(state, buffer, size)
|
||||
#define md5_finish(state, hash) MD5_Final(hash, state)
|
||||
#else
|
||||
#include "..\rhash\md5.h"
|
||||
#endif
|
||||
#include "../rcheevos/compat.h"
|
||||
#include "../rhash/md5.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -25,37 +17,41 @@ static int rc_url_encode(char* encoded, size_t len, const char* str) {
|
||||
case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
||||
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
||||
case '-': case '_': case '.': case '~':
|
||||
if (len >= 2) {
|
||||
*encoded++ = *str++;
|
||||
len--;
|
||||
}
|
||||
else {
|
||||
if (len < 2)
|
||||
return -1;
|
||||
}
|
||||
|
||||
*encoded++ = *str++;
|
||||
--len;
|
||||
break;
|
||||
|
||||
|
||||
case ' ':
|
||||
if (len < 2)
|
||||
return -1;
|
||||
|
||||
*encoded++ = '+';
|
||||
++str;
|
||||
--len;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (len >= 4) {
|
||||
snprintf(encoded, len, "%%%02x", (unsigned char)*str);
|
||||
encoded += 3;
|
||||
str++;
|
||||
len -= 3;
|
||||
}
|
||||
else {
|
||||
if (len < 4)
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(encoded, len, "%%%02x", (unsigned char)*str);
|
||||
encoded += 3;
|
||||
++str;
|
||||
len -= 3;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
||||
case '\0':
|
||||
*encoded = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore) {
|
||||
int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token,
|
||||
unsigned cheevo_id, int hardcore, const char* game_hash) {
|
||||
char urle_user_name[64];
|
||||
char urle_login_token[64];
|
||||
int written;
|
||||
@ -63,11 +59,11 @@ int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -78,10 +74,14 @@ int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const
|
||||
hardcore ? 1 : 0
|
||||
);
|
||||
|
||||
if (game_hash && strlen(game_hash) == 32 && (size - (size_t)written) >= 35) {
|
||||
written += snprintf(buffer + written, size - (size_t)written, "&m=%s", game_hash);
|
||||
}
|
||||
|
||||
return (size_t)written >= size ? -1 : 0;
|
||||
}
|
||||
|
||||
int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value, const char* game_hash) {
|
||||
int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value) {
|
||||
char urle_user_name[64];
|
||||
char urle_login_token[64];
|
||||
char signature[64];
|
||||
@ -92,7 +92,7 @@ int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -115,20 +115,15 @@ int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const
|
||||
hash[ 8], hash[ 9], hash[10], hash[11],hash[12], hash[13], hash[14], hash[15]
|
||||
);
|
||||
|
||||
if (game_hash && strlen(game_hash) == 32 && (size - (size_t)written) >= 35) {
|
||||
written += snprintf(buffer + written, size - (size_t)written, "&m=%s", game_hash);
|
||||
}
|
||||
|
||||
return (size_t)written >= size ? -1 : 0;
|
||||
}
|
||||
|
||||
int rc_url_get_gameid(char* buffer, size_t size, unsigned char hash[16]) {
|
||||
int rc_url_get_gameid(char* buffer, size_t size, const char* hash) {
|
||||
int written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
"http://retroachievements.org/dorequest.php?r=gameid&m=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
hash[ 0], hash[ 1], hash[ 2], hash[ 3], hash[ 4], hash[ 5], hash[ 6], hash[ 7],
|
||||
hash[ 8], hash[ 9], hash[10], hash[11],hash[12], hash[13], hash[14], hash[15]
|
||||
"http://retroachievements.org/dorequest.php?r=gameid&m=%s",
|
||||
hash
|
||||
);
|
||||
|
||||
return (size_t)written >= size ? -1 : 0;
|
||||
@ -142,11 +137,11 @@ int rc_url_get_patch(char* buffer, size_t size, const char* user_name, const cha
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -178,11 +173,11 @@ int rc_url_login_with_password(char* buffer, size_t size, const char* user_name,
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_password, sizeof(urle_password), password) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -202,11 +197,11 @@ int rc_url_login_with_token(char* buffer, size_t size, const char* user_name, co
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -226,11 +221,11 @@ int rc_url_get_unlock_list(char* buffer, size_t size, const char* user_name, con
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -252,11 +247,11 @@ int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const
|
||||
if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
written = snprintf(
|
||||
buffer,
|
||||
size,
|
||||
@ -268,3 +263,111 @@ int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const
|
||||
|
||||
return (size_t)written >= size ? -1 : 0;
|
||||
}
|
||||
|
||||
static int rc_url_append_param_equals(char* buffer, size_t buffer_size, size_t buffer_offset, const char* param)
|
||||
{
|
||||
int written = 0;
|
||||
size_t param_len;
|
||||
|
||||
if (buffer_offset >= buffer_size)
|
||||
return -1;
|
||||
|
||||
if (buffer_offset) {
|
||||
buffer += buffer_offset;
|
||||
buffer_size -= buffer_offset;
|
||||
|
||||
if (buffer[-1] != '?') {
|
||||
*buffer++ = '&';
|
||||
buffer_size--;
|
||||
written = 1;
|
||||
}
|
||||
}
|
||||
|
||||
param_len = strlen(param);
|
||||
if (param_len + 1 >= buffer_size)
|
||||
return -1;
|
||||
memcpy(buffer, param, param_len);
|
||||
buffer[param_len] = '=';
|
||||
|
||||
written += (int)param_len + 1;
|
||||
return written + (int)buffer_offset;
|
||||
}
|
||||
|
||||
static int rc_url_append_unum(char* buffer, size_t buffer_size, size_t* buffer_offset, const char* param, unsigned value)
|
||||
{
|
||||
int written = rc_url_append_param_equals(buffer, buffer_size, *buffer_offset, param);
|
||||
if (written > 0) {
|
||||
char num[16];
|
||||
int chars = sprintf(num, "%u", value);
|
||||
|
||||
if (chars + written < (int)buffer_size)
|
||||
{
|
||||
memcpy(&buffer[written], num, chars + 1);
|
||||
*buffer_offset = written + chars;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int rc_url_append_str(char* buffer, size_t buffer_size, size_t* buffer_offset, const char* param, const char* value)
|
||||
{
|
||||
int written = rc_url_append_param_equals(buffer, buffer_size, *buffer_offset, param);
|
||||
if (written > 0)
|
||||
{
|
||||
buffer += written;
|
||||
buffer_size -= written;
|
||||
|
||||
if (rc_url_encode(buffer, buffer_size, value) == 0)
|
||||
{
|
||||
written += (int)strlen(buffer);
|
||||
*buffer_offset = written;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int rc_url_build_dorequest(char* url_buffer, size_t url_buffer_size, size_t* buffer_offset,
|
||||
const char* api, const char* user_name)
|
||||
{
|
||||
const char* base_url = "http://retroachievements.org/dorequest.php";
|
||||
size_t written = strlen(base_url);
|
||||
int failure = 0;
|
||||
|
||||
if (url_buffer_size < written + 1)
|
||||
return -1;
|
||||
memcpy(url_buffer, base_url, written);
|
||||
url_buffer[written++] = '?';
|
||||
|
||||
failure |= rc_url_append_str(url_buffer, url_buffer_size, &written, "r", api);
|
||||
failure |= rc_url_append_str(url_buffer, url_buffer_size, &written, "u", user_name);
|
||||
|
||||
*buffer_offset += written;
|
||||
return failure;
|
||||
}
|
||||
|
||||
int rc_url_ping(char* url_buffer, size_t url_buffer_size, char* post_buffer, size_t post_buffer_size,
|
||||
const char* user_name, const char* login_token, unsigned gameid, const char* rich_presence)
|
||||
{
|
||||
size_t written = 0;
|
||||
int failure = rc_url_build_dorequest(url_buffer, url_buffer_size, &written, "ping", user_name);
|
||||
failure |= rc_url_append_unum(url_buffer, url_buffer_size, &written, "g", gameid);
|
||||
|
||||
written = 0;
|
||||
failure |= rc_url_append_str(post_buffer, post_buffer_size, &written, "t", login_token);
|
||||
|
||||
if (rich_presence && *rich_presence)
|
||||
failure |= rc_url_append_str(post_buffer, post_buffer_size, &written, "m", rich_presence);
|
||||
|
||||
if (failure) {
|
||||
if (url_buffer_size)
|
||||
url_buffer[0] = '\0';
|
||||
if (post_buffer_size)
|
||||
post_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
return failure;
|
||||
}
|
||||
|
@ -125,6 +125,11 @@ EXE_PATH=${CELL_SDK}/host-win32/bin
|
||||
GENPS3ISO_PATH=${PS3TOOLS_PATH}/ODE/genps3iso_v2.5
|
||||
SCETOOL_PATH=${PS3TOOLS_PATH}/scetool/scetool.exe
|
||||
SCETOOL_FLAGS_ODE="--sce-type=SELF --compress-data=TRUE --self-type=APP --key-revision=04 --self-fw-version=0003004100000000 --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-cap-flags=00000000000000000000000000000000000000000000003b0000000100040000 --encrypt"
|
||||
elif [ $PLATFORM = "dos" ]; then
|
||||
platform=dos
|
||||
MAKEFILE_GRIFFIN=yes
|
||||
EXT=a
|
||||
SALAMANDER=yes
|
||||
fi
|
||||
|
||||
# Cleanup Salamander core if it exists
|
||||
@ -149,6 +154,10 @@ if [ $SALAMANDER = "yes" ]; then
|
||||
if [ $PLATFORM = "psp1" ] ; then
|
||||
mv -f ../EBOOT.PBP ../pkg/${platform}/EBOOT.PBP
|
||||
fi
|
||||
if [ $platform = "dos" ] ; then
|
||||
mkdir -p ../pkg/${platform}
|
||||
mv -f ../retrodos_salamander.exe ../pkg/${platform}/RETRODOS.EXE
|
||||
fi
|
||||
if [ $PLATFORM = "vita" ] ; then
|
||||
mkdir -p ../pkg/${platform}/retroarch.vpk/vpk/sce_sys/livearea/contents
|
||||
vita-make-fself -c -s ../retroarchvita_salamander.velf ../pkg/${platform}/retroarch.vpk/vpk/eboot.bin
|
||||
@ -260,8 +269,8 @@ for f in `ls -v *_${platform}.${EXT}`; do
|
||||
if [ $platform = "psl1ght" ] ; then
|
||||
mv -fv ../retroarch_psl1ght.self ../pkg/psl1ght/pkg/USRDIR/cores/"${name}_libretro_${platform}.SELF"
|
||||
if [ -d ../../dist/info ]; then
|
||||
mkdir -p ../pkg/psl1ght/USRDIR/cores/info
|
||||
cp -fv ../../dist/info/"${name}_libretro.info" ../pkg/psl1ght/USRDIR/pkg/cores/info/"${name}_libretro.info"
|
||||
mkdir -p ../pkg/psl1ght/pkg/USRDIR/cores/info
|
||||
cp -fv ../../dist/info/"${name}_libretro.info" ../pkg/psl1ght/pkg/USRDIR/cores/info/"${name}_libretro.info"
|
||||
fi
|
||||
elif [ $platform = "ps3" ] ; then
|
||||
if [ $PLATFORM = "ode-ps3" ] ; then
|
||||
@ -301,7 +310,10 @@ for f in `ls -v *_${platform}.${EXT}`; do
|
||||
elif [ $PLATFORM = "ngc" ] ; then
|
||||
mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol
|
||||
elif [ $PLATFORM = "wii" ] ; then
|
||||
mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol
|
||||
mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol
|
||||
elif [ $PLATFORM = "dos" ] ; then
|
||||
mkdir -p ../pkg/${platform}/cores
|
||||
mv -f ../retrodos.exe ../pkg/${platform}/cores/${name}.exe
|
||||
elif [ $PLATFORM = "emscripten" ] ; then
|
||||
mkdir -p ../pkg/emscripten/
|
||||
mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js
|
||||
|
@ -414,53 +414,3 @@ void fill_pathname_application_special(char *s,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fill_short_pathname_representation:
|
||||
* @out_rep : output representation
|
||||
* @in_path : input path
|
||||
* @size : size of output representation
|
||||
*
|
||||
* Generates a short representation of path. It should only
|
||||
* be used for displaying the result; the output representation is not
|
||||
* binding in any meaningful way (for a normal path, this is the same as basename)
|
||||
* In case of more complex URLs, this should cut everything except for
|
||||
* the main image file.
|
||||
*
|
||||
* E.g.: "/path/to/game.img" -> game.img
|
||||
* "/path/to/myarchive.7z#folder/to/game.img" -> game.img
|
||||
*/
|
||||
void fill_short_pathname_representation_wrapper(char* out_rep,
|
||||
const char *in_path, size_t size)
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
char *path_short = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *last_slash = NULL;
|
||||
|
||||
path_short[0] = '\0';
|
||||
|
||||
fill_pathname(path_short, path_basename(in_path), "",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
|
||||
last_slash = find_last_slash(path_short);
|
||||
|
||||
if (last_slash != NULL)
|
||||
{
|
||||
/* We handle paths like:
|
||||
* /path/to/file.7z#mygame.img
|
||||
* short_name: mygame.img:
|
||||
*
|
||||
* We check whether something is actually
|
||||
* after the hash to avoid going over the buffer.
|
||||
*/
|
||||
strlcpy(out_rep, last_slash + 1, size);
|
||||
free(path_short);
|
||||
return;
|
||||
}
|
||||
|
||||
free(path_short);
|
||||
#endif
|
||||
|
||||
fill_short_pathname_representation(out_rep, in_path, size);
|
||||
}
|
||||
|
@ -117,24 +117,6 @@ enum application_special_type
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS
|
||||
};
|
||||
|
||||
/**
|
||||
* fill_short_pathname_representation:
|
||||
* @out_rep : output representation
|
||||
* @in_path : input path
|
||||
* @size : size of output representation
|
||||
*
|
||||
* Generates a short representation of path. It should only
|
||||
* be used for displaying the result; the output representation is not
|
||||
* binding in any meaningful way (for a normal path, this is the same as basename)
|
||||
* In case of more complex URLs, this should cut everything except for
|
||||
* the main image file.
|
||||
*
|
||||
* E.g.: "/path/to/game.img" -> game.img
|
||||
* "/path/to/myarchive.7z#folder/to/game.img" -> game.img
|
||||
*/
|
||||
void fill_short_pathname_representation_wrapper(char* out_rep,
|
||||
const char *in_path, size_t size);
|
||||
|
||||
const char *file_path_str(enum file_path_enum enum_idx);
|
||||
|
||||
bool fill_pathname_application_data(char *s, size_t len);
|
||||
|
@ -16,64 +16,199 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <process.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include "../frontend_driver.h"
|
||||
#include "../../defaults.h"
|
||||
|
||||
static enum frontend_fork dos_fork_mode = FRONTEND_FORK_NONE;
|
||||
|
||||
static void frontend_dos_init(void *data)
|
||||
{
|
||||
printf("Loading RetroArch...\n");
|
||||
printf("Loading RetroArch...\n");
|
||||
}
|
||||
|
||||
static void frontend_dos_shutdown(bool unused)
|
||||
{
|
||||
(void)unused;
|
||||
(void)unused;
|
||||
}
|
||||
|
||||
static int frontend_dos_get_rating(void)
|
||||
{
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
enum frontend_architecture frontend_dos_get_architecture(void)
|
||||
{
|
||||
return FRONTEND_ARCH_X86;
|
||||
return FRONTEND_ARCH_X86;
|
||||
}
|
||||
|
||||
static void frontend_dos_get_env_settings(int *argc, char *argv[],
|
||||
void *data, void *params_data)
|
||||
{
|
||||
char base_path[PATH_MAX] = {0};
|
||||
int i;
|
||||
|
||||
retro_main_log_file_init("retrodos.txt", false);
|
||||
|
||||
strlcpy(base_path, argv[0], sizeof(base_path));
|
||||
char *slash = strrchr(base_path, '/');
|
||||
if (slash)
|
||||
*slash = '\0';
|
||||
slash = strrchr(base_path, '/');
|
||||
if (slash && strcasecmp(slash, "/cores"))
|
||||
*slash = '\0';
|
||||
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path,
|
||||
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path,
|
||||
"coreinfo", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path,
|
||||
"autoconf", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));
|
||||
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path,
|
||||
"assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
|
||||
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], base_path,
|
||||
"config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP],
|
||||
g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG],
|
||||
"remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], base_path,
|
||||
"playlist", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG], base_path,
|
||||
"recrdcfg", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT], base_path,
|
||||
"records", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], base_path,
|
||||
"database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path,
|
||||
"database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path,
|
||||
"shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path,
|
||||
"cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path,
|
||||
"overlay", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY]));
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], base_path,
|
||||
"layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT]));
|
||||
#endif
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], base_path,
|
||||
"download", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], base_path,
|
||||
"scrnshot", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], base_path,
|
||||
"thumbs", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]));
|
||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], base_path,
|
||||
"logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS]));
|
||||
|
||||
for (i = 0; i < DEFAULT_DIR_LAST; i++)
|
||||
{
|
||||
const char *dir_path = g_defaults.dirs[i];
|
||||
if (!string_is_empty(dir_path))
|
||||
path_mkdir(dir_path);
|
||||
}
|
||||
}
|
||||
|
||||
static void frontend_dos_exec(const char *path, bool should_load_game)
|
||||
{
|
||||
printf("Loading %s, %d\n", path, should_load_game);
|
||||
|
||||
char *newargv[] = { NULL, NULL };
|
||||
size_t len = strlen(path);
|
||||
|
||||
newargv[0] = (char*)malloc(len);
|
||||
|
||||
strlcpy(newargv[0], path, len);
|
||||
|
||||
execv(path, newargv);
|
||||
}
|
||||
|
||||
static void frontend_dos_exitspawn(char *s, size_t len, char *args)
|
||||
{
|
||||
bool should_load_content = false;
|
||||
|
||||
if (dos_fork_mode == FRONTEND_FORK_NONE)
|
||||
return;
|
||||
|
||||
switch (dos_fork_mode)
|
||||
{
|
||||
case FRONTEND_FORK_CORE_WITH_ARGS:
|
||||
should_load_content = true;
|
||||
break;
|
||||
case FRONTEND_FORK_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
frontend_dos_exec(s, should_load_content);
|
||||
}
|
||||
|
||||
static bool frontend_unix_set_fork(enum frontend_fork fork_mode)
|
||||
{
|
||||
switch (fork_mode)
|
||||
{
|
||||
case FRONTEND_FORK_CORE:
|
||||
RARCH_LOG("FRONTEND_FORK_CORE\n");
|
||||
unix_fork_mode = fork_mode;
|
||||
break;
|
||||
case FRONTEND_FORK_CORE_WITH_ARGS:
|
||||
RARCH_LOG("FRONTEND_FORK_CORE_WITH_ARGS\n");
|
||||
unix_fork_mode = fork_mode;
|
||||
break;
|
||||
case FRONTEND_FORK_RESTART:
|
||||
RARCH_LOG("FRONTEND_FORK_RESTART\n");
|
||||
unix_fork_mode = FRONTEND_FORK_CORE;
|
||||
|
||||
{
|
||||
char executable_path[PATH_MAX_LENGTH] = {0};
|
||||
fill_pathname_application_path(executable_path,
|
||||
sizeof(executable_path));
|
||||
path_set(RARCH_PATH_CORE, executable_path);
|
||||
}
|
||||
command_event(CMD_EVENT_QUIT, NULL);
|
||||
break;
|
||||
case FRONTEND_FORK_NONE:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
frontend_ctx_driver_t frontend_ctx_dos = {
|
||||
frontend_dos_get_env_settings,/* environment_get */
|
||||
frontend_dos_init, /* init */
|
||||
NULL, /* deinit */
|
||||
NULL, /* exitspawn */
|
||||
NULL, /* process_args */
|
||||
NULL, /* exec */
|
||||
NULL, /* set_fork */
|
||||
frontend_dos_shutdown, /* shutdown */
|
||||
NULL, /* get_name */
|
||||
NULL, /* get_os */
|
||||
frontend_dos_get_rating, /* get_rating */
|
||||
NULL, /* load_content */
|
||||
frontend_dos_get_architecture,/* get_architecture */
|
||||
NULL, /* get_powerstate */
|
||||
NULL, /* parse_drive_list */
|
||||
NULL, /* get_mem_total */
|
||||
NULL, /* get_mem_free */
|
||||
NULL, /* install_signal_handler */
|
||||
NULL, /* get_sighandler_state */
|
||||
NULL, /* set_sighandler_state */
|
||||
NULL, /* destroy_sighandler_state */
|
||||
NULL, /* attach_console */
|
||||
NULL, /* detach_console */
|
||||
NULL, /* watch_path_for_changes */
|
||||
NULL, /* check_for_path_changes */
|
||||
NULL, /* set_sustained_performance_mode */
|
||||
NULL, /* get_cpu_model_name */
|
||||
NULL, /* get_user_language */
|
||||
NULL, /* is_narrator_running */
|
||||
NULL, /* accessibility_speak */
|
||||
"dos",
|
||||
frontend_dos_get_env_settings,/* environment_get */
|
||||
frontend_dos_init, /* init */
|
||||
NULL, /* deinit */
|
||||
frontend_dos_exitspawn, /* exitspawn */
|
||||
NULL, /* process_args */
|
||||
frontend_dos_exec, /* exec */
|
||||
frontend_dos_set_fork, /* set_fork */
|
||||
frontend_dos_shutdown, /* shutdown */
|
||||
NULL, /* get_name */
|
||||
NULL, /* get_os */
|
||||
frontend_dos_get_rating, /* get_rating */
|
||||
NULL, /* load_content */
|
||||
frontend_dos_get_architecture,/* get_architecture */
|
||||
NULL, /* get_powerstate */
|
||||
NULL, /* parse_drive_list */
|
||||
NULL, /* get_mem_total */
|
||||
NULL, /* get_mem_free */
|
||||
NULL, /* install_signal_handler */
|
||||
NULL, /* get_sighandler_state */
|
||||
NULL, /* set_sighandler_state */
|
||||
NULL, /* destroy_sighandler_state */
|
||||
NULL, /* attach_console */
|
||||
NULL, /* detach_console */
|
||||
NULL, /* watch_path_for_changes */
|
||||
NULL, /* check_for_path_changes */
|
||||
NULL, /* set_sustained_performance_mode */
|
||||
NULL, /* get_cpu_model_name */
|
||||
NULL, /* get_user_language */
|
||||
NULL, /* is_narrator_running */
|
||||
NULL, /* accessibility_speak */
|
||||
"dos",
|
||||
};
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "../frontend_driver.h"
|
||||
|
||||
#include <io_common.h>
|
||||
#include <loadfile.h>
|
||||
#include <unistd.h>
|
||||
#include <sbv_patches.h>
|
||||
@ -27,12 +26,8 @@
|
||||
#include <libmtap.h>
|
||||
#include <audsrv.h>
|
||||
#include <libpad.h>
|
||||
#include <libcdvd-common.h>
|
||||
#include <cdvd_rpc.h>
|
||||
#include <fileXio_cdvd.h>
|
||||
#include <ps2_devices.h>
|
||||
#include <ps2_irx_variables.h>
|
||||
#include <ps2_descriptor.h>
|
||||
|
||||
char eboot_path[512];
|
||||
char user_path[512];
|
||||
@ -186,9 +181,6 @@ static void frontend_ps2_init(void *data)
|
||||
SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL);
|
||||
|
||||
/* CDVD */
|
||||
SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL);
|
||||
|
||||
if (mcInit(MC_TYPE_XMC)) {
|
||||
RARCH_ERR("mcInit library not initalizated\n");
|
||||
}
|
||||
@ -210,20 +202,6 @@ static void frontend_ps2_init(void *data)
|
||||
RARCH_ERR("mtapPortOpen library not initalizated\n");
|
||||
}
|
||||
|
||||
/* Initializes CDVD library */
|
||||
/* SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state. */
|
||||
sceCdInit(SCECdINoD);
|
||||
if (CDVD_Init() != 1) {
|
||||
RARCH_ERR("CDVD_Init library not initalizated\n");
|
||||
}
|
||||
|
||||
_init_ps2_io();
|
||||
|
||||
/* Prepare device */
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
bootDeviceID=getBootDeviceID(cwd);
|
||||
waitUntilDeviceIsReady(bootDeviceID);
|
||||
|
||||
#if defined(HAVE_FILE_LOGGER)
|
||||
retro_main_log_file_init("retroarch.log", false);
|
||||
verbosity_enable();
|
||||
@ -237,11 +215,8 @@ static void frontend_ps2_deinit(void *data)
|
||||
verbosity_disable();
|
||||
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
|
||||
#endif
|
||||
_free_ps2_io();
|
||||
CDVD_Stop();
|
||||
padEnd();
|
||||
audsrv_quit();
|
||||
fileXioExit();
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,6 @@ static void frontend_ps3_shutdown(bool unused)
|
||||
static void callback_sysutil_exit(uint64_t status,
|
||||
uint64_t param, void *userdata)
|
||||
{
|
||||
|
||||
(void)param;
|
||||
(void)userdata;
|
||||
(void)status;
|
||||
@ -107,7 +106,7 @@ static void callback_sysutil_exit(uint64_t status,
|
||||
}
|
||||
#endif
|
||||
|
||||
static void fill_derived_paths()
|
||||
static void fill_derived_paths(void)
|
||||
{
|
||||
strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY],
|
||||
g_defaults.dirs[DEFAULT_DIR_PORT],
|
||||
@ -276,7 +275,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
memset(&size, 0x00, sizeof(CellGameContentSize));
|
||||
|
||||
ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName);
|
||||
if(ret < 0)
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
RARCH_ERR("cellGameBootCheck() Error: 0x%x.\n", ret);
|
||||
}
|
||||
@ -299,7 +299,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");
|
||||
|
||||
@ -307,12 +307,10 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
|
||||
#ifdef HAVE_MULTIMAN
|
||||
if (multiman_detected)
|
||||
{
|
||||
use_app_path(content_info_path);
|
||||
}
|
||||
use_app_path(content_info_path);
|
||||
#endif
|
||||
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
RARCH_ERR("cellGameContentPermit() Error: 0x%x\n", ret);
|
||||
else
|
||||
{
|
||||
@ -468,7 +466,7 @@ static int frontend_ps3_exec_exitspawn(const char *path,
|
||||
ret = -1;
|
||||
#endif
|
||||
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n");
|
||||
sys_game_process_exitspawn(path, (const char** const)argv,
|
||||
|
@ -164,7 +164,7 @@ int system_property_get(const char *command,
|
||||
|
||||
while (!feof(pipe))
|
||||
{
|
||||
if (fgets(buffer, 128, pipe) != NULL)
|
||||
if (fgets(buffer, 128, pipe))
|
||||
{
|
||||
int curlen = strlen(buffer);
|
||||
|
||||
@ -306,11 +306,11 @@ static void* onSaveInstanceState(
|
||||
while (!android_app->stateSaved)
|
||||
scond_wait(android_app->cond, android_app->mutex);
|
||||
|
||||
if (android_app->savedState != NULL)
|
||||
if (android_app->savedState)
|
||||
{
|
||||
savedState = android_app->savedState;
|
||||
*outLen = android_app->savedStateSize;
|
||||
android_app->savedState = NULL;
|
||||
savedState = android_app->savedState;
|
||||
*outLen = android_app->savedStateSize;
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedStateSize = 0;
|
||||
}
|
||||
|
||||
@ -451,9 +451,9 @@ static struct android_app* android_app_create(ANativeActivity* activity,
|
||||
android_app->mutex = slock_new();
|
||||
android_app->cond = scond_new();
|
||||
|
||||
if (savedState != NULL)
|
||||
if (savedState)
|
||||
{
|
||||
android_app->savedState = malloc(savedStateSize);
|
||||
android_app->savedState = malloc(savedStateSize);
|
||||
android_app->savedStateSize = savedStateSize;
|
||||
memcpy(android_app->savedState, savedState, savedStateSize);
|
||||
}
|
||||
@ -1679,7 +1679,7 @@ static void frontend_unix_get_env(int *argc,
|
||||
/* For gamepad-like/console devices:
|
||||
*
|
||||
* - Explicitly disable input overlay by default
|
||||
* - Use XMB menu driver by default
|
||||
* - Use Ozone menu driver by default
|
||||
*
|
||||
* */
|
||||
|
||||
@ -1687,7 +1687,7 @@ static void frontend_unix_get_env(int *argc,
|
||||
{
|
||||
g_defaults.overlay.set = true;
|
||||
g_defaults.overlay.enable = false;
|
||||
strlcpy(g_defaults.settings.menu, "xmb",
|
||||
strlcpy(g_defaults.settings.menu, "ozone",
|
||||
sizeof(g_defaults.settings.menu));
|
||||
}
|
||||
#else
|
||||
@ -1783,10 +1783,10 @@ static void free_saved_state(struct android_app* android_app)
|
||||
{
|
||||
slock_lock(android_app->mutex);
|
||||
|
||||
if (android_app->savedState != NULL)
|
||||
if (android_app->savedState)
|
||||
{
|
||||
free(android_app->savedState);
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedStateSize = 0;
|
||||
}
|
||||
|
||||
@ -2414,7 +2414,7 @@ enum retro_language frontend_unix_get_user_language(void)
|
||||
#else
|
||||
char *envvar = getenv("LANG");
|
||||
|
||||
if (envvar != NULL)
|
||||
if (envvar)
|
||||
lang = rarch_get_language_from_iso(envvar);
|
||||
#endif
|
||||
#endif
|
||||
@ -2432,8 +2432,8 @@ static bool accessibility_speak_unix(int speed,
|
||||
{
|
||||
int pid;
|
||||
const char *language = get_user_language_iso639_1(true);
|
||||
char* voice_out = (char *)malloc(3+strlen(language));
|
||||
char* speed_out = (char *)malloc(3+3);
|
||||
char* voice_out = (char*)malloc(3+strlen(language));
|
||||
char* speed_out = (char*)malloc(3+3);
|
||||
const char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"};
|
||||
|
||||
if (speed < 1)
|
||||
@ -2482,7 +2482,7 @@ static bool accessibility_speak_unix(int speed,
|
||||
char* cmd[] = { (char*) "espeak", NULL, NULL, NULL, NULL};
|
||||
cmd[1] = voice_out;
|
||||
cmd[2] = speed_out;
|
||||
cmd[3] = (char *) speak_text;
|
||||
cmd[3] = (char*)speak_text;
|
||||
execvp("espeak", cmd);
|
||||
}
|
||||
return true;
|
||||
|
@ -61,6 +61,7 @@
|
||||
|
||||
#define WIIU_SD_PATH "sd:/"
|
||||
#define WIIU_USB_PATH "usb:/"
|
||||
#define WIIU_STORAGE_USB_PATH "storage_usb:/"
|
||||
|
||||
/**
|
||||
* The Wii U frontend driver, along with the main() method.
|
||||
@ -79,7 +80,8 @@ static bool exists(char *path)
|
||||
return (stat(path, &stat_buf) == 0);
|
||||
}
|
||||
|
||||
static void fix_asset_directory(void) {
|
||||
static void fix_asset_directory(void)
|
||||
{
|
||||
char src_path_buf[PATH_MAX_LENGTH] = {0};
|
||||
char dst_path_buf[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
@ -188,13 +190,16 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content)
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
||||
enum_idx,
|
||||
FILE_TYPE_DIRECTORY, 0, 0);
|
||||
menu_entries_append_enum(list, WIIU_STORAGE_USB_PATH,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
||||
enum_idx,
|
||||
FILE_TYPE_DIRECTORY, 0, 0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void frontend_wiiu_exec(const char *path, bool should_load_content)
|
||||
{
|
||||
|
||||
struct
|
||||
{
|
||||
u32 magic;
|
||||
|
@ -52,7 +52,7 @@
|
||||
#include "platform_win32.h"
|
||||
|
||||
#ifdef HAVE_NVDA
|
||||
#include "../../nvdaController.h"
|
||||
#include "../../nvda_controller.h"
|
||||
#endif
|
||||
|
||||
#ifndef SM_SERVERR2
|
||||
@ -616,15 +616,17 @@ static void frontend_win32_attach_console(void)
|
||||
bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE))
|
||||
== FILE_TYPE_UNKNOWN);
|
||||
|
||||
if(need_stdout || need_stderr)
|
||||
if (need_stdout || need_stderr)
|
||||
{
|
||||
if(!AttachConsole( ATTACH_PARENT_PROCESS))
|
||||
if (!AttachConsole( ATTACH_PARENT_PROCESS))
|
||||
AllocConsole();
|
||||
|
||||
SetConsoleTitle("Log Console");
|
||||
|
||||
if(need_stdout) freopen( "CONOUT$", "w", stdout );
|
||||
if(need_stderr) freopen( "CONOUT$", "w", stderr );
|
||||
if (need_stdout)
|
||||
freopen( "CONOUT$", "w", stdout );
|
||||
if (need_stderr)
|
||||
freopen( "CONOUT$", "w", stderr );
|
||||
|
||||
console_needs_free = true;
|
||||
}
|
||||
@ -637,7 +639,7 @@ static void frontend_win32_detach_console(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#ifdef _WIN32_WINNT_WINXP
|
||||
if(console_needs_free)
|
||||
if (console_needs_free)
|
||||
{
|
||||
/* we don't reconnect stdout/stderr to anything here,
|
||||
* because by definition, they weren't connected to
|
||||
@ -693,7 +695,7 @@ static void frontend_win32_respawn(char *s, size_t len, char *args)
|
||||
si.cb = sizeof(si);
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
if(!CreateProcess( executable_path, args,
|
||||
if (!CreateProcess( executable_path, args,
|
||||
NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
RARCH_LOG("Failed to restart RetroArch\n");
|
||||
@ -954,8 +956,6 @@ static bool accessibility_speak_windows(int speed,
|
||||
bool res = false;
|
||||
const char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"};
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
if (speed < 1)
|
||||
speed = 1;
|
||||
else if (speed > 10)
|
||||
@ -971,7 +971,7 @@ static bool accessibility_speak_windows(int speed,
|
||||
{
|
||||
if (strlen(language) > 0)
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text);
|
||||
"powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text);
|
||||
else
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", speeds[speed-1], (char*) speak_text);
|
||||
@ -984,7 +984,6 @@ static bool accessibility_speak_windows(int speed,
|
||||
return true;
|
||||
}
|
||||
pi_set = true;
|
||||
return true;
|
||||
}
|
||||
#ifdef HAVE_NVDA
|
||||
else if (USE_NVDA)
|
||||
@ -1000,23 +999,19 @@ static bool accessibility_speak_windows(int speed,
|
||||
RARCH_LOG("Error communicating with NVDA\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nvdaController_cancelSpeech();
|
||||
}
|
||||
|
||||
nvdaController_cancelSpeech();
|
||||
|
||||
if (USE_NVDA_BRAILLE)
|
||||
nvdaController_brailleMessage(wc);
|
||||
else
|
||||
{
|
||||
nvdaController_speakText(wc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SAPI
|
||||
else
|
||||
{
|
||||
HRESULT hr;
|
||||
/* stop the old voice if running */
|
||||
if (pVoice)
|
||||
{
|
||||
@ -1036,14 +1031,14 @@ static bool accessibility_speak_windows(int speed,
|
||||
{
|
||||
wchar_t wtext[1200];
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"<rate speed=\"%s\"/><volume level=\"80\"/><lang langid=\"%s\"/>%s", speeds[speed], langid, speak_text);
|
||||
"<rate speed=\"%s\"/><volume level=\"80\"/><lang langid=\"%s\"/>%s", speeds[speed], langid, speak_text);
|
||||
mbstowcs(wtext, speak_text, sizeof(wtext));
|
||||
|
||||
|
||||
hr = ISpVoice_Speak(pVoice, wtext, SPF_ASYNC /*SVSFlagsAsync*/, NULL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -218,6 +218,9 @@ bool frontend_driver_get_core_extension(char *s, size_t len)
|
||||
#elif defined(HAVE_LIBNX)
|
||||
strlcpy(s, "nro", len);
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strlcpy(s, "exe", len);
|
||||
return true;
|
||||
#elif defined(_3DS)
|
||||
if (envIsHomebrew())
|
||||
strlcpy(s, "3dsx", len);
|
||||
@ -264,6 +267,9 @@ bool frontend_driver_get_salamander_basename(char *s, size_t len)
|
||||
#elif defined(_3DS)
|
||||
strlcpy(s, "retroarch.core", len);
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strlcpy(s, "retrodos.exe", len);
|
||||
return true;
|
||||
#elif defined(SWITCH)
|
||||
strlcpy(s, "retroarch_switch.nro", len);
|
||||
return true;
|
||||
|
@ -93,7 +93,7 @@ bool dbus_screensaver_inhibit(void)
|
||||
reply = dbus_connection_send_with_reply_and_block(dbus_connection,
|
||||
msg, 300, NULL);
|
||||
|
||||
if (reply != NULL)
|
||||
if (reply)
|
||||
{
|
||||
if (!dbus_message_get_args(reply, NULL,
|
||||
DBUS_TYPE_UINT32, &dbus_screensaver_cookie,
|
||||
|
@ -443,6 +443,8 @@
|
||||
|
||||
- (void)_drawMenu:(video_frame_info_t *)video_info
|
||||
{
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!_menu.enabled)
|
||||
return;
|
||||
|
||||
@ -470,7 +472,7 @@
|
||||
{
|
||||
[rce pushDebugGroup:@"menu"];
|
||||
[_context resetRenderViewport:kFullscreenViewport];
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
[rce popDebugGroup];
|
||||
}
|
||||
#endif
|
||||
|
@ -52,10 +52,13 @@ static VkDevice cached_device_vk;
|
||||
static retro_vulkan_destroy_device_t cached_destroy_device_vk;
|
||||
static struct string_list *vulkan_gpu_list = NULL;
|
||||
|
||||
//#define WSI_HARDENING_TEST
|
||||
#if 0
|
||||
#define WSI_HARDENING_TEST
|
||||
#endif
|
||||
|
||||
#ifdef WSI_HARDENING_TEST
|
||||
static unsigned wsi_harden_counter = 0;
|
||||
static unsigned wsi_harden_counter2 = 0;
|
||||
static unsigned wsi_harden_counter = 0;
|
||||
static unsigned wsi_harden_counter2 = 0;
|
||||
|
||||
static void trigger_spurious_error_vkresult(VkResult *res)
|
||||
{
|
||||
@ -1978,9 +1981,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
|
||||
#else
|
||||
vulkan_library = dylib_load("libvulkan.so");
|
||||
if (!vulkan_library)
|
||||
{
|
||||
vulkan_library = dylib_load("libvulkan.so.1");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -117,97 +117,114 @@ extern bool dinput_handle_message(void *dinput, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
|
||||
typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM {
|
||||
UINT32 Numerator;
|
||||
UINT32 Denominator;
|
||||
typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM
|
||||
{
|
||||
UINT32 Numerator;
|
||||
UINT32 Denominator;
|
||||
} DISPLAYCONFIG_RATIONAL_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_2DREGION_CUSTOM {
|
||||
UINT32 cx;
|
||||
UINT32 cy;
|
||||
typedef struct DISPLAYCONFIG_2DREGION_CUSTOM
|
||||
{
|
||||
UINT32 cx;
|
||||
UINT32 cy;
|
||||
} DISPLAYCONFIG_2DREGION_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM {
|
||||
UINT64 pixelRate;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq;
|
||||
DISPLAYCONFIG_2DREGION_CUSTOM activeSize;
|
||||
DISPLAYCONFIG_2DREGION_CUSTOM totalSize;
|
||||
union {
|
||||
struct {
|
||||
UINT32 videoStandard :16;
|
||||
UINT32 vSyncFreqDivider :6;
|
||||
UINT32 reserved :10;
|
||||
} AdditionalSignalInfo;
|
||||
UINT32 videoStandard;
|
||||
} dummyunionname;
|
||||
UINT32 scanLineOrdering;
|
||||
typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM
|
||||
{
|
||||
UINT64 pixelRate;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq;
|
||||
DISPLAYCONFIG_2DREGION_CUSTOM activeSize;
|
||||
DISPLAYCONFIG_2DREGION_CUSTOM totalSize;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
UINT32 videoStandard :16;
|
||||
UINT32 vSyncFreqDivider :6;
|
||||
UINT32 reserved :10;
|
||||
} AdditionalSignalInfo;
|
||||
UINT32 videoStandard;
|
||||
} dummyunionname;
|
||||
UINT32 scanLineOrdering;
|
||||
} DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM {
|
||||
DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo;
|
||||
typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM
|
||||
{
|
||||
DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo;
|
||||
} DISPLAYCONFIG_TARGET_MODE_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM {
|
||||
LUID adapterId;
|
||||
UINT32 id;
|
||||
union {
|
||||
UINT32 modeInfoIdx;
|
||||
struct {
|
||||
UINT32 cloneGroupId :16;
|
||||
UINT32 sourceModeInfoIdx :16;
|
||||
} dummystructname;
|
||||
} dummyunionname;
|
||||
UINT32 statusFlags;
|
||||
typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM
|
||||
{
|
||||
LUID adapterId;
|
||||
UINT32 id;
|
||||
union
|
||||
{
|
||||
UINT32 modeInfoIdx;
|
||||
struct
|
||||
{
|
||||
UINT32 cloneGroupId :16;
|
||||
UINT32 sourceModeInfoIdx :16;
|
||||
} dummystructname;
|
||||
} dummyunionname;
|
||||
UINT32 statusFlags;
|
||||
} DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM {
|
||||
POINTL PathSourceSize;
|
||||
RECTL DesktopImageRegion;
|
||||
RECTL DesktopImageClip;
|
||||
typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM
|
||||
{
|
||||
POINTL PathSourceSize;
|
||||
RECTL DesktopImageRegion;
|
||||
RECTL DesktopImageClip;
|
||||
} DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM {
|
||||
UINT32 width;
|
||||
UINT32 height;
|
||||
UINT32 pixelFormat;
|
||||
POINTL position;
|
||||
typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM
|
||||
{
|
||||
UINT32 width;
|
||||
UINT32 height;
|
||||
UINT32 pixelFormat;
|
||||
POINTL position;
|
||||
} DISPLAYCONFIG_SOURCE_MODE_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM {
|
||||
UINT32 infoType;
|
||||
UINT32 id;
|
||||
LUID adapterId;
|
||||
union {
|
||||
DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode;
|
||||
DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode;
|
||||
DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo;
|
||||
} dummyunionname;
|
||||
typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM
|
||||
{
|
||||
UINT32 infoType;
|
||||
UINT32 id;
|
||||
LUID adapterId;
|
||||
union
|
||||
{
|
||||
DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode;
|
||||
DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode;
|
||||
DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo;
|
||||
} dummyunionname;
|
||||
} DISPLAYCONFIG_MODE_INFO_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM {
|
||||
LUID adapterId;
|
||||
UINT32 id;
|
||||
union {
|
||||
UINT32 modeInfoIdx;
|
||||
struct {
|
||||
UINT32 desktopModeInfoIdx :16;
|
||||
UINT32 targetModeInfoIdx :16;
|
||||
} dummystructname;
|
||||
} dummyunionname;
|
||||
UINT32 outputTechnology;
|
||||
UINT32 rotation;
|
||||
UINT32 scaling;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM refreshRate;
|
||||
UINT32 scanLineOrdering;
|
||||
BOOL targetAvailable;
|
||||
UINT32 statusFlags;
|
||||
typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM
|
||||
{
|
||||
LUID adapterId;
|
||||
UINT32 id;
|
||||
union
|
||||
{
|
||||
UINT32 modeInfoIdx;
|
||||
struct
|
||||
{
|
||||
UINT32 desktopModeInfoIdx :16;
|
||||
UINT32 targetModeInfoIdx :16;
|
||||
} dummystructname;
|
||||
} dummyunionname;
|
||||
UINT32 outputTechnology;
|
||||
UINT32 rotation;
|
||||
UINT32 scaling;
|
||||
DISPLAYCONFIG_RATIONAL_CUSTOM refreshRate;
|
||||
UINT32 scanLineOrdering;
|
||||
BOOL targetAvailable;
|
||||
UINT32 statusFlags;
|
||||
} DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM;
|
||||
|
||||
typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM {
|
||||
DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo;
|
||||
DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo;
|
||||
UINT32 flags;
|
||||
typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM
|
||||
{
|
||||
DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo;
|
||||
DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo;
|
||||
UINT32 flags;
|
||||
} DISPLAYCONFIG_PATH_INFO_CUSTOM;
|
||||
|
||||
typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO_CUSTOM*, UINT32*, DISPLAYCONFIG_MODE_INFO_CUSTOM*, UINT32*);
|
||||
@ -301,9 +318,9 @@ bool win32_taskbar_is_created(void)
|
||||
return taskbar_is_created;
|
||||
}
|
||||
|
||||
static INT_PTR_COMPAT CALLBACK PickCoreProc(
|
||||
static INT_PTR_COMPAT CALLBACK pick_core_proc(
|
||||
HWND hDlg, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
size_t list_size;
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
@ -528,7 +545,7 @@ bool win32_load_content_from_gui(const char *szFilename)
|
||||
|
||||
/* Pick one core that could be compatible, ew */
|
||||
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PICKCORE),
|
||||
main_window.hwnd, PickCoreProc, (LPARAM)NULL) == IDOK)
|
||||
main_window.hwnd, pick_core_proc, (LPARAM)NULL) == IDOK)
|
||||
{
|
||||
task_push_load_content_with_current_core_from_companion_ui(
|
||||
NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL);
|
||||
@ -822,7 +839,8 @@ static LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
|
||||
return 0L;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||
static LRESULT CALLBACK wnd_proc_common(
|
||||
bool *quit, HWND hwnd, UINT message,
|
||||
WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
bool keydown = true;
|
||||
@ -1028,7 +1046,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
|
||||
case WM_MOVE:
|
||||
case WM_SIZE:
|
||||
case WM_COMMAND:
|
||||
ret = WndProcCommon(&quit, hwnd, message, wparam, lparam);
|
||||
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
|
||||
if (quit)
|
||||
return ret;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
@ -1092,8 +1110,7 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message,
|
||||
case WM_MOVE:
|
||||
case WM_SIZE:
|
||||
case WM_COMMAND:
|
||||
ret = WndProcCommon(&quit,
|
||||
hwnd, message, wparam, lparam);
|
||||
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
|
||||
if (quit)
|
||||
return ret;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
@ -1195,7 +1212,7 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
|
||||
case WM_MOVE:
|
||||
case WM_SIZE:
|
||||
case WM_COMMAND:
|
||||
ret = WndProcCommon(&quit, hwnd, message, wparam, lparam);
|
||||
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
|
||||
if (quit)
|
||||
return ret;
|
||||
#if _WIN32_WINNT >= 0x0500 /* 2K */
|
||||
@ -1856,7 +1873,9 @@ bool win32_get_video_output(DEVMODE *dm, int mode, size_t len)
|
||||
memset(dm, 0, len);
|
||||
dm->dmSize = len;
|
||||
|
||||
if (win32_internal_get_video_output((mode == -1) ? ENUM_CURRENT_SETTINGS : mode,
|
||||
if (win32_internal_get_video_output((mode == -1)
|
||||
? ENUM_CURRENT_SETTINGS
|
||||
: mode,
|
||||
dm) == 0)
|
||||
return false;
|
||||
return true;
|
||||
|
@ -43,24 +43,27 @@
|
||||
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
|
||||
#define HAS_TASKBAR_EXT
|
||||
|
||||
static ITaskbarList3 *g_taskbarList = NULL;
|
||||
|
||||
/* MSVC really doesn't want CINTERFACE to be used with shobjidl for some reason, but since we use C++ mode,
|
||||
* we need a workaround... so use the names of the COBJMACROS functions instead. */
|
||||
#if defined(__cplusplus) && !defined(CINTERFACE)
|
||||
#define ITaskbarList3_HrInit(x) g_taskbarList->HrInit()
|
||||
#define ITaskbarList3_Release(x) g_taskbarList->Release()
|
||||
#define ITaskbarList3_SetProgressState(a, b, c) g_taskbarList->SetProgressState(b, c)
|
||||
#define ITaskbarList3_SetProgressValue(a, b, c, d) g_taskbarList->SetProgressValue(b, c, d)
|
||||
#define ITaskbarList3_HrInit(x) (x)->HrInit()
|
||||
#define ITaskbarList3_Release(x) (x)->Release()
|
||||
#define ITaskbarList3_SetProgressState(a, b, c) (a)->SetProgressState(b, c)
|
||||
#define ITaskbarList3_SetProgressValue(a, b, c, d) (a)->SetProgressValue(b, c, d)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned opacity;
|
||||
int progress;
|
||||
bool decorations;
|
||||
int progress;
|
||||
int crt_center;
|
||||
unsigned opacity;
|
||||
unsigned orig_width;
|
||||
unsigned orig_height;
|
||||
unsigned orig_refresh;
|
||||
ITaskbarList3 *taskbar_list;
|
||||
} dispserv_win32_t;
|
||||
|
||||
/*
|
||||
@ -71,12 +74,7 @@ typedef struct
|
||||
be received by your application before it calls any ITaskbarList3 method.
|
||||
*/
|
||||
|
||||
static unsigned win32_orig_width = 0;
|
||||
static unsigned win32_orig_height = 0;
|
||||
static unsigned win32_orig_refresh = 0;
|
||||
static int crt_center = 0;
|
||||
|
||||
static void* win32_display_server_init(void)
|
||||
static void *win32_display_server_init(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
dispserv_win32_t *dispserv = (dispserv_win32_t*)calloc(1, sizeof(*dispserv));
|
||||
@ -90,23 +88,25 @@ static void* win32_display_server_init(void)
|
||||
#ifdef __cplusplus
|
||||
/* When compiling in C++ mode, GUIDs are references instead of pointers */
|
||||
hr = CoCreateInstance(CLSID_TaskbarList, NULL,
|
||||
CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&g_taskbarList);
|
||||
CLSCTX_INPROC_SERVER, IID_ITaskbarList3,
|
||||
(void**)&dispserv->taskbar_list);
|
||||
#else
|
||||
/* Mingw GUIDs are pointers instead of references since we're in C mode */
|
||||
hr = CoCreateInstance(&CLSID_TaskbarList, NULL,
|
||||
CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (void**)&g_taskbarList);
|
||||
CLSCTX_INPROC_SERVER, &IID_ITaskbarList3,
|
||||
(void**)&dispserv->taskbar_list);
|
||||
#endif
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = ITaskbarList3_HrInit(g_taskbarList);
|
||||
hr = ITaskbarList3_HrInit(dispserv->taskbar_list);
|
||||
|
||||
if (!SUCCEEDED(hr))
|
||||
RARCH_ERR("[dispserv]: HrInit of ITaskbarList3 failed.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_taskbarList = NULL;
|
||||
dispserv->taskbar_list = NULL;
|
||||
RARCH_ERR("[dispserv]: CoCreateInstance of ITaskbarList3 failed.\n");
|
||||
}
|
||||
#endif
|
||||
@ -118,15 +118,19 @@ static void win32_display_server_destroy(void *data)
|
||||
{
|
||||
dispserv_win32_t *dispserv = (dispserv_win32_t*)data;
|
||||
|
||||
if (win32_orig_width > 0 && win32_orig_height > 0)
|
||||
video_display_server_set_resolution(win32_orig_width, win32_orig_height,
|
||||
win32_orig_refresh, (float)win32_orig_refresh, crt_center, 0, 0);
|
||||
if (dispserv->orig_width > 0 && dispserv->orig_height > 0)
|
||||
video_display_server_set_resolution(
|
||||
dispserv->orig_width,
|
||||
dispserv->orig_height,
|
||||
dispserv->orig_refresh,
|
||||
(float)dispserv->orig_refresh,
|
||||
dispserv->crt_center, 0, 0);
|
||||
|
||||
#ifdef HAS_TASKBAR_EXT
|
||||
if (g_taskbarList)
|
||||
if (dispserv->taskbar_list)
|
||||
{
|
||||
ITaskbarList3_Release(g_taskbarList);
|
||||
g_taskbarList = NULL;
|
||||
ITaskbarList3_Release(dispserv->taskbar_list);
|
||||
dispserv->taskbar_list = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -170,29 +174,29 @@ static bool win32_display_server_set_window_progress(void *data, int progress, b
|
||||
serv->progress = progress;
|
||||
|
||||
#ifdef HAS_TASKBAR_EXT
|
||||
if (!g_taskbarList || !win32_taskbar_is_created())
|
||||
if (!serv->taskbar_list || !win32_taskbar_is_created())
|
||||
return false;
|
||||
|
||||
if (progress == -1)
|
||||
{
|
||||
if (ITaskbarList3_SetProgressState(
|
||||
g_taskbarList, hwnd, TBPF_INDETERMINATE) != S_OK)
|
||||
serv->taskbar_list, hwnd, TBPF_INDETERMINATE) != S_OK)
|
||||
return false;
|
||||
}
|
||||
else if (finished)
|
||||
{
|
||||
if (ITaskbarList3_SetProgressState(
|
||||
g_taskbarList, hwnd, TBPF_NOPROGRESS) != S_OK)
|
||||
serv->taskbar_list, hwnd, TBPF_NOPROGRESS) != S_OK)
|
||||
return false;
|
||||
}
|
||||
else if (progress >= 0)
|
||||
{
|
||||
if (ITaskbarList3_SetProgressState(
|
||||
g_taskbarList, hwnd, TBPF_NORMAL) != S_OK)
|
||||
serv->taskbar_list, hwnd, TBPF_NORMAL) != S_OK)
|
||||
return false;
|
||||
|
||||
if (ITaskbarList3_SetProgressValue(
|
||||
g_taskbarList, hwnd, progress, 100) != S_OK)
|
||||
serv->taskbar_list, hwnd, progress, 100) != S_OK)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -227,11 +231,11 @@ static bool win32_display_server_set_resolution(void *data,
|
||||
|
||||
win32_get_video_output(&curDevmode, -1, sizeof(curDevmode));
|
||||
|
||||
if (win32_orig_width == 0)
|
||||
win32_orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||
win32_orig_refresh = curDevmode.dmDisplayFrequency;
|
||||
if (win32_orig_height == 0)
|
||||
win32_orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
if (serv->orig_width == 0)
|
||||
serv->orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||
serv->orig_refresh = curDevmode.dmDisplayFrequency;
|
||||
if (serv->orig_height == 0)
|
||||
serv->orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
/* Used to stop super resolution bug */
|
||||
if (width == curDevmode.dmPelsWidth)
|
||||
|
@ -141,7 +141,7 @@ static bool caca_gfx_frame(void *data, const void *frame,
|
||||
caca_clear_canvas(caca->cv);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
if (msg)
|
||||
|
@ -546,7 +546,7 @@ static bool ctr_frame(void* data, const void* frame,
|
||||
int custom_vp_y = video_info->custom_vp_y;
|
||||
unsigned custom_vp_width = video_info->custom_vp_width;
|
||||
unsigned custom_vp_height = video_info->custom_vp_height;
|
||||
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!width || !height || !settings)
|
||||
{
|
||||
@ -873,9 +873,8 @@ static bool ctr_frame(void* data, const void* frame,
|
||||
}
|
||||
|
||||
ctr->msg_rendering_enabled = true;
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
ctr->msg_rendering_enabled = false;
|
||||
|
||||
}
|
||||
else if (statistics_show)
|
||||
{
|
||||
|
@ -1211,6 +1211,7 @@ static bool d3d10_gfx_frame(
|
||||
*osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
const char *stat_text = video_info->stat_text;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (d3d10->resize_chain)
|
||||
{
|
||||
@ -1471,7 +1472,7 @@ static bool d3d10_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (d3d10->menu.enabled)
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
if (statistics_show)
|
||||
|
@ -1290,6 +1290,7 @@ static bool d3d11_gfx_frame(
|
||||
unsigned video_height = video_info->height;
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (d3d11->resize_chain)
|
||||
{
|
||||
@ -1544,7 +1545,7 @@ static bool d3d11_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (d3d11->menu.enabled)
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
if (statistics_show)
|
||||
|
@ -1174,6 +1174,7 @@ static bool d3d12_gfx_frame(
|
||||
unsigned video_height = video_info->height;
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
|
||||
d3d12_gfx_sync(d3d12);
|
||||
@ -1513,7 +1514,7 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (d3d12->menu.enabled)
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
if (statistics_show)
|
||||
|
@ -1489,6 +1489,7 @@ static bool d3d8_frame(void *data, const void *frame,
|
||||
const char *stat_text = video_info->stat_text;
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
bool black_frame_insertion = video_info->black_frame_insertion;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
(void)i;
|
||||
|
||||
@ -1556,7 +1557,7 @@ static bool d3d8_frame(void *data, const void *frame,
|
||||
d3d8_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex));
|
||||
|
||||
d3d8_set_viewports(d3d->dev, &screen_vp);
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
}
|
||||
else if (statistics_show)
|
||||
{
|
||||
|
@ -645,8 +645,8 @@ void d3d9_make_d3dpp(void *data,
|
||||
#ifdef _XBOX
|
||||
/* TODO/FIXME - get rid of global state dependencies. */
|
||||
global_t *global = global_get_ptr();
|
||||
bool gamma_enable = global ?
|
||||
global->console.screen.gamma_correction : false;
|
||||
int gamma_enable = global ?
|
||||
global->console.screen.gamma_correction : 0;
|
||||
#endif
|
||||
bool windowed_enable = d3d9_is_windowed_enable(info->fullscreen);
|
||||
|
||||
@ -1532,7 +1532,7 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
const char *stat_text = video_info->stat_text;
|
||||
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!frame)
|
||||
return true;
|
||||
@ -1602,7 +1602,7 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
d3d9_set_stream_source(d3d->dev, 0, (LPDIRECT3DVERTEXBUFFER9)d3d->menu_display.buffer, 0, sizeof(Vertex));
|
||||
|
||||
d3d9_set_viewports(d3d->dev, &screen_vp);
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
}
|
||||
else if (statistics_show)
|
||||
{
|
||||
|
@ -439,6 +439,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
struct dispmanx_video *_dispvars = data;
|
||||
float aspect = video_driver_get_aspect_ratio();
|
||||
unsigned max_swapchain_images = video_info->max_swapchain_images;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!frame)
|
||||
return true;
|
||||
@ -456,7 +457,7 @@ 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)
|
||||
dispmanx_surface_free(_dispvars, &_dispvars->main_surface);
|
||||
|
||||
/* Internal resolution or ratio has changed, so we need
|
||||
@ -480,7 +481,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
/* Update main surface: locate free page, blit and flip. */
|
||||
|
@ -757,6 +757,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
video_frame_info_t *video_info)
|
||||
{
|
||||
struct drm_video *_drmvars = data;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if ( ( width != _drmvars->core_width) ||
|
||||
(height != _drmvars->core_height))
|
||||
@ -769,7 +770,7 @@ 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)
|
||||
drm_surface_free(_drmvars, &_drmvars->main_surface);
|
||||
|
||||
/* We need to recreate the main surface and it's pages (buffers). */
|
||||
@ -790,7 +791,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
/* Update main surface: locate free page, blit and flip. */
|
||||
|
@ -247,7 +247,7 @@ static void exynos_clean_up_pages(struct exynos_page *p, unsigned cnt)
|
||||
|
||||
for (i = 0; i < cnt; ++i)
|
||||
{
|
||||
if (p[i].bo != NULL)
|
||||
if (p[i].bo)
|
||||
{
|
||||
if (p[i].buf_id != 0)
|
||||
drmModeRmFB(p[i].buf_id, p[i].bo->handle);
|
||||
@ -902,10 +902,13 @@ static void exynos_set_fake_blit(struct exynos_data *pdata)
|
||||
pdata->pages[i].clear = true;
|
||||
}
|
||||
|
||||
static int exynos_blit_frame(struct exynos_data *pdata, const void *frame,
|
||||
unsigned src_pitch)
|
||||
static int exynos_blit_frame(
|
||||
struct exynos_data *pdata,
|
||||
const void *frame,
|
||||
unsigned src_pitch)
|
||||
{
|
||||
const enum exynos_buffer_type buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type;
|
||||
const enum exynos_buffer_type
|
||||
buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type;
|
||||
const unsigned size = src_pitch * pdata->blit_params[5];
|
||||
struct g2d_image *src = pdata->src[EXYNOS_IMAGE_FRAME];
|
||||
|
||||
@ -1268,7 +1271,7 @@ static void exynos_gfx_free(void *data)
|
||||
|
||||
free(pdata);
|
||||
|
||||
if (vid->font != NULL && vid->font_driver != NULL)
|
||||
if (vid->font && vid->font_driver)
|
||||
vid->font_driver->free(vid->font);
|
||||
|
||||
free(vid);
|
||||
@ -1280,12 +1283,13 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
{
|
||||
struct exynos_video *vid = data;
|
||||
struct exynos_page *page = NULL;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
/* Check if neither menu nor core framebuffer is to be displayed. */
|
||||
if (!vid->menu_active && !frame)
|
||||
return true;
|
||||
|
||||
if (frame != NULL)
|
||||
if (frame)
|
||||
{
|
||||
if (width != vid->width || height != vid->height)
|
||||
{
|
||||
@ -1315,15 +1319,16 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
if (!page)
|
||||
page = exynos_free_page(vid->data);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (vid->menu_active)
|
||||
{
|
||||
if (exynos_blend_menu(vid->data, vid->menu_rotation) != 0)
|
||||
goto fail;
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
#endif
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
}
|
||||
else if (video_info->statistics_show)
|
||||
else
|
||||
#endif
|
||||
if (video_info->statistics_show)
|
||||
{
|
||||
struct font_params *osd_params = video_info ?
|
||||
(struct font_params*)&video_info->osd_stat_params : NULL;
|
||||
|
@ -209,12 +209,13 @@ static bool fpga_gfx_frame(void *data, const void *frame,
|
||||
bool draw = true;
|
||||
fpga_t *fpga = (fpga_t*)data;
|
||||
unsigned bits = fpga->video_bits;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!frame || !frame_width || !frame_height)
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
if ( fpga->video_width != frame_width ||
|
||||
|
@ -66,13 +66,12 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
int height;
|
||||
int width;
|
||||
int id;
|
||||
uint32_t *ptr;
|
||||
// Internal stuff
|
||||
uint32_t offset;
|
||||
int height;
|
||||
int width;
|
||||
int id;
|
||||
uint32_t *ptr;
|
||||
/* Internal stuff */
|
||||
uint32_t offset;
|
||||
} rsxBuffer;
|
||||
|
||||
typedef struct
|
||||
@ -91,26 +90,25 @@ typedef struct
|
||||
|
||||
typedef struct gcm_video
|
||||
{
|
||||
video_viewport_t vp;
|
||||
rsxBuffer buffers[MAX_BUFFERS];
|
||||
rsxBuffer menuBuffers[MAX_BUFFERS];
|
||||
int currentBuffer, menuBuffer;
|
||||
gcmContextData *context;
|
||||
u16 width;
|
||||
u16 height;
|
||||
bool menu_frame_enable;
|
||||
bool rgb32;
|
||||
bool vsync;
|
||||
u32 depth_pitch;
|
||||
u32 depth_offset;
|
||||
u32 *depth_buffer;
|
||||
video_viewport_t vp;
|
||||
rsxBuffer buffers[MAX_BUFFERS];
|
||||
rsxBuffer menuBuffers[MAX_BUFFERS];
|
||||
int currentBuffer, menuBuffer;
|
||||
gcmContextData *context;
|
||||
u16 width;
|
||||
u16 height;
|
||||
bool menu_frame_enable;
|
||||
bool rgb32;
|
||||
bool vsync;
|
||||
u32 depth_pitch;
|
||||
u32 depth_offset;
|
||||
u32 *depth_buffer;
|
||||
|
||||
bool smooth;
|
||||
unsigned rotation;
|
||||
bool keep_aspect;
|
||||
bool should_resize;
|
||||
bool msg_rendering_enabled;
|
||||
|
||||
} gcm_video_t;
|
||||
|
||||
#ifndef HAVE_THREADS
|
||||
@ -121,136 +119,138 @@ static bool gcm_tasks_finder(retro_task_t *task,void *userdata)
|
||||
task_finder_data_t gcm_tasks_finder_data = {gcm_tasks_finder, NULL};
|
||||
#endif
|
||||
|
||||
static int
|
||||
makeBuffer (rsxBuffer * buffer, u16 width, u16 height, int id)
|
||||
static int gcm_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id)
|
||||
{
|
||||
int depth = sizeof(u32);
|
||||
int pitch = depth * width;
|
||||
int size = depth * width * height;
|
||||
int depth = sizeof(u32);
|
||||
int pitch = depth * width;
|
||||
int size = depth * width * height;
|
||||
|
||||
buffer->ptr = (uint32_t*) rsxMemalign (64, size);
|
||||
if (buffer->ptr == NULL)
|
||||
goto error;
|
||||
buffer->ptr = (uint32_t*)rsxMemalign (64, size);
|
||||
if (!buffer->ptr)
|
||||
goto error;
|
||||
|
||||
if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0)
|
||||
goto error;
|
||||
if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0)
|
||||
goto error;
|
||||
|
||||
/* Register the display buffer with the RSX */
|
||||
if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0)
|
||||
goto error;
|
||||
/* Register the display buffer with the RSX */
|
||||
if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0)
|
||||
goto error;
|
||||
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
buffer->id = id;
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
buffer->id = id;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
if (buffer->ptr != NULL)
|
||||
rsxFree (buffer->ptr);
|
||||
error:
|
||||
if (buffer->ptr)
|
||||
rsxFree (buffer->ptr);
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
flip (gcmContextData *context, s32 buffer)
|
||||
static int gcm_flip(gcmContextData *context, s32 buffer)
|
||||
{
|
||||
if (gcmSetFlip (context, buffer) == 0) {
|
||||
rsxFlushBuffer (context);
|
||||
// Prevent the RSX from continuing until the flip has finished.
|
||||
gcmSetWaitFlip (context);
|
||||
if (gcmSetFlip(context, buffer) == 0)
|
||||
{
|
||||
rsxFlushBuffer (context);
|
||||
/* Prevent the RSX from continuing until the flip has finished. */
|
||||
gcmSetWaitFlip (context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define GCM_LABEL_INDEX 255
|
||||
|
||||
static void waitRSXIdle(gcmContextData *context);
|
||||
static void gcm_wait_rsx_idle(gcmContextData *context);
|
||||
|
||||
static void
|
||||
waitFlip ()
|
||||
static void gcm_wait_flip(void)
|
||||
{
|
||||
while (gcmGetFlipStatus () != 0)
|
||||
while (gcmGetFlipStatus() != 0)
|
||||
usleep (200); /* Sleep, to not stress the cpu. */
|
||||
gcmResetFlipStatus ();
|
||||
gcmResetFlipStatus();
|
||||
}
|
||||
|
||||
static gcmContextData *
|
||||
initScreen (gcm_video_t* gcm)
|
||||
static gcmContextData *gcm_init_screen(gcm_video_t* gcm)
|
||||
{
|
||||
gcmContextData *context = NULL; /* Context to keep track of the RSX buffer. */
|
||||
static gcmContextData *saved_context = NULL;
|
||||
videoState state;
|
||||
videoConfiguration vconfig;
|
||||
videoResolution res; /* Screen Resolution */
|
||||
/* Context to keep track of the RSX buffer. */
|
||||
gcmContextData *context = NULL;
|
||||
static gcmContextData *saved_context = NULL;
|
||||
videoState state;
|
||||
videoConfiguration vconfig;
|
||||
videoResolution res; /* Screen Resolution */
|
||||
|
||||
if (!saved_context) {
|
||||
/* Allocate a 1Mb buffer, alligned to a 1Mb boundary
|
||||
* to be our shared IO memory with the RSX. */
|
||||
void *host_addr = memalign (1024*1024, HOST_SIZE);
|
||||
if (!saved_context)
|
||||
{
|
||||
/* Allocate a 1Mb buffer, alligned to a 1Mb boundary
|
||||
* to be our shared IO memory with the RSX. */
|
||||
void *host_addr = memalign (1024*1024, HOST_SIZE);
|
||||
|
||||
if (host_addr == NULL)
|
||||
if (!host_addr)
|
||||
goto error;
|
||||
|
||||
/* Initialise Reality, which sets up the
|
||||
* command buffer and shared I/O memory */
|
||||
context = rsxInit (CB_SIZE, HOST_SIZE, host_addr);
|
||||
if (!context)
|
||||
goto error;
|
||||
saved_context = context;
|
||||
}
|
||||
else
|
||||
context = saved_context;
|
||||
|
||||
/* Get the state of the display */
|
||||
if (videoGetState (0, 0, &state) != 0)
|
||||
goto error;
|
||||
|
||||
/* Initilise Reality, which sets up the command buffer and shared IO memory */
|
||||
context = rsxInit (CB_SIZE, HOST_SIZE, host_addr);
|
||||
if (context == NULL)
|
||||
/* Make sure display is enabled */
|
||||
if (state.state != 0)
|
||||
goto error;
|
||||
saved_context = context;
|
||||
} else {
|
||||
context = saved_context;
|
||||
}
|
||||
|
||||
/* Get the state of the display */
|
||||
if (videoGetState (0, 0, &state) != 0)
|
||||
goto error;
|
||||
/* Get the current resolution */
|
||||
if (videoGetResolution (state.displayMode.resolution, &res) != 0)
|
||||
goto error;
|
||||
|
||||
/* Make sure display is enabled */
|
||||
if (state.state != 0)
|
||||
goto error;
|
||||
/* Configure the buffer format to xRGB */
|
||||
memset (&vconfig, 0, sizeof(videoConfiguration));
|
||||
vconfig.resolution = state.displayMode.resolution;
|
||||
vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
|
||||
vconfig.pitch = res.width * sizeof(u32);
|
||||
vconfig.aspect = state.displayMode.aspect;
|
||||
|
||||
/* Get the current resolution */
|
||||
if (videoGetResolution (state.displayMode.resolution, &res) != 0)
|
||||
goto error;
|
||||
gcm->width = res.width;
|
||||
gcm->height = res.height;
|
||||
|
||||
/* Configure the buffer format to xRGB */
|
||||
memset (&vconfig, 0, sizeof(videoConfiguration));
|
||||
vconfig.resolution = state.displayMode.resolution;
|
||||
vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
|
||||
vconfig.pitch = res.width * sizeof(u32);
|
||||
vconfig.aspect = state.displayMode.aspect;
|
||||
gcm_wait_rsx_idle(context);
|
||||
|
||||
gcm->width = res.width;
|
||||
gcm->height = res.height;
|
||||
if (videoConfigure (0, &vconfig, NULL, 0) != 0)
|
||||
goto error;
|
||||
|
||||
waitRSXIdle(context);
|
||||
if (videoGetState (0, 0, &state) != 0)
|
||||
goto error;
|
||||
|
||||
if (videoConfigure (0, &vconfig, NULL, 0) != 0)
|
||||
goto error;
|
||||
gcmSetFlipMode (GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */
|
||||
|
||||
if (videoGetState (0, 0, &state) != 0)
|
||||
goto error;
|
||||
gcm->depth_pitch = res.width * sizeof(u32);
|
||||
gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)* 2);
|
||||
rsxAddressToOffset (gcm->depth_buffer, &gcm->depth_offset);
|
||||
|
||||
gcmSetFlipMode (GCM_FLIP_VSYNC); // Wait for VSYNC to flip
|
||||
gcmResetFlipStatus();
|
||||
|
||||
gcm->depth_pitch = res.width * sizeof(u32);
|
||||
gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)* 2);
|
||||
rsxAddressToOffset (gcm->depth_buffer, &gcm->depth_offset);
|
||||
return context;
|
||||
|
||||
gcmResetFlipStatus();
|
||||
error:
|
||||
#if 0
|
||||
if (context)
|
||||
rsxFinish (context, 0);
|
||||
|
||||
return context;
|
||||
if (gcm->host_addr)
|
||||
free (gcm->host_addr);
|
||||
#endif
|
||||
|
||||
error:
|
||||
// if (context)
|
||||
// rsxFinish (context, 0);
|
||||
|
||||
// if (gcm->host_addr)
|
||||
// free (gcm->host_addr);
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -267,8 +267,7 @@ waitFinish(gcmContextData *context, u32 sLabelVal)
|
||||
sLabelVal++;
|
||||
}
|
||||
|
||||
static void
|
||||
waitRSXIdle(gcmContextData *context)
|
||||
static void gcm_wait_rsx_idle(gcmContextData *context)
|
||||
{
|
||||
u32 sLabelVal = 1;
|
||||
|
||||
@ -283,7 +282,7 @@ waitRSXIdle(gcmContextData *context)
|
||||
static void* gcm_init(const video_info_t* video,
|
||||
input_driver_t** input, void** input_data)
|
||||
{
|
||||
RARCH_LOG("Reached gcm_init\n");
|
||||
int i;
|
||||
gcm_video_t* gcm = malloc(sizeof(gcm_video_t));
|
||||
|
||||
if (!gcm)
|
||||
@ -291,17 +290,15 @@ static void* gcm_init(const video_info_t* video,
|
||||
|
||||
memset(gcm, 0, sizeof(gcm_video_t));
|
||||
|
||||
int i;
|
||||
|
||||
gcm->context = initScreen (gcm);
|
||||
gcm->context = gcm_init_screen(gcm);
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
makeBuffer( &gcm->buffers[i], gcm->width, gcm->height, i);
|
||||
gcm_make_buffer(&gcm->buffers[i], gcm->width, gcm->height, i);
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
makeBuffer( &gcm->menuBuffers[i], gcm->width, gcm->height, i + MAX_BUFFERS);
|
||||
gcm_make_buffer(&gcm->menuBuffers[i], gcm->width, gcm->height, i + MAX_BUFFERS);
|
||||
|
||||
flip(gcm->context, MAX_BUFFERS - 1);
|
||||
gcm_flip(gcm->context, MAX_BUFFERS - 1);
|
||||
|
||||
gcm->vp.x = 0;
|
||||
gcm->vp.y = 0;
|
||||
@ -318,41 +315,44 @@ static void* gcm_init(const video_info_t* video,
|
||||
*input = ps3input ? &input_ps3 : NULL;
|
||||
*input_data = ps3input;
|
||||
}
|
||||
RARCH_LOG("gcm_init done\n");
|
||||
|
||||
return gcm;
|
||||
}
|
||||
|
||||
static void black (uint32_t *dst, uint32_t *dst_end, size_t sz)
|
||||
static void gcm_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz)
|
||||
{
|
||||
if (sz > dst_end - dst)
|
||||
sz = dst_end - dst;
|
||||
memset (dst, 0, sz * 4);
|
||||
}
|
||||
|
||||
static void blitBuffer(rsxBuffer *buffer, const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, int rgb32, bool do_scaling)
|
||||
static void gcm_blit_buffer(
|
||||
rsxBuffer *buffer, const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, int rgb32, bool do_scaling)
|
||||
{
|
||||
if (width > buffer->width)
|
||||
int scale = 1, xofs = 0, yofs = 0;
|
||||
if (width > buffer->width)
|
||||
width = buffer->width;
|
||||
if (height > buffer->height)
|
||||
height = buffer->height;
|
||||
int scale = 1, xofs = 0, yofs = 0;
|
||||
|
||||
if (do_scaling) {
|
||||
scale = buffer->width / width;
|
||||
if (scale > buffer->height / height)
|
||||
scale = buffer->height / height;
|
||||
if (scale >= 10)
|
||||
scale = 10;
|
||||
if (scale >= 1) {
|
||||
xofs = (buffer->width - width * scale) / 2;
|
||||
yofs = (buffer->height - height * scale) / 2;
|
||||
} else
|
||||
scale = 1;
|
||||
if (do_scaling)
|
||||
{
|
||||
scale = buffer->width / width;
|
||||
if (scale > buffer->height / height)
|
||||
scale = buffer->height / height;
|
||||
if (scale >= 10)
|
||||
scale = 10;
|
||||
if (scale >= 1)
|
||||
{
|
||||
xofs = (buffer->width - width * scale) / 2;
|
||||
yofs = (buffer->height - height * scale) / 2;
|
||||
}
|
||||
else
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
// TODO: let rsx do the copy
|
||||
/* TODO: let rsx do the copy */
|
||||
int i;
|
||||
int pre_clean = xofs + buffer->width * yofs;
|
||||
uint32_t *dst = buffer->ptr;
|
||||
@ -361,83 +361,94 @@ static void blitBuffer(rsxBuffer *buffer, const void *frame, unsigned width,
|
||||
memset (dst, 0, pre_clean * 4);
|
||||
dst += pre_clean;
|
||||
|
||||
if (scale == 1) {
|
||||
if (rgb32) {
|
||||
const uint8_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
memcpy(dst, src, width * 4);
|
||||
black(dst + width, dst_end, buffer->width - width);
|
||||
dst += buffer->width;
|
||||
src += pitch;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++, dst++) {
|
||||
u16 rgb565 = *src;
|
||||
u8 r = ((rgb565 >> 8) & 0xf8);
|
||||
u8 g = ((rgb565 >> 3) & 0xfc);
|
||||
u8 b = ((rgb565 << 3) & 0xfc);
|
||||
*dst = (r<<16) | (g<<8) | b;
|
||||
}
|
||||
black(dst, dst_end, buffer->width - width);
|
||||
if (scale == 1)
|
||||
{
|
||||
if (rgb32)
|
||||
{
|
||||
const uint8_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
memcpy(dst, src, width * 4);
|
||||
gcm_fill_black(dst + width, dst_end, buffer->width - width);
|
||||
dst += buffer->width;
|
||||
src += pitch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint16_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++, dst++)
|
||||
{
|
||||
u16 rgb565 = *src;
|
||||
u8 r = ((rgb565 >> 8) & 0xf8);
|
||||
u8 g = ((rgb565 >> 3) & 0xfc);
|
||||
u8 b = ((rgb565 << 3) & 0xfc);
|
||||
*dst = (r<<16) | (g<<8) | b;
|
||||
}
|
||||
gcm_fill_black(dst, dst_end, buffer->width - width);
|
||||
|
||||
dst += buffer->width - width;
|
||||
src += pitch / 2 - width;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (rgb32) {
|
||||
const uint32_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++) {
|
||||
u32 c = *src;
|
||||
for (int k = 0; k < scale; k++, dst++)
|
||||
for (int l = 0; l < scale; l++)
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
dst += buffer->width - width;
|
||||
src += pitch / 2 - width;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rgb32)
|
||||
{
|
||||
const uint32_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++)
|
||||
{
|
||||
u32 c = *src;
|
||||
for (int k = 0; k < scale; k++, dst++)
|
||||
for (int l = 0; l < scale; l++)
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 4 - width;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++) {
|
||||
u16 rgb565 = *src;
|
||||
u8 r = ((rgb565 >> 8) & 0xf8);
|
||||
u8 g = ((rgb565 >> 3) & 0xfc);
|
||||
u8 b = ((rgb565 << 3) & 0xfc);
|
||||
u32 c = (r<<16) | (g<<8) | b;
|
||||
for (int k = 0; k < scale; k++, dst++)
|
||||
for (int l = 0; l < scale; l++)
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 4 - width;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *src = frame;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++, src++)
|
||||
{
|
||||
u16 rgb565 = *src;
|
||||
u8 r = ((rgb565 >> 8) & 0xf8);
|
||||
u8 g = ((rgb565 >> 3) & 0xfc);
|
||||
u8 b = ((rgb565 << 3) & 0xfc);
|
||||
u32 c = (r<<16) | (g<<8) | b;
|
||||
for (int k = 0; k < scale; k++, dst++)
|
||||
for (int l = 0; l < scale; l++)
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 2 - width;
|
||||
}
|
||||
}
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 2 - width;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dst < dst_end)
|
||||
memset(dst, 0, 4 * (dst_end - dst));
|
||||
memset(dst, 0, 4 * (dst_end - dst));
|
||||
}
|
||||
|
||||
static void gcm_update_screen(gcm_video_t *gcm) {
|
||||
rsxBuffer *buffer = gcm->menu_frame_enable
|
||||
? &gcm->menuBuffers[gcm->menuBuffer]
|
||||
: &gcm->buffers[gcm->currentBuffer];
|
||||
flip(gcm->context, buffer->id);
|
||||
if (gcm->vsync)
|
||||
waitFlip();
|
||||
static void gcm_update_screen(gcm_video_t *gcm)
|
||||
{
|
||||
rsxBuffer *buffer = gcm->menu_frame_enable
|
||||
? &gcm->menuBuffers[gcm->menuBuffer]
|
||||
: &gcm->buffers[gcm->currentBuffer];
|
||||
gcm_flip(gcm->context, buffer->id);
|
||||
if (gcm->vsync)
|
||||
gcm_wait_flip();
|
||||
#ifdef HAVE_SYSUTILS
|
||||
cellSysutilCheckCallback();
|
||||
#endif
|
||||
@ -452,14 +463,15 @@ static bool gcm_frame(void* data, const void* frame,
|
||||
|
||||
if(frame && width && height)
|
||||
{
|
||||
gcm->currentBuffer++;
|
||||
if (gcm->currentBuffer >= MAX_BUFFERS)
|
||||
gcm->currentBuffer = 0;
|
||||
blitBuffer(&gcm->buffers[gcm->currentBuffer], frame, width, height, pitch,
|
||||
gcm->rgb32, true);
|
||||
gcm->currentBuffer++;
|
||||
if (gcm->currentBuffer >= MAX_BUFFERS)
|
||||
gcm->currentBuffer = 0;
|
||||
gcm_blit_buffer(
|
||||
&gcm->buffers[gcm->currentBuffer], frame, width, height, pitch,
|
||||
gcm->rgb32, true);
|
||||
}
|
||||
|
||||
// TODO: translucid menu
|
||||
/* TODO: translucid menu */
|
||||
gcm_update_screen(gcm);
|
||||
|
||||
return true;
|
||||
@ -524,21 +536,23 @@ static void gcm_free(void* data)
|
||||
for (int i = 0; i < MAX_BUFFERS; i++)
|
||||
rsxFree(gcm->menuBuffers[i].ptr);
|
||||
|
||||
//rsxFinish(gcm->context, 1);
|
||||
// free(gcm->host_addr);
|
||||
#if 0
|
||||
rsxFinish(gcm->context, 1);
|
||||
free(gcm->host_addr);
|
||||
#endif
|
||||
free (gcm);
|
||||
}
|
||||
|
||||
static void gcm_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
|
||||
int newBuffer = gcm->menuBuffer + 1;
|
||||
if (newBuffer >= MAX_BUFFERS)
|
||||
newBuffer = 0;
|
||||
// TODO: respect alpha
|
||||
blitBuffer(&gcm->menuBuffers[newBuffer], frame, width, height,
|
||||
/* TODO: respect alpha */
|
||||
gcm_blit_buffer(&gcm->menuBuffers[newBuffer], frame, width, height,
|
||||
width * (rgb32 ? 4 : 2), rgb32, true);
|
||||
gcm->menuBuffer = newBuffer;
|
||||
|
||||
@ -605,7 +619,6 @@ static void gcm_viewport_info(void* data, struct video_viewport* vp)
|
||||
*vp = gcm->vp;
|
||||
}
|
||||
|
||||
|
||||
static void gcm_set_osd_msg(void *data,
|
||||
video_frame_info_t *video_info,
|
||||
const char *msg,
|
||||
@ -649,14 +662,14 @@ static const video_poke_interface_t gcm_poke_interface = {
|
||||
};
|
||||
|
||||
static void gcm_get_poke_interface(void* data,
|
||||
const video_poke_interface_t** iface)
|
||||
const video_poke_interface_t** iface)
|
||||
{
|
||||
(void)data;
|
||||
*iface = &gcm_poke_interface;
|
||||
}
|
||||
|
||||
static bool gcm_set_shader(void* data,
|
||||
enum rarch_shader_type type, const char* path)
|
||||
enum rarch_shader_type type, const char* path)
|
||||
{
|
||||
(void)data;
|
||||
(void)type;
|
||||
|
@ -189,6 +189,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
|
||||
gdi_t *gdi = (gdi_t*)data;
|
||||
unsigned bits = gdi->video_bits;
|
||||
HWND hwnd = win32_get_window();
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
/* FIXME: Force these settings off as they interfere with the rendering */
|
||||
video_info->xmb_shadows_enable = false;
|
||||
@ -198,7 +199,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
if ( gdi->video_width != frame_width ||
|
||||
|
@ -2829,6 +2829,7 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
const char *stat_text = video_info->stat_text;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!gl)
|
||||
return false;
|
||||
@ -3036,7 +3037,7 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
#if defined(HAVE_MENU)
|
||||
if (gl->menu_texture_enable)
|
||||
{
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
|
||||
if (gl->menu_texture)
|
||||
gl2_draw_texture(gl);
|
||||
|
@ -696,6 +696,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
unsigned pot_height = 0;
|
||||
unsigned video_width = video_info->width;
|
||||
unsigned video_height = video_info->height;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
gl1_context_bind_hw_render(gl1, false);
|
||||
|
||||
@ -790,9 +791,8 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
if (draw)
|
||||
{
|
||||
if (frame_to_copy)
|
||||
{
|
||||
draw_tex(gl1, pot_width, pot_height, width, height, gl1->tex, frame_to_copy);
|
||||
}
|
||||
draw_tex(gl1, pot_width, pot_height,
|
||||
width, height, gl1->tex, frame_to_copy);
|
||||
}
|
||||
|
||||
if (gl1->menu_frame && video_info->menu_is_alive)
|
||||
@ -837,25 +837,26 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (gl1->menu_texture_enable)
|
||||
menu_driver_frame(video_info);
|
||||
else if (video_info->statistics_show)
|
||||
{
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
|
||||
if (osd_params)
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
if (video_info->statistics_show)
|
||||
{
|
||||
font_driver_render_msg(gl1, video_info->stat_text,
|
||||
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
|
||||
if (osd_params)
|
||||
{
|
||||
font_driver_render_msg(gl1, video_info->stat_text,
|
||||
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
||||
#if 0
|
||||
osd_params->y = 0.350f;
|
||||
osd_params->scale = 0.75f;
|
||||
font_driver_render_msg(gl1, video_info->chat_text,
|
||||
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
||||
osd_params->y = 0.350f;
|
||||
osd_params->scale = 0.75f;
|
||||
font_driver_render_msg(gl1, video_info->chat_text,
|
||||
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
gfx_widgets_frame(video_info);
|
||||
|
@ -1850,6 +1850,8 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
bool runloop_is_paused = video_info->runloop_is_paused;
|
||||
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
|
||||
bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!gl)
|
||||
return false;
|
||||
|
||||
@ -1919,7 +1921,7 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
#if defined(HAVE_MENU)
|
||||
if (gl->menu_texture_enable)
|
||||
{
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
if (gl->menu_texture_enable && gl->menu_texture)
|
||||
gl_core_draw_menu_texture(gl, width, height);
|
||||
}
|
||||
|
@ -1047,6 +1047,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
{
|
||||
uint32_t i;
|
||||
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
(void)msg;
|
||||
|
||||
@ -1140,44 +1141,45 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
|
||||
if (wiiu->shader_preset)
|
||||
{
|
||||
unsigned i;
|
||||
int32_t frame_direction = state_manager_frame_is_reversed() ? -1 : 1;
|
||||
|
||||
for (int i = 0; i < wiiu->shader_preset->passes; i++)
|
||||
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
||||
{
|
||||
|
||||
unsigned j;
|
||||
GX2SetVertexShader(wiiu->pass[i].gfd->vs);
|
||||
|
||||
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
||||
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
||||
{
|
||||
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j,
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
|
||||
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
|
||||
frame_count, frame_direction);
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
|
||||
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
|
||||
frame_count, frame_direction);
|
||||
GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset,
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
|
||||
}
|
||||
|
||||
GX2SetPixelShader(wiiu->pass[i].gfd->ps);
|
||||
|
||||
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
||||
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
||||
{
|
||||
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j,
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
|
||||
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
|
||||
frame_count, frame_direction);
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
|
||||
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
|
||||
frame_count, frame_direction);
|
||||
GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset,
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++)
|
||||
for (j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++)
|
||||
{
|
||||
if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Source"))
|
||||
{
|
||||
GX2SetPixelTexture(texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1185,9 +1187,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
{
|
||||
GX2SetPixelTexture(&wiiu->texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->pass[0].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1203,9 +1205,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
GX2Texture *source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture;
|
||||
GX2SetPixelTexture(source, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1216,9 +1218,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
index = i - 1;
|
||||
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1231,9 +1233,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
|
||||
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1244,9 +1246,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
{
|
||||
GX2SetPixelTexture(&wiiu->luts[k], wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
GX2SetPixelSampler(wiiu->shader_preset->lut[k].filter ?
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
&wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] :
|
||||
&wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap],
|
||||
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1308,12 +1310,11 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
0.0f, 1.0f);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
|
||||
if (wiiu->overlay_enable)
|
||||
gx2_render_overlay(wiiu);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (wiiu->menu.enable)
|
||||
{
|
||||
GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->menu.v), sizeof(*wiiu->menu.v), wiiu->menu.v);
|
||||
@ -1325,6 +1326,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, 0, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
wiiu->vertex_cache.current = 0;
|
||||
wiiu->vertex_cache_tex.current = 0;
|
||||
@ -1335,9 +1337,12 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
|
||||
wiiu->render_msg_enabled = true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (wiiu->menu.enable)
|
||||
menu_driver_frame(video_info);
|
||||
else if (video_info->statistics_show)
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
else
|
||||
#endif
|
||||
if (video_info->statistics_show)
|
||||
{
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
@ -1446,6 +1451,7 @@ static bool wiiu_gfx_set_shader(void *data,
|
||||
|
||||
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
||||
{
|
||||
unsigned j;
|
||||
char gfdpath[PATH_MAX_LENGTH];
|
||||
struct video_shader_pass *pass = &wiiu->shader_preset->pass[i];
|
||||
|
||||
@ -1470,22 +1476,22 @@ static bool wiiu_gfx_set_shader(void *data,
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
||||
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
||||
{
|
||||
wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
|
||||
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
||||
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
||||
memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j],
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
|
||||
wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
||||
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
||||
{
|
||||
wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
|
||||
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
||||
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
||||
memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j],
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
|
||||
wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1495,6 +1501,8 @@ static bool wiiu_gfx_set_shader(void *data,
|
||||
|
||||
if (image_texture_load(&image, wiiu->shader_preset->lut[i].path))
|
||||
{
|
||||
unsigned j;
|
||||
|
||||
wiiu->luts[i].surface.width = image.width;
|
||||
wiiu->luts[i].surface.height = image.height;
|
||||
wiiu->luts[i].surface.depth = 1;
|
||||
@ -1510,7 +1518,7 @@ static bool wiiu_gfx_set_shader(void *data,
|
||||
wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize,
|
||||
wiiu->luts[i].surface.alignment);
|
||||
|
||||
for (int j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++)
|
||||
for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++)
|
||||
memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch),
|
||||
image.pixels + (j * image.width), image.width * sizeof(image.pixels));
|
||||
|
||||
|
@ -1574,6 +1574,7 @@ static bool gx_frame(void *data, const void *frame,
|
||||
unsigned overscan_corr_bottom = settings->uints.video_overscan_correction_bottom;
|
||||
bool video_smooth = settings->bools.video_smooth;
|
||||
unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
fps_text_buf[0] = '\0';
|
||||
|
||||
@ -1615,7 +1616,7 @@ static bool gx_frame(void *data, const void *frame,
|
||||
gx->old_height = height;
|
||||
}
|
||||
|
||||
g_draw_done = false;
|
||||
g_draw_done = false;
|
||||
gx->current_framebuf ^= 1;
|
||||
|
||||
if (frame)
|
||||
@ -1649,7 +1650,7 @@ static bool gx_frame(void *data, const void *frame,
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
GX_InvalidateTexAll();
|
||||
|
@ -178,26 +178,30 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
unsigned pixfmt = NETWORK_VIDEO_PIXELFORMAT_RGB565;
|
||||
bool draw = true;
|
||||
network_video_t *network = (network_video_t*)data;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!frame || !frame_width || !frame_height)
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
if (network_video_width != frame_width || network_video_height != frame_height || network_video_pitch != pitch)
|
||||
if ( network_video_width != frame_width ||
|
||||
network_video_height != frame_height ||
|
||||
network_video_pitch != pitch)
|
||||
{
|
||||
if (frame_width > 4 && frame_height > 4)
|
||||
{
|
||||
network_video_width = frame_width;
|
||||
network_video_height = frame_height;
|
||||
network_video_pitch = pitch;
|
||||
network->screen_width = network_video_width;
|
||||
network_video_width = frame_width;
|
||||
network_video_height = frame_height;
|
||||
network_video_pitch = pitch;
|
||||
network->screen_width = network_video_width;
|
||||
network->screen_height = network_video_height;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (network_menu_frame && video_info->menu_is_alive)
|
||||
{
|
||||
frame_to_copy = network_menu_frame;
|
||||
@ -207,16 +211,21 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
bits = network_menu_bits;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
width = network_video_width;
|
||||
height = network_video_height;
|
||||
pitch = network_video_pitch;
|
||||
|
||||
if (frame_width == 4 && frame_height == 4 && (frame_width < width && frame_height < height))
|
||||
if ( frame_width == 4 &&
|
||||
frame_height == 4 &&
|
||||
(frame_width < width && frame_height < height))
|
||||
draw = false;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (video_info->menu_is_alive)
|
||||
draw = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (network->video_width != width || network->video_height != height)
|
||||
@ -225,9 +234,7 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
network->video_height = height;
|
||||
|
||||
if (network_video_temp_buf)
|
||||
{
|
||||
free(network_video_temp_buf);
|
||||
}
|
||||
|
||||
network_video_temp_buf = (unsigned*)malloc(network->screen_width * network->screen_height * sizeof(unsigned));
|
||||
}
|
||||
@ -246,8 +253,8 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
for (x = 0; x < network->screen_width; x++)
|
||||
{
|
||||
/* scale incoming frame to fit the screen */
|
||||
unsigned scaled_x = (width * x) / network->screen_width;
|
||||
unsigned scaled_y = (height * y) / network->screen_height;
|
||||
unsigned scaled_x = (width * x) / network->screen_width;
|
||||
unsigned scaled_y = (height * y) / network->screen_height;
|
||||
unsigned short pixel = ((unsigned short*)frame_to_copy)[width * scaled_y + scaled_x];
|
||||
|
||||
/* convert RGBX4444 to RGBX8888 */
|
||||
@ -272,8 +279,8 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
for (x = 0; x < network->screen_width; x++)
|
||||
{
|
||||
/* scale incoming frame to fit the screen */
|
||||
unsigned scaled_x = (width * x) / network->screen_width;
|
||||
unsigned scaled_y = (height * y) / network->screen_height;
|
||||
unsigned scaled_x = (width * x) / network->screen_width;
|
||||
unsigned scaled_y = (height * y) / network->screen_height;
|
||||
unsigned short pixel = ((unsigned short*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
|
||||
|
||||
/* convert RGB565 to RGBX8888 */
|
||||
@ -306,7 +313,7 @@ static bool network_gfx_frame(void *data, const void *frame,
|
||||
/* scale incoming frame to fit the screen */
|
||||
unsigned scaled_x = (width * x) / network->screen_width;
|
||||
unsigned scaled_y = (height * y) / network->screen_height;
|
||||
unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
|
||||
unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
|
||||
|
||||
network_video_temp_buf[network->screen_width * y + x] = pixel;
|
||||
}
|
||||
|
@ -76,85 +76,91 @@ go2_rotation_t oga_rotation = GO2_ROTATION_DEGREES_0;
|
||||
|
||||
static void oga_gfx_free(void *data)
|
||||
{
|
||||
oga_video_t *vid = (oga_video_t*)data;
|
||||
if (!vid)
|
||||
return;
|
||||
unsigned i;
|
||||
oga_video_t *vid = (oga_video_t*)data;
|
||||
|
||||
if (vid->font) {
|
||||
vid->font_driver->free(vid->font);
|
||||
vid->font_driver = NULL;
|
||||
}
|
||||
if (!vid)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < NUM_PAGES; ++i)
|
||||
{
|
||||
go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i];
|
||||
go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer);
|
||||
if (vid->font)
|
||||
{
|
||||
vid->font_driver->free(vid->font);
|
||||
vid->font_driver = NULL;
|
||||
}
|
||||
|
||||
go2_frame_buffer_destroy(frameBuffer);
|
||||
go2_surface_destroy(surface);
|
||||
}
|
||||
for (i = 0; i < NUM_PAGES; ++i)
|
||||
{
|
||||
go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i];
|
||||
go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer);
|
||||
|
||||
go2_surface_destroy(vid->frame);
|
||||
go2_surface_destroy(vid->menu_surface);
|
||||
go2_presenter_destroy(vid->presenter);
|
||||
go2_display_destroy(vid->display);
|
||||
go2_frame_buffer_destroy(frameBuffer);
|
||||
go2_surface_destroy(surface);
|
||||
}
|
||||
|
||||
free(vid);
|
||||
vid = NULL;
|
||||
go2_surface_destroy(vid->frame);
|
||||
go2_surface_destroy(vid->menu_surface);
|
||||
go2_presenter_destroy(vid->presenter);
|
||||
go2_display_destroy(vid->display);
|
||||
|
||||
free(vid);
|
||||
vid = NULL;
|
||||
}
|
||||
|
||||
static void *oga_gfx_init(const video_info_t *video,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
oga_video_t *vid = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
oga_video_t *vid = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
frontend_driver_install_signal_handler();
|
||||
|
||||
if (input && input_data) {
|
||||
void* udev = input_udev.init(settings->arrays.input_joypad_driver);
|
||||
if (udev) {
|
||||
*input = &input_udev;
|
||||
*input_data = udev;
|
||||
}
|
||||
else
|
||||
*input = NULL;
|
||||
}
|
||||
if (input && input_data)
|
||||
{
|
||||
void* udev = input_udev.init(settings->arrays.input_joypad_driver);
|
||||
if (udev)
|
||||
{
|
||||
*input = &input_udev;
|
||||
*input_data = udev;
|
||||
}
|
||||
else
|
||||
*input = NULL;
|
||||
}
|
||||
|
||||
vid = (oga_video_t*)calloc(1, sizeof(*vid));
|
||||
vid = (oga_video_t*)calloc(1, sizeof(*vid));
|
||||
|
||||
vid->menu_frame = NULL;
|
||||
vid->display = go2_display_create();
|
||||
vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false);
|
||||
vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565);
|
||||
vid->font = NULL;
|
||||
vid->font_driver = NULL;
|
||||
vid->menu_frame = NULL;
|
||||
vid->display = go2_display_create();
|
||||
vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false);
|
||||
vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565);
|
||||
vid->font = NULL;
|
||||
vid->font_driver = NULL;
|
||||
|
||||
int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH);
|
||||
int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT);
|
||||
int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH);
|
||||
int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT);
|
||||
|
||||
printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n",
|
||||
video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect,
|
||||
video->fullscreen, aw, ah, video->rgb32);
|
||||
printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n",
|
||||
video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect,
|
||||
video->fullscreen, aw, ah, video->rgb32);
|
||||
|
||||
vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565);
|
||||
vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565);
|
||||
|
||||
// bitmap only for now
|
||||
if (settings->bools.video_font_enable) {
|
||||
vid->font_driver = &bitmap_font_renderer;
|
||||
vid->font = vid->font_driver->init("", settings->floats.video_font_size);
|
||||
}
|
||||
/* bitmap only for now */
|
||||
if (settings->bools.video_font_enable)
|
||||
{
|
||||
vid->font_driver = &bitmap_font_renderer;
|
||||
vid->font = vid->font_driver->init("", settings->floats.video_font_size);
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_PAGES; ++i)
|
||||
{
|
||||
go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH,
|
||||
video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888);
|
||||
vid->frameBuffer[i] = go2_frame_buffer_create(surface);
|
||||
}
|
||||
vid->cur_page = 0;
|
||||
for (int i = 0; i < NUM_PAGES; ++i)
|
||||
{
|
||||
go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH,
|
||||
video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888);
|
||||
vid->frameBuffer[i] = go2_frame_buffer_create(surface);
|
||||
}
|
||||
vid->cur_page = 0;
|
||||
|
||||
return vid;
|
||||
return vid;
|
||||
}
|
||||
|
||||
int get_message_width(oga_video_t* vid, const char* msg)
|
||||
@ -171,110 +177,126 @@ int get_message_width(oga_video_t* vid, const char* msg)
|
||||
return width;
|
||||
}
|
||||
|
||||
static void render_msg(oga_video_t* vid, go2_surface_t* surface, const char* msg, int width, int bpp)
|
||||
static void render_msg(oga_video_t* vid,
|
||||
go2_surface_t* surface, const char* msg, int width, int bpp)
|
||||
{
|
||||
const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font);
|
||||
int msg_width = get_message_width(vid, msg);
|
||||
int dest_x = MAX(0, width - get_message_width(vid, msg));
|
||||
int dest_stride = go2_surface_stride_get(surface);
|
||||
const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font);
|
||||
int msg_width = get_message_width(vid, msg);
|
||||
int dest_x = MAX(0, width - get_message_width(vid, msg));
|
||||
int dest_stride = go2_surface_stride_get(surface);
|
||||
const char *c = msg;
|
||||
|
||||
const char* c = msg;
|
||||
while (*c) {
|
||||
const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c);
|
||||
if (!g)
|
||||
continue;
|
||||
if (dest_x + g->advance_x >= width)
|
||||
break;
|
||||
while (*c)
|
||||
{
|
||||
const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c);
|
||||
if (!g)
|
||||
continue;
|
||||
if (dest_x + g->advance_x >= width)
|
||||
break;
|
||||
|
||||
const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x;
|
||||
uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp;
|
||||
const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x;
|
||||
uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp;
|
||||
|
||||
for (int y = 0; y < g->height; y++) {
|
||||
for (int x = 0; x < g->advance_x; x++) {
|
||||
uint8_t px = (x < g->width) ? *(source++) : 0x00;
|
||||
if (bpp == 4) {
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
}
|
||||
else {
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
}
|
||||
for (int y = 0; y < g->height; y++)
|
||||
{
|
||||
for (int x = 0; x < g->advance_x; x++)
|
||||
{
|
||||
uint8_t px = (x < g->width) ? *(source++) : 0x00;
|
||||
if (bpp == 4)
|
||||
{
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
}
|
||||
dest += dest_stride - g->advance_x * bpp;
|
||||
source += atlas->width - g->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(dest++) = px;
|
||||
*(dest++) = px;
|
||||
}
|
||||
}
|
||||
dest += dest_stride - g->advance_x * bpp;
|
||||
source += atlas->width - g->width;
|
||||
}
|
||||
|
||||
c++;
|
||||
dest_x += g->advance_x;
|
||||
}
|
||||
c++;
|
||||
dest_x += g->advance_x;
|
||||
}
|
||||
}
|
||||
|
||||
static bool oga_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
unsigned height, uint64_t frame_count,
|
||||
unsigned pitch, const char *msg, video_frame_info_t *video_info)
|
||||
{
|
||||
oga_video_t* vid = (oga_video_t*)data;
|
||||
go2_surface_t* dst_surface = vid->frame;
|
||||
uint8_t* src = (uint8_t*)frame;
|
||||
int bpp = go2_drm_format_get_bpp(go2_surface_format_get(dst_surface)) / 8;
|
||||
int out_w, out_h;
|
||||
int yy, stride, dst_stride;
|
||||
int out_x = 0;
|
||||
int out_y = 0;
|
||||
go2_display_t *display = NULL;
|
||||
go2_frame_buffer_t *dstFrameBuffer = NULL;
|
||||
go2_surface_t *dstSurface = NULL;
|
||||
uint8_t *dst = NULL;
|
||||
oga_video_t *vid = (oga_video_t*)data;
|
||||
go2_surface_t *dst_surface = vid->frame;
|
||||
uint8_t *src = (uint8_t*)frame;
|
||||
int bpp = go2_drm_format_get_bpp(
|
||||
go2_surface_format_get(dst_surface)) / 8;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (unlikely(video_info->menu_is_alive)) {
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
if (unlikely(menu_is_alive))
|
||||
{
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
dst_surface = vid->menu_surface;
|
||||
src = (uint8_t*)vid->menu_frame;
|
||||
width = vid->menu_width;
|
||||
height = vid->menu_height;
|
||||
pitch = vid->menu_pitch;
|
||||
bpp = vid->menu_pitch / vid->menu_width;
|
||||
}
|
||||
#endif
|
||||
dst_surface = vid->menu_surface;
|
||||
src = (uint8_t*)vid->menu_frame;
|
||||
width = vid->menu_width;
|
||||
height = vid->menu_height;
|
||||
pitch = vid->menu_pitch;
|
||||
bpp = vid->menu_pitch / vid->menu_width;
|
||||
}
|
||||
|
||||
if (unlikely(!frame || width == 0 || height == 0))
|
||||
return true;
|
||||
if (unlikely(!frame || width == 0 || height == 0))
|
||||
return true;
|
||||
|
||||
// copy buffer to surface
|
||||
uint8_t* dst = (uint8_t*)go2_surface_map(dst_surface);
|
||||
int yy = height;
|
||||
int stride = width * bpp;
|
||||
int dst_stride = go2_surface_stride_get(dst_surface);
|
||||
while (yy > 0) {
|
||||
memcpy(dst, src, stride);
|
||||
src += pitch;
|
||||
dst += dst_stride;
|
||||
--yy;
|
||||
}
|
||||
/* copy buffer to surface */
|
||||
dst = (uint8_t*)go2_surface_map(dst_surface);
|
||||
yy = height;
|
||||
stride = width * bpp;
|
||||
dst_stride = go2_surface_stride_get(dst_surface);
|
||||
|
||||
int out_w = NATIVE_WIDTH;
|
||||
int out_h = NATIVE_HEIGHT;
|
||||
int out_x = 0;
|
||||
int out_y = 0;
|
||||
while (yy > 0)
|
||||
{
|
||||
memcpy(dst, src, stride);
|
||||
src += pitch;
|
||||
dst += dst_stride;
|
||||
--yy;
|
||||
}
|
||||
|
||||
if ((out_w != width || out_h != height))
|
||||
{
|
||||
out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH);
|
||||
out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0);
|
||||
}
|
||||
out_w = NATIVE_WIDTH;
|
||||
out_h = NATIVE_HEIGHT;
|
||||
|
||||
if (msg && vid->font) {
|
||||
render_msg(vid, dst_surface, msg, width, bpp);
|
||||
}
|
||||
if ((out_w != width || out_h != height))
|
||||
{
|
||||
out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH);
|
||||
out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0);
|
||||
}
|
||||
|
||||
go2_frame_buffer_t* dstFrameBuffer = vid->frameBuffer[vid->cur_page];
|
||||
go2_surface_t* dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer);
|
||||
if (msg && vid->font)
|
||||
render_msg(vid, dst_surface, msg, width, bpp);
|
||||
|
||||
go2_surface_blit(dst_surface, 0, 0, width, height,
|
||||
dstSurface, out_y, out_x, out_h, out_w,
|
||||
!video_info->menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2);
|
||||
dstFrameBuffer = vid->frameBuffer[vid->cur_page];
|
||||
dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer);
|
||||
|
||||
go2_display_t* display = go2_presenter_display_get(vid->presenter);
|
||||
go2_display_present(display, dstFrameBuffer);
|
||||
vid->cur_page = !vid->cur_page;
|
||||
go2_surface_blit(dst_surface, 0, 0, width, height,
|
||||
dstSurface, out_y, out_x, out_h, out_w,
|
||||
!menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2);
|
||||
|
||||
return true;
|
||||
display = go2_presenter_display_get(vid->presenter);
|
||||
go2_display_present(display, dstFrameBuffer);
|
||||
vid->cur_page = !vid->cur_page;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void oga_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||
@ -353,25 +375,26 @@ static const video_poke_interface_t oga_poke_interface = {
|
||||
|
||||
void oga_set_rotation(void *data, unsigned rotation)
|
||||
{
|
||||
// called before init?
|
||||
(void)data;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_270;
|
||||
break;
|
||||
case 1:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_180;
|
||||
break;
|
||||
case 2:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_90;
|
||||
break;
|
||||
case 3:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_0;
|
||||
break;
|
||||
default:
|
||||
RARCH_ERR("Unhandled rotation %hu\n", rotation);
|
||||
break;
|
||||
}
|
||||
/* called before init? */
|
||||
(void)data;
|
||||
switch (rotation)
|
||||
{
|
||||
case 0:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_270;
|
||||
break;
|
||||
case 1:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_180;
|
||||
break;
|
||||
case 2:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_90;
|
||||
break;
|
||||
case 3:
|
||||
oga_rotation = GO2_ROTATION_DEGREES_0;
|
||||
break;
|
||||
default:
|
||||
RARCH_ERR("Unhandled rotation %hu\n", rotation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void oga_get_poke_interface(void *data, const video_poke_interface_t **iface)
|
||||
|
@ -989,7 +989,8 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
|
||||
video_frame_info_t *video_info)
|
||||
{
|
||||
omap_video_t *vid = (omap_video_t*)data;
|
||||
omap_video_t *vid = (omap_video_t*)data;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!frame)
|
||||
return true;
|
||||
@ -1012,13 +1013,13 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
omapfb_blit_frame(vid->omap, frame, vid->height, pitch);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
#endif
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
|
||||
if (vid->menu.active)
|
||||
omapfb_blit_frame(vid->omap, vid->menu.frame,
|
||||
vid->menu.scaler.out_height,
|
||||
vid->menu.scaler.out_stride);
|
||||
#endif
|
||||
|
||||
if (msg)
|
||||
omap_render_msg(vid, msg);
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
typedef struct ps2_video
|
||||
{
|
||||
bool clearVRAM;
|
||||
/* I need to create this additional field
|
||||
* to be used in the font driver*/
|
||||
bool clearVRAM_font;
|
||||
@ -93,6 +92,8 @@ static GSTEXTURE *prepare_new_texture(void)
|
||||
static void init_ps2_video(ps2_video_t *ps2)
|
||||
{
|
||||
ps2->gsGlobal = init_GSGlobal();
|
||||
gsKit_TexManager_init(ps2->gsGlobal);
|
||||
|
||||
ps2->menuTexture = prepare_new_texture();
|
||||
ps2->coreTexture = prepare_new_texture();
|
||||
|
||||
@ -108,16 +109,8 @@ static void ps2_gfx_deinit_texture(GSTEXTURE *texture)
|
||||
texture->Clut = NULL;
|
||||
}
|
||||
|
||||
static bool texture_need_prepare(GSTEXTURE *texture,
|
||||
int width, int height, int PSM)
|
||||
{
|
||||
return texture->Width != width ||
|
||||
texture->Height != height ||
|
||||
texture->PSM != PSM;
|
||||
}
|
||||
|
||||
static void transfer_texture(GSTEXTURE *texture, const void *frame,
|
||||
int width, int height, int PSM, int filter, bool color_correction)
|
||||
static void set_texture(GSTEXTURE *texture, const void *frame,
|
||||
int width, int height, int PSM, int filter)
|
||||
{
|
||||
texture->Width = width;
|
||||
texture->Height = height;
|
||||
@ -126,25 +119,6 @@ static void transfer_texture(GSTEXTURE *texture, const void *frame,
|
||||
texture->Mem = (void *)frame;
|
||||
}
|
||||
|
||||
static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture)
|
||||
{
|
||||
uint32_t size = gsKit_texture_size(texture->Width,
|
||||
texture->Height, texture->PSM);
|
||||
texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER);
|
||||
|
||||
if(texture->Vram == GSKIT_ALLOC_ERROR)
|
||||
{
|
||||
printf("VRAM Allocation Failed. Will not upload texture.\n");
|
||||
}
|
||||
|
||||
if (texture->Clut)
|
||||
{
|
||||
/* Right now just supporting 16 x 16 = 256 colours */
|
||||
size = gsKit_texture_size(16, 16, texture->ClutPSM);
|
||||
texture->VramClut = gsKit_vram_alloc(gsGlobal, size , GSKIT_ALLOC_USERBUFFER);
|
||||
}
|
||||
}
|
||||
|
||||
static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding)
|
||||
{
|
||||
float x1, y1, x2, y2;
|
||||
@ -185,65 +159,13 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition,
|
||||
GS_TEXT);
|
||||
}
|
||||
|
||||
static void clearVRAMIfNeeded(ps2_video_t *ps2,
|
||||
const void *frame, int width, int height)
|
||||
{
|
||||
if (!ps2->clearVRAM)
|
||||
{
|
||||
if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID)
|
||||
{
|
||||
bool coreVRAMClear = texture_need_prepare(
|
||||
ps2->coreTexture, width, height, ps2->PSM);
|
||||
ps2->clearVRAM = ps2->clearVRAM || coreVRAMClear;
|
||||
}
|
||||
}
|
||||
|
||||
if (ps2->clearVRAM)
|
||||
{
|
||||
gsKit_vram_clear(ps2->gsGlobal);
|
||||
ps2->iface.updatedPalette = true;
|
||||
/* we need to upload also palette in the font driver */
|
||||
ps2->clearVRAM_font = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void refreshScreen(ps2_video_t *ps2)
|
||||
{
|
||||
if (ps2->vsync)
|
||||
gsKit_sync_flip(ps2->gsGlobal);
|
||||
gsKit_queue_exec(ps2->gsGlobal);
|
||||
gsKit_TexManager_nextFrame(ps2->gsGlobal);
|
||||
|
||||
/* Here we are just puting in false the ps2->clearVRAM field
|
||||
however, the ps2->clearVRAM_font should be done in the ps2_font driver */
|
||||
ps2->clearVRAM = false;
|
||||
}
|
||||
|
||||
static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
|
||||
bool sendPalette)
|
||||
{
|
||||
gsKit_setup_tbw(Texture);
|
||||
|
||||
if (Texture->PSM == GS_PSM_T8)
|
||||
{
|
||||
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
||||
if (sendPalette)
|
||||
{
|
||||
gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
||||
}
|
||||
|
||||
}
|
||||
else if (Texture->PSM == GS_PSM_T4)
|
||||
{
|
||||
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
||||
if (sendPalette)
|
||||
{
|
||||
gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void *ps2_gfx_init(const video_info_t *video,
|
||||
@ -270,7 +192,6 @@ static void *ps2_gfx_init(const video_info_t *video,
|
||||
ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST;
|
||||
ps2->force_aspect = video->force_aspect;
|
||||
ps2->vsync = video->vsync;
|
||||
ps2->clearVRAM = true;
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
@ -294,43 +215,30 @@ static bool ps2_gfx_frame(void *data, const void *frame,
|
||||
return false;
|
||||
|
||||
#if defined(DEBUG)
|
||||
if (frame_count%60==0)
|
||||
{
|
||||
if (frame_count%180==0)
|
||||
printf("ps2_gfx_frame %lu\n", frame_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
clearVRAMIfNeeded(ps2, frame, width, height);
|
||||
gsKit_clear(ps2->gsGlobal, GS_BLACK);
|
||||
|
||||
if (frame)
|
||||
{
|
||||
bool sendPalette = false;
|
||||
struct retro_hw_ps2_insets padding = empty_ps2_insets;
|
||||
/* Checking if the transfer is done in the core */
|
||||
if (frame != RETRO_HW_FRAME_BUFFER_VALID)
|
||||
{
|
||||
/* Checking if the transfer is done in the core */
|
||||
{
|
||||
/* calculate proper width based in the pitch */
|
||||
int bytes_per_pixel = (ps2->PSM == GS_PSM_CT32) ? 4 : 2;
|
||||
int real_width = pitch / bytes_per_pixel;
|
||||
|
||||
transfer_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter, 1);
|
||||
int shifh_per_bytes = (ps2->PSM == GS_PSM_CT32) ? 2 : 1;
|
||||
int real_width = pitch >> shifh_per_bytes;
|
||||
set_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter);
|
||||
|
||||
padding.right = real_width - width;
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPalette = ps2->iface.updatedPalette;
|
||||
ps2->iface.updatedPalette = false;
|
||||
padding = ps2->iface.padding;
|
||||
if (ps2->iface.clearTexture)
|
||||
ps2->iface.clearTexture = false;
|
||||
}
|
||||
|
||||
if(ps2->clearVRAM)
|
||||
vram_alloc(ps2->gsGlobal, ps2->coreTexture);
|
||||
|
||||
ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette);
|
||||
gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->coreTexture);
|
||||
gsKit_TexManager_bind(ps2->gsGlobal, ps2->coreTexture);
|
||||
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding);
|
||||
}
|
||||
|
||||
@ -339,9 +247,6 @@ static bool ps2_gfx_frame(void *data, const void *frame,
|
||||
bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height;
|
||||
if (!texture_empty)
|
||||
{
|
||||
if(ps2->clearVRAM)
|
||||
vram_alloc(ps2->gsGlobal, ps2->menuTexture);
|
||||
gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture);
|
||||
prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets);
|
||||
}
|
||||
}
|
||||
@ -412,12 +317,11 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||
{
|
||||
ps2_video_t *ps2 = (ps2_video_t*)data;
|
||||
|
||||
bool color_correction = false;
|
||||
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
|
||||
bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM);
|
||||
|
||||
transfer_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter, color_correction);
|
||||
ps2->clearVRAM = ps2->clearVRAM || texture_changed;
|
||||
set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter);
|
||||
gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture);
|
||||
gsKit_TexManager_bind(ps2->gsGlobal, ps2->menuTexture);
|
||||
}
|
||||
|
||||
static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen)
|
||||
@ -426,10 +330,8 @@ static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen)
|
||||
|
||||
if (ps2->menuVisible != enable)
|
||||
{
|
||||
/* If Menu change status, CLEAR VRAM */
|
||||
ps2->clearVRAM = true;
|
||||
ps2->iface.clearTexture = true;
|
||||
ps2->iface.updatedPalette = true;
|
||||
/* If Menu change status, CLEAR SCREEN */
|
||||
gsKit_clear(ps2->gsGlobal, GS_BLACK);
|
||||
}
|
||||
ps2->menuVisible = enable;
|
||||
ps2->fullscreen = fullscreen;
|
||||
@ -439,8 +341,6 @@ static bool ps2_get_hw_render_interface(void* data,
|
||||
const struct retro_hw_render_interface** iface)
|
||||
{
|
||||
ps2_video_t *ps2 = (ps2_video_t*)data;
|
||||
ps2->iface.clearTexture = ps2->clearVRAM;
|
||||
ps2->iface.updatedPalette = true;
|
||||
ps2->iface.padding = empty_ps2_insets;
|
||||
*iface =
|
||||
(const struct retro_hw_render_interface*)&ps2->iface;
|
||||
|
@ -475,7 +475,8 @@ static bool psp_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, uint64_t frame_count,
|
||||
unsigned pitch, const char *msg, video_frame_info_t *video_info)
|
||||
{
|
||||
psp1_video_t *psp = (psp1_video_t*)data;
|
||||
psp1_video_t *psp = (psp1_video_t*)data;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
|
||||
if (!width || !height)
|
||||
return false;
|
||||
@ -536,7 +537,7 @@ static bool psp_frame(void *data, const void *frame,
|
||||
sceGuFinish();
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
menu_driver_frame(video_info);
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
#endif
|
||||
|
||||
if(psp->menu.active)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user