Skip to content

Commit fcf0cc7

Browse files
authored
rvz hashing for retroachievements (#18319)
1 parent 8c10eaa commit fcf0cc7

File tree

6 files changed

+1358
-2
lines changed

6 files changed

+1358
-2
lines changed

Makefile.common

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,12 @@ ifeq ($(HAVE_NETWORKING), 1)
24042404
deps/rcheevos/src/rapi/rc_api_runtime.o \
24052405
deps/rcheevos/src/rapi/rc_api_user.o \
24062406

2407+
# RVZ/WIA disc image support for RetroAchievements
2408+
ifeq ($(HAVE_ZSTD), 1)
2409+
DEFINES += -DHAVE_CHEEVOS_RVZ
2410+
OBJ += cheevos/cheevos_rvz.o
2411+
endif
2412+
24072413
ifeq ($(HAVE_LUA), 1)
24082414
DEFINES += -DHAVE_LUA \
24092415
-DLUA_32BITS

cheevos/cheevos.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#include "streams/chd_stream.h"
5353
#endif
5454

55+
#ifdef HAVE_CHEEVOS_RVZ
56+
#include "cheevos_rvz.h"
57+
#endif
58+
5559
#include "cheevos.h"
5660
#include "cheevos_client.h"
5761
#include "cheevos_menu.h"
@@ -1636,8 +1640,33 @@ bool rcheevos_load(const void *data)
16361640
gfx_widget_set_cheevos_set_loading(true);
16371641
#endif
16381642

1639-
rc_client_begin_identify_and_load_game(rcheevos_locals.client, RC_CONSOLE_UNKNOWN,
1640-
info->path, (const uint8_t*)info->data, info->size, rcheevos_client_load_game_callback, NULL);
1643+
/* Detect RVZ files and determine console type (GameCube or Wii) */
1644+
{
1645+
uint32_t console_id = RC_CONSOLE_UNKNOWN;
1646+
1647+
#ifdef HAVE_CHEEVOS_RVZ
1648+
if (string_is_equal_noncase(path_get_extension(info->path), "rvz"))
1649+
{
1650+
console_id = rcheevos_rvz_get_console_id(info->path);
1651+
1652+
/* Only register custom file reader for valid RVZ files */
1653+
if (console_id != RC_CONSOLE_UNKNOWN)
1654+
{
1655+
struct rc_hash_filereader filereader;
1656+
1657+
filereader.open = rcheevos_rvz_open;
1658+
filereader.seek = rcheevos_rvz_seek;
1659+
filereader.tell = rcheevos_rvz_tell;
1660+
filereader.read = rcheevos_rvz_read;
1661+
filereader.close = rcheevos_rvz_close;
1662+
rc_hash_init_custom_filereader(&filereader);
1663+
}
1664+
}
1665+
#endif
1666+
1667+
rc_client_begin_identify_and_load_game(rcheevos_locals.client, console_id,
1668+
info->path, (const uint8_t*)info->data, info->size, rcheevos_client_load_game_callback, NULL);
1669+
}
16411670

16421671
return true;
16431672
}

0 commit comments

Comments
 (0)