update rcheevos to latest release, change a ton of ints to uints (what's actually used often)

todo: trim out unneeded defs and do c# 10 cleanups
This commit is contained in:
CasualPokePlayer 2023-12-09 02:22:39 -08:00
parent c2e8bda5e2
commit cc0b6c0d99
22 changed files with 323 additions and 251 deletions

Binary file not shown.

Binary file not shown.

View File

@ -6,14 +6,11 @@ endif()
project(rcheevos C) project(rcheevos C)
set(CMAKE_C_STANDARD 90) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_EXTENSIONS ON)
if(MSVC) if(MSVC)
# silence dumb warnings over CRT functions be "unsafe"
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# MSVC targets don't export all symbols unless this is on # MSVC targets don't export all symbols unless this is on
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
@ -25,14 +22,13 @@ if(MSVC)
# this differs between clang-cl and cl # this differs between clang-cl and cl
if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options( add_compile_options(
-Wno-missing-field-initializers
-Wno-unused-parameter -Wno-unused-parameter
-Wno-null-pointer-subtraction
) )
else() else()
add_compile_options( add_compile_options(
/wd4100 # "unreferenced formal parameter" /wd4100 # "unreferenced formal parameter"
/wd4701 # "potentially uninitialized local variable used" (detection here is just faulty) /wd4244 # "conversion from 'type1' to 'type2', possible loss of data"
/wd4245 # "conversion from 'type1' to 'type2', signed/unsigned mismatch"
) )
endif() endif()
@ -53,11 +49,8 @@ else()
# ignore some warnings # ignore some warnings
add_compile_options( add_compile_options(
-Wno-missing-field-initializers
-Wno-unused-parameter -Wno-unused-parameter
-Wno-null-pointer-subtraction
-Wno-implicit-fallthrough -Wno-implicit-fallthrough
-Wno-array-bounds # interestingly this warning isn't triggered with lto active, it's likely just a false positive when there isn't lto
) )
# strip in release, optimize for gdb usage in debug # strip in release, optimize for gdb usage in debug
@ -73,42 +66,43 @@ else()
set(RC_TARGET rcheevos) set(RC_TARGET rcheevos)
endif() endif()
set(RC_RAPI_DIR ${CMAKE_SOURCE_DIR}/rcheevos/src/rapi) set(RC_SRC_DIR ${CMAKE_SOURCE_DIR}/rcheevos/src)
set(RC_RCHEEVOS_DIR ${CMAKE_SOURCE_DIR}/rcheevos/src/rcheevos)
set(RC_RHASH_DIR ${CMAKE_SOURCE_DIR}/rcheevos/src/rhash)
set(RC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/rcheevos/include) set(RC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/rcheevos/include)
add_library( add_library(
${RC_TARGET} ${RC_TARGET}
SHARED SHARED
${RC_RAPI_DIR}/rc_api_common.c ${RC_SRC_DIR}/rc_compat.c
${RC_RAPI_DIR}/rc_api_common.h ${RC_SRC_DIR}/rc_compat.h
${RC_RAPI_DIR}/rc_api_editor.c ${RC_SRC_DIR}/rc_util.c
${RC_RAPI_DIR}/rc_api_info.c ${RC_SRC_DIR}/rc_util.h
${RC_RAPI_DIR}/rc_api_runtime.c ${RC_SRC_DIR}/rc_version.h
${RC_RAPI_DIR}/rc_api_user.c ${RC_SRC_DIR}/rapi/rc_api_common.c
${RC_RCHEEVOS_DIR}/alloc.c ${RC_SRC_DIR}/rapi/rc_api_common.h
${RC_RCHEEVOS_DIR}/compat.c ${RC_SRC_DIR}/rapi/rc_api_editor.c
${RC_RCHEEVOS_DIR}/condition.c ${RC_SRC_DIR}/rapi/rc_api_info.c
${RC_RCHEEVOS_DIR}/condset.c ${RC_SRC_DIR}/rapi/rc_api_runtime.c
${RC_RCHEEVOS_DIR}/consoleinfo.c ${RC_SRC_DIR}/rapi/rc_api_user.c
${RC_RCHEEVOS_DIR}/format.c ${RC_SRC_DIR}/rcheevos/alloc.c
${RC_RCHEEVOS_DIR}/lboard.c ${RC_SRC_DIR}/rcheevos/condition.c
${RC_RCHEEVOS_DIR}/memref.c ${RC_SRC_DIR}/rcheevos/condset.c
${RC_RCHEEVOS_DIR}/operand.c ${RC_SRC_DIR}/rcheevos/consoleinfo.c
${RC_RCHEEVOS_DIR}/rc_compat.h ${RC_SRC_DIR}/rcheevos/format.c
${RC_RCHEEVOS_DIR}/rc_internal.h ${RC_SRC_DIR}/rcheevos/lboard.c
${RC_RCHEEVOS_DIR}/rc_validate.c ${RC_SRC_DIR}/rcheevos/memref.c
${RC_RCHEEVOS_DIR}/rc_validate.h ${RC_SRC_DIR}/rcheevos/operand.c
${RC_RCHEEVOS_DIR}/richpresence.c ${RC_SRC_DIR}/rcheevos/rc_internal.h
${RC_RCHEEVOS_DIR}/runtime.c ${RC_SRC_DIR}/rcheevos/rc_validate.c
${RC_RCHEEVOS_DIR}/runtime_progress.c ${RC_SRC_DIR}/rcheevos/rc_validate.h
${RC_RCHEEVOS_DIR}/trigger.c ${RC_SRC_DIR}/rcheevos/richpresence.c
${RC_RCHEEVOS_DIR}/value.c ${RC_SRC_DIR}/rcheevos/runtime.c
${RC_RHASH_DIR}/cdreader.c ${RC_SRC_DIR}/rcheevos/runtime_progress.c
${RC_RHASH_DIR}/hash.c ${RC_SRC_DIR}/rcheevos/trigger.c
${RC_RHASH_DIR}/md5.c ${RC_SRC_DIR}/rcheevos/value.c
${RC_RHASH_DIR}/md5.h ${RC_SRC_DIR}/rhash/cdreader.c
${RC_SRC_DIR}/rhash/hash.c
${RC_SRC_DIR}/rhash/md5.c
${RC_SRC_DIR}/rhash/md5.h
${RC_INCLUDE_DIR}/rc_api_editor.h ${RC_INCLUDE_DIR}/rc_api_editor.h
${RC_INCLUDE_DIR}/rc_api_info.h ${RC_INCLUDE_DIR}/rc_api_info.h
${RC_INCLUDE_DIR}/rc_api_request.h ${RC_INCLUDE_DIR}/rc_api_request.h
@ -119,11 +113,10 @@ add_library(
${RC_INCLUDE_DIR}/rc_hash.h ${RC_INCLUDE_DIR}/rc_hash.h
${RC_INCLUDE_DIR}/rc_runtime.h ${RC_INCLUDE_DIR}/rc_runtime.h
${RC_INCLUDE_DIR}/rc_runtime_types.h ${RC_INCLUDE_DIR}/rc_runtime_types.h
${RC_INCLUDE_DIR}/rc_url.h
${RC_INCLUDE_DIR}/rcheevos.h ${RC_INCLUDE_DIR}/rcheevos.h
) )
target_compile_definitions(${RC_TARGET} PRIVATE -DRC_DISABLE_LUA) target_compile_definitions(${RC_TARGET} PRIVATE RC_DISABLE_LUA RC_NO_THREADS)
target_include_directories(${RC_TARGET} PRIVATE ${RC_INCLUDE_DIR}) target_include_directories(${RC_TARGET} PRIVATE ${RC_INCLUDE_DIR})
add_custom_command( add_custom_command(

View File

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
set -e
if [ -z "$CC" ]; then export CC="clang"; fi
rm -rf build rm -rf build
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -G Ninja cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$CC -G Ninja
ninja ninja

View File

@ -1,6 +1,6 @@
rmdir /s /q build rmdir /s /q build
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_C_COMPILER=clang-cl -G Ninja cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_C_COMPILER=clang-cl -G Ninja
ninja ninja
cd .. cd ..

View File

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
set -e
if [ -z "$CC" ]; then export CC="clang"; fi
rm -rf build rm -rf build
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_C_COMPILER=clang -G Ninja cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_C_COMPILER=$CC -G Ninja
ninja ninja

@ -1 +1 @@
Subproject commit 46e1feaafb2e777ced9fbef14a22d54fd0191287 Subproject commit 6fb3ebca22fe4f3a97e7a391e5e9c4623aa2286a

View File

@ -47,7 +47,16 @@ namespace BizHawk.Client.EmuHawk
RC_INVALID_MEASURED_TARGET = -23, RC_INVALID_MEASURED_TARGET = -23,
RC_INVALID_COMPARISON = -24, RC_INVALID_COMPARISON = -24,
RC_INVALID_STATE = -25, RC_INVALID_STATE = -25,
RC_INVALID_JSON = -26 RC_INVALID_JSON = -26,
RC_API_FAILURE = -27,
RC_LOGIN_REQUIRED = -28,
RC_NO_GAME_LOADED = -29,
RC_HARDCORE_DISABLED = -30,
RC_ABORTED = -31,
RC_NO_RESPONSE = -32,
RC_ACCESS_DENIED = -33,
RC_INVALID_CREDENTIALS = -34,
RC_EXPIRED_TOKEN = -35
} }
public enum rc_runtime_event_type_t : byte public enum rc_runtime_event_type_t : byte
@ -63,10 +72,11 @@ namespace BizHawk.Client.EmuHawk
RC_RUNTIME_EVENT_LBOARD_TRIGGERED, RC_RUNTIME_EVENT_LBOARD_TRIGGERED,
RC_RUNTIME_EVENT_ACHIEVEMENT_DISABLED, RC_RUNTIME_EVENT_ACHIEVEMENT_DISABLED,
RC_RUNTIME_EVENT_LBOARD_DISABLED, RC_RUNTIME_EVENT_LBOARD_DISABLED,
RC_RUNTIME_EVENT_ACHIEVEMENT_UNPRIMED RC_RUNTIME_EVENT_ACHIEVEMENT_UNPRIMED,
RC_RUNTIME_EVENT_ACHIEVEMENT_PROGRESS_UPDATED
} }
public enum rc_api_image_type_t : int public enum rc_api_image_type_t : uint
{ {
RC_IMAGE_TYPE_GAME = 1, RC_IMAGE_TYPE_GAME = 1,
RC_IMAGE_TYPE_ACHIEVEMENT, RC_IMAGE_TYPE_ACHIEVEMENT,
@ -74,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
RC_IMAGE_TYPE_USER, RC_IMAGE_TYPE_USER,
} }
public enum rc_runtime_achievement_category_t : int public enum rc_runtime_achievement_category_t : uint
{ {
RC_ACHIEVEMENT_CATEGORY_CORE = 3, RC_ACHIEVEMENT_CATEGORY_CORE = 3,
RC_ACHIEVEMENT_CATEGORY_UNOFFICIAL = 5, RC_ACHIEVEMENT_CATEGORY_UNOFFICIAL = 5,
@ -83,17 +93,24 @@ namespace BizHawk.Client.EmuHawk
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_runtime_event_t public struct rc_runtime_event_t
{ {
public int id; public uint id;
public int value; public int value;
public rc_runtime_event_type_t type; public rc_runtime_event_type_t type;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_buffer_t public struct rc_buffer_chunk_t
{ {
public IntPtr write; public IntPtr write;
public IntPtr end; public IntPtr end;
public IntPtr start;
public IntPtr next; public IntPtr next;
}
[StructLayout(LayoutKind.Sequential)]
public struct rc_buffer_t
{
public rc_buffer_chunk_t chunk;
public unsafe fixed byte data[256]; public unsafe fixed byte data[256];
} }
@ -102,10 +119,12 @@ namespace BizHawk.Client.EmuHawk
{ {
public IntPtr url; public IntPtr url;
public IntPtr post_data; public IntPtr post_data;
public rc_api_buffer_t buffer; public IntPtr content_type;
public rc_buffer_t buffer;
public string URL => Mershul.PtrToStringUtf8(url); public string URL => Mershul.PtrToStringUtf8(url);
public string PostData => Mershul.PtrToStringUtf8(post_data); public string PostData => Mershul.PtrToStringUtf8(post_data);
public string ContentType => Mershul.PtrToStringUtf8(content_type);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -113,16 +132,18 @@ namespace BizHawk.Client.EmuHawk
{ {
public int succeeded; public int succeeded;
public IntPtr error_message; public IntPtr error_message;
public rc_api_buffer_t buffer; public IntPtr error_code;
public rc_buffer_t buffer;
public string ErrorMessage => Mershul.PtrToStringUtf8(error_message); public readonly string ErrorMessage => Mershul.PtrToStringUtf8(error_message);
public readonly string ErrorCode => Mershul.PtrToStringUtf8(error_code);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_user_unlocks_response_t public struct rc_api_fetch_user_unlocks_response_t
{ {
public IntPtr achievement_ids; public unsafe uint* achievement_ids;
public int num_achievement_ids; public uint num_achievement_ids;
public rc_api_response_t response; public rc_api_response_t response;
} }
@ -131,19 +152,32 @@ namespace BizHawk.Client.EmuHawk
{ {
public IntPtr username; public IntPtr username;
public IntPtr api_token; public IntPtr api_token;
public int score; public uint score;
public int num_unread_messages; public uint score_softcore;
public uint num_unread_messages;
public IntPtr display_name; public IntPtr display_name;
public rc_api_response_t response; public rc_api_response_t response;
public string Username => Mershul.PtrToStringUtf8(username); public readonly string Username => Mershul.PtrToStringUtf8(username);
public string ApiToken => Mershul.PtrToStringUtf8(api_token); public readonly string ApiToken => Mershul.PtrToStringUtf8(api_token);
public string DisplayName => Mershul.PtrToStringUtf8(display_name); public readonly string DisplayName => Mershul.PtrToStringUtf8(display_name);
}
[StructLayout(LayoutKind.Sequential)]
public struct rc_api_unlock_entry_t
{
public uint achievement_id;
public long when; // time_t?
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_start_session_response_t public struct rc_api_start_session_response_t
{ {
public unsafe rc_api_unlock_entry_t* hardcore_unlocks;
public unsafe rc_api_unlock_entry_t* unlocks;
public uint num_hardcore_unlocks;
public uint num_unlocks;
public long server_now; // time_t?
public rc_api_response_t response; public rc_api_response_t response;
} }
@ -154,11 +188,11 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int game_id; public uint game_id;
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
public bool hardcore; public bool hardcore;
public rc_api_fetch_user_unlocks_request_t(string username, string api_token, int game_id, bool hardcore) public rc_api_fetch_user_unlocks_request_t(string username, string api_token, uint game_id, bool hardcore)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -192,9 +226,9 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int game_id; public uint game_id;
public rc_api_start_session_request_t(string username, string api_token, int game_id) public rc_api_start_session_request_t(string username, string api_token, uint game_id)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -205,17 +239,18 @@ namespace BizHawk.Client.EmuHawk
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_award_achievement_response_t public struct rc_api_award_achievement_response_t
{ {
public int awarded_achievement_id; public uint awarded_achievement_id;
public int new_player_score; public uint new_player_score;
public int achievements_remaining; public uint new_player_score_softcore;
public uint achievements_remaining;
public rc_api_response_t response; public rc_api_response_t response;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_achievement_definition_t public struct rc_api_achievement_definition_t
{ {
public int id; public uint id;
public int points; public uint points;
public rc_runtime_achievement_category_t category; public rc_runtime_achievement_category_t category;
public IntPtr title; public IntPtr title;
public IntPtr description; public IntPtr description;
@ -225,46 +260,46 @@ namespace BizHawk.Client.EmuHawk
public long created; // time_t? public long created; // time_t?
public long updated; // time_t? public long updated; // time_t?
public string Title => Mershul.PtrToStringUtf8(title); public readonly string Title => Mershul.PtrToStringUtf8(title);
public string Description => Mershul.PtrToStringUtf8(description); public readonly string Description => Mershul.PtrToStringUtf8(description);
public string Definition => Mershul.PtrToStringUtf8(definition); public readonly string Definition => Mershul.PtrToStringUtf8(definition);
public string Author => Mershul.PtrToStringUtf8(author); public readonly string Author => Mershul.PtrToStringUtf8(author);
public string BadgeName => Mershul.PtrToStringUtf8(badge_name); public readonly string BadgeName => Mershul.PtrToStringUtf8(badge_name);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_leaderboard_definition_t public struct rc_api_leaderboard_definition_t
{ {
public int id; public uint id;
public int format; public int format;
public IntPtr title; public IntPtr title;
public IntPtr description; public IntPtr description;
public IntPtr definition; public IntPtr definition;
public int lower_is_better; public byte lower_is_better;
public int hidden; public byte hidden;
public string Title => Mershul.PtrToStringUtf8(title); public readonly string Title => Mershul.PtrToStringUtf8(title);
public string Description => Mershul.PtrToStringUtf8(description); public readonly string Description => Mershul.PtrToStringUtf8(description);
public string Definition => Mershul.PtrToStringUtf8(definition); public readonly string Definition => Mershul.PtrToStringUtf8(definition);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_game_data_response_t public struct rc_api_fetch_game_data_response_t
{ {
public int id; public uint id;
public RetroAchievements.ConsoleID console_id; public RetroAchievements.ConsoleID console_id;
public IntPtr title; public IntPtr title;
public IntPtr image_name; public IntPtr image_name;
public IntPtr rich_presence_script; public IntPtr rich_presence_script;
public IntPtr achievements; public unsafe rc_api_achievement_definition_t* achievements;
public int num_achievements; public uint num_achievements;
public IntPtr leaderboards; public unsafe rc_api_leaderboard_definition_t* leaderboards;
public int num_leaderboards; public uint num_leaderboards;
public rc_api_response_t response; public rc_api_response_t response;
public string Title => Mershul.PtrToStringUtf8(title); public readonly string Title => Mershul.PtrToStringUtf8(title);
public string ImageName => Mershul.PtrToStringUtf8(image_name); public readonly string ImageName => Mershul.PtrToStringUtf8(image_name);
public string RichPresenceScript => Mershul.PtrToStringUtf8(rich_presence_script); public readonly string RichPresenceScript => Mershul.PtrToStringUtf8(rich_presence_script);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -276,19 +311,29 @@ namespace BizHawk.Client.EmuHawk
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_resolve_hash_response_t public struct rc_api_resolve_hash_response_t
{ {
public int game_id; public uint game_id;
public rc_api_response_t response; public rc_api_response_t response;
} }
[StructLayout(LayoutKind.Sequential)]
public struct rc_api_lboard_entry_t
{
public IntPtr username;
public uint rank;
public int score;
public readonly string Username => Mershul.PtrToStringUtf8(username);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_submit_lboard_entry_response_t public struct rc_api_submit_lboard_entry_response_t
{ {
public int submitted_score; public int submitted_score;
public int best_score; public int best_score;
public int new_rank; public uint new_rank;
public int num_entries; public uint num_entries;
public IntPtr top_entries; public unsafe rc_api_lboard_entry_t* top_entries;
public int num_top_entries; public uint num_top_entries;
public rc_api_response_t response; public rc_api_response_t response;
} }
@ -299,13 +344,13 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int achievement_id; public uint achievement_id;
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
public bool hardcore; public bool hardcore;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string game_hash; public string game_hash;
public rc_api_award_achievement_request_t(string username, string api_token, int achievement_id, bool hardcore, string game_hash) public rc_api_award_achievement_request_t(string username, string api_token, uint achievement_id, bool hardcore, string game_hash)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -322,9 +367,9 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int game_id; public uint game_id;
public rc_api_fetch_game_data_request_t(string username, string api_token, int game_id) public rc_api_fetch_game_data_request_t(string username, string api_token, uint game_id)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -353,11 +398,11 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int game_id; public uint game_id;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string rich_presence; public string rich_presence;
public rc_api_ping_request_t(string username, string api_token, int game_id, string rich_presence) public rc_api_ping_request_t(string username, string api_token, uint game_id, string rich_presence)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -391,12 +436,12 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int leaderboard_id; public uint leaderboard_id;
public int score; public int score;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string game_hash; public string game_hash;
public rc_api_submit_lboard_entry_request_t(string username, string api_token, int leaderboard_id, int score, string game_hash) public rc_api_submit_lboard_entry_request_t(string username, string api_token, uint leaderboard_id, int score, string game_hash)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -406,46 +451,76 @@ namespace BizHawk.Client.EmuHawk
} }
} }
[StructLayout(LayoutKind.Sequential)]
public struct rc_api_achievement_awarded_entry_t
{
public IntPtr username;
public long awarded; // time_t?
public string Username => Mershul.PtrToStringUtf8(username);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_achievement_info_response_t public struct rc_api_fetch_achievement_info_response_t
{ {
public int id; public uint id;
public int game_id; public uint game_id;
public int num_awarded; public uint num_awarded;
public int num_players; public uint num_players;
public IntPtr recently_awarded; public unsafe rc_api_achievement_awarded_entry_t* recently_awarded;
public int num_recently_awarded; public uint num_recently_awarded;
public rc_api_response_t response; public rc_api_response_t response;
} }
[StructLayout(LayoutKind.Sequential)]
public struct rc_api_game_list_entry_t
{
public uint id;
public IntPtr name;
public readonly string Name => Mershul.PtrToStringUtf8(name);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_games_list_response_t public struct rc_api_fetch_games_list_response_t
{ {
public IntPtr entries; public unsafe rc_api_game_list_entry_t* entries;
public int num_entries; public uint num_entries;
public rc_api_response_t response; public rc_api_response_t response;
} }
[StructLayout(LayoutKind.Sequential)]
public struct rc_api_lboard_info_entry_t
{
public IntPtr username;
public uint rank;
public uint index;
public int score;
public long submitted; // time_t?
public readonly string Username => Mershul.PtrToStringUtf8(username);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_leaderboard_info_response_t public struct rc_api_fetch_leaderboard_info_response_t
{ {
public int id; public uint id;
public int format; public int format;
public int lower_is_better; public uint lower_is_better;
public IntPtr title; public IntPtr title;
public IntPtr description; public IntPtr description;
public IntPtr definition; public IntPtr definition;
public int game_id; public uint game_id;
public IntPtr author; public IntPtr author;
public long created; // time_t? public long created; // time_t?
public long updated; // time_t? public long updated; // time_t?
public IntPtr entries; public unsafe rc_api_lboard_info_entry_t* entries;
public int num_entries; public uint num_entries;
public rc_api_response_t response; public rc_api_response_t response;
public string Title => Mershul.PtrToStringUtf8(title); public readonly string Title => Mershul.PtrToStringUtf8(title);
public string Description => Mershul.PtrToStringUtf8(description); public readonly string Description => Mershul.PtrToStringUtf8(description);
public string Definition => Mershul.PtrToStringUtf8(definition); public readonly string Definition => Mershul.PtrToStringUtf8(definition);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -455,12 +530,12 @@ namespace BizHawk.Client.EmuHawk
public string username; public string username;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string api_token; public string api_token;
public int achievement_id; public uint achievement_id;
public int first_entry; public uint first_entry;
public int count; public uint count;
public int friends_only; public uint friends_only;
public rc_api_fetch_achievement_info_request_t(string username, string api_token, int achievement_id, int first_entry, int count, int friends_only) public rc_api_fetch_achievement_info_request_t(string username, string api_token, uint achievement_id, uint first_entry, uint count, uint friends_only)
{ {
this.username = username; this.username = username;
this.api_token = api_token; this.api_token = api_token;
@ -474,9 +549,9 @@ namespace BizHawk.Client.EmuHawk
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_games_list_request_t public struct rc_api_fetch_games_list_request_t
{ {
public int console_id; public uint console_id;
public rc_api_fetch_games_list_request_t(int console_id) public rc_api_fetch_games_list_request_t(uint console_id)
{ {
this.console_id = console_id; this.console_id = console_id;
} }
@ -485,13 +560,13 @@ namespace BizHawk.Client.EmuHawk
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct rc_api_fetch_leaderboard_info_request_t public struct rc_api_fetch_leaderboard_info_request_t
{ {
public int leaderboard_id; public uint leaderboard_id;
public int count; public uint count;
public int first_entry; public uint first_entry;
[MarshalAs(UnmanagedType.LPUTF8Str)] [MarshalAs(UnmanagedType.LPUTF8Str)]
public string username; public string username;
public rc_api_fetch_leaderboard_info_request_t(int leaderboard_id, int count, int first_entry, string username) public rc_api_fetch_leaderboard_info_request_t(uint leaderboard_id, uint count, uint first_entry, string username)
{ {
this.leaderboard_id = leaderboard_id; this.leaderboard_id = leaderboard_id;
this.count = count; this.count = count;
@ -576,11 +651,11 @@ namespace BizHawk.Client.EmuHawk
public delegate void rc_runtime_event_handler_t(IntPtr runtime_event); public delegate void rc_runtime_event_handler_t(IntPtr runtime_event);
[UnmanagedFunctionPointer(cc)] [UnmanagedFunctionPointer(cc)]
public delegate int rc_peek_t(int address, int num_bytes, IntPtr ud); public delegate uint rc_runtime_peek_t(uint address, uint num_bytes, IntPtr ud);
[UnmanagedFunctionPointer(cc)] [UnmanagedFunctionPointer(cc)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public delegate bool rc_runtime_validate_address_t(int address); public delegate bool rc_runtime_validate_address_t(uint address);
[UnmanagedFunctionPointer(cc)] [UnmanagedFunctionPointer(cc)]
public delegate void rc_hash_message_callback(string message); public delegate void rc_hash_message_callback(string message);
@ -607,7 +682,7 @@ namespace BizHawk.Client.EmuHawk
public abstract void rc_runtime_reset(IntPtr runtime); public abstract void rc_runtime_reset(IntPtr runtime);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_runtime_do_frame(IntPtr runtime, rc_runtime_event_handler_t rc_runtime_event_handler_t, rc_peek_t peek, IntPtr ud, IntPtr unused); public abstract void rc_runtime_do_frame(IntPtr runtime, rc_runtime_event_handler_t rc_runtime_event_handler_t, rc_runtime_peek_t peek, IntPtr ud, IntPtr unused);
[BizImport(cc)] [BizImport(cc)]
public abstract rc_error_t rc_runtime_progress_size(IntPtr runtime, IntPtr unused); public abstract rc_error_t rc_runtime_progress_size(IntPtr runtime, IntPtr unused);
@ -619,44 +694,44 @@ namespace BizHawk.Client.EmuHawk
public abstract rc_error_t rc_runtime_deserialize_progress(IntPtr runtime, byte[] serialized, IntPtr unused); public abstract rc_error_t rc_runtime_deserialize_progress(IntPtr runtime, byte[] serialized, IntPtr unused);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_runtime_invalidate_address(IntPtr runtime, int address); public abstract void rc_runtime_invalidate_address(IntPtr runtime, uint address);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_runtime_validate_addresses(IntPtr runtime, rc_runtime_event_handler_t event_handler, rc_runtime_validate_address_t validate_handler); public abstract void rc_runtime_validate_addresses(IntPtr runtime, rc_runtime_event_handler_t event_handler, rc_runtime_validate_address_t validate_handler);
[BizImport(cc)] [BizImport(cc)]
public abstract rc_error_t rc_runtime_activate_achievement(IntPtr runtime, int id, string memaddr, IntPtr unused, int unused_idx); public abstract rc_error_t rc_runtime_activate_achievement(IntPtr runtime, uint id, string memaddr, IntPtr unused, int unused_idx);
[BizImport(cc)] [BizImport(cc)]
public abstract rc_error_t rc_runtime_activate_lboard(IntPtr runtime, int id, string memaddr, IntPtr unused, int unused_idx); public abstract rc_error_t rc_runtime_activate_lboard(IntPtr runtime, uint id, string memaddr, IntPtr unused, int unused_idx);
[BizImport(cc)] [BizImport(cc)]
public abstract rc_error_t rc_runtime_activate_richpresence(IntPtr runtime, string script, IntPtr unused, int unused_idx); public abstract rc_error_t rc_runtime_activate_richpresence(IntPtr runtime, string script, IntPtr unused, int unused_idx);
[BizImport(cc)] [BizImport(cc)]
public abstract IntPtr rc_runtime_get_achievement(IntPtr runtime, int id); public abstract IntPtr rc_runtime_get_achievement(IntPtr runtime, uint id);
[BizImport(cc)] [BizImport(cc)]
public abstract IntPtr rc_runtime_get_lboard(IntPtr runtime, int id); public abstract IntPtr rc_runtime_get_lboard(IntPtr runtime, uint id);
[BizImport(cc)] [BizImport(cc)]
public abstract int rc_runtime_get_richpresence(IntPtr runtime, byte[] buffer, int buffersize, rc_peek_t peek, IntPtr ud, IntPtr unused); public abstract int rc_runtime_get_richpresence(IntPtr runtime, byte[] buffer, UIntPtr buffersize, rc_runtime_peek_t peek, IntPtr ud, IntPtr unused);
[BizImport(cc)] [BizImport(cc)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public abstract bool rc_runtime_get_achievement_measured(IntPtr runtime, int id, out int measured_value, out int measured_target); public abstract bool rc_runtime_get_achievement_measured(IntPtr runtime, uint id, out uint measured_value, out uint measured_target);
[BizImport(cc)] [BizImport(cc)]
public abstract int rc_runtime_format_achievement_measured(IntPtr runtime, int id, byte[] buffer, long buffer_size); public abstract int rc_runtime_format_achievement_measured(IntPtr runtime, uint id, byte[] buffer, UIntPtr buffer_size);
[BizImport(cc)] [BizImport(cc)]
public abstract int rc_runtime_format_lboard_value(byte[] buffer, int size, int value, int format); public abstract int rc_runtime_format_lboard_value(byte[] buffer, int size, int value, int format);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_runtime_deactivate_achievement(IntPtr runtime, int id); public abstract void rc_runtime_deactivate_achievement(IntPtr runtime, uint id);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_runtime_deactivate_lboard(IntPtr runtime, int id); public abstract void rc_runtime_deactivate_lboard(IntPtr runtime, uint id);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_hash_init_error_message_callback(rc_hash_message_callback callback); public abstract void rc_hash_init_error_message_callback(rc_hash_message_callback callback);
@ -672,14 +747,14 @@ namespace BizHawk.Client.EmuHawk
[BizImport(cc)] [BizImport(cc)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public abstract bool rc_hash_generate_from_buffer(byte[] hash, RetroAchievements.ConsoleID console_id, byte[] buffer, long buffer_size); public abstract bool rc_hash_generate_from_buffer(byte[] hash, RetroAchievements.ConsoleID console_id, byte[] buffer, UIntPtr buffer_size);
[BizImport(cc)] [BizImport(cc)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public abstract bool rc_hash_generate_from_file(byte[] hash, RetroAchievements.ConsoleID console_id, string path); public abstract bool rc_hash_generate_from_file(byte[] hash, RetroAchievements.ConsoleID console_id, string path);
[BizImport(cc)] [BizImport(cc)]
public abstract void rc_hash_initialize_iterator(IntPtr iterator, string path, byte[] buffer, long buffer_size); public abstract void rc_hash_initialize_iterator(IntPtr iterator, string path, byte[] buffer, UIntPtr buffer_size);
[BizImport(cc)] [BizImport(cc)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]

View File

@ -107,10 +107,10 @@ namespace BizHawk.Client.EmuHawk
RA.WarnDisableHardcore(null); RA.WarnDisableHardcore(null);
} }
protected override int IdentifyHash(string hash) protected override uint IdentifyHash(string hash)
=> RA.IdentifyHash(hash); => RA.IdentifyHash(hash);
protected override int IdentifyRom(byte[] rom) protected override uint IdentifyRom(byte[] rom)
=> RA.IdentifyRom(rom, rom.Length); => RA.IdentifyRom(rom, rom.Length);
public RAIntegration( public RAIntegration(
@ -213,7 +213,7 @@ namespace BizHawk.Client.EmuHawk
for (var i = 0; i < _memFunctions.Count; i++) for (var i = 0; i < _memFunctions.Count; i++)
{ {
_memFunctions[i].MemGuard = _memGuard; _memFunctions[i].MemGuard = _memGuard;
RA.InstallMemoryBank(i, _memFunctions[i].ReadFunc, _memFunctions[i].WriteFunc, _memFunctions[i].BankSize); RA.InstallMemoryBank(i, _memFunctions[i].ReadFunc, _memFunctions[i].WriteFunc, checked((int)_memFunctions[i].BankSize));
RA.InstallMemoryBankBlockReader(i, _memFunctions[i].ReadBlockFunc); RA.InstallMemoryBankBlockReader(i, _memFunctions[i].ReadBlockFunc);
} }
} }
@ -224,9 +224,9 @@ namespace BizHawk.Client.EmuHawk
{ {
var ids = GetRAGameIds(_mainForm.CurrentlyOpenRomArgs.OpenAdvanced, consoleId); var ids = GetRAGameIds(_mainForm.CurrentlyOpenRomArgs.OpenAdvanced, consoleId);
AllGamesVerified = !ids.Contains(0); AllGamesVerified = !ids.Contains(0u);
RA.ActivateGame(ids.Count > 0 ? ids[0] : 0); RA.ActivateGame(ids.Count > 0 ? ids[0] : 0u);
} }
else else
{ {

View File

@ -137,13 +137,13 @@ namespace BizHawk.Client.EmuHawk
public abstract void UpdateHWnd(IntPtr hwnd); public abstract void UpdateHWnd(IntPtr hwnd);
[BizImport(cc, EntryPoint = "_RA_IdentifyRom")] [BizImport(cc, EntryPoint = "_RA_IdentifyRom")]
public abstract int IdentifyRom(byte[] rom, int romSize); public abstract uint IdentifyRom(byte[] rom, int romSize);
[BizImport(cc, EntryPoint = "_RA_IdentifyHash")] [BizImport(cc, EntryPoint = "_RA_IdentifyHash")]
public abstract int IdentifyHash(string hash); public abstract uint IdentifyHash(string hash);
[BizImport(cc, EntryPoint = "_RA_ActivateGame")] [BizImport(cc, EntryPoint = "_RA_ActivateGame")]
public abstract void ActivateGame(int gameId); public abstract void ActivateGame(uint gameId);
[BizImport(cc, EntryPoint = "_RA_OnLoadNewRom")] [BizImport(cc, EntryPoint = "_RA_OnLoadNewRom")]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]

View File

@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
InternalDoRequest(apiParamsResult, ref api_req); InternalDoRequest(apiParamsResult, ref api_req);
} }
public CheevoUnlockRequest(string username, string api_token, int achievement_id, bool hardcore, string game_hash) public CheevoUnlockRequest(string username, string api_token, uint achievement_id, bool hardcore, string game_hash)
{ {
_apiParams = new(username, api_token, achievement_id, hardcore, game_hash); _apiParams = new(username, api_token, achievement_id, hardcore, game_hash);
} }
@ -40,8 +40,8 @@ namespace BizHawk.Client.EmuHawk
public class Cheevo public class Cheevo
{ {
public int ID { get; } public uint ID { get; }
public int Points { get; } public uint Points { get; }
public LibRCheevos.rc_runtime_achievement_category_t Category { get; } public LibRCheevos.rc_runtime_achievement_category_t Category { get; }
public string Title { get; } public string Title { get; }
public string Description { get; } public string Description { get; }
@ -129,9 +129,9 @@ namespace BizHawk.Client.EmuHawk
private readonly byte[] _cheevoFormatBuffer = new byte[1024]; private readonly byte[] _cheevoFormatBuffer = new byte[1024];
private string GetCheevoProgress(int id) private string GetCheevoProgress(uint id)
{ {
var len = _lib.rc_runtime_format_achievement_measured(_runtime, id, _cheevoFormatBuffer, _cheevoFormatBuffer.Length); var len = _lib.rc_runtime_format_achievement_measured(_runtime, id, _cheevoFormatBuffer, new((uint)_cheevoFormatBuffer.Length));
return Encoding.ASCII.GetString(_cheevoFormatBuffer, 0, len); return Encoding.ASCII.GetString(_cheevoFormatBuffer, 0, len);
} }

View File

@ -247,12 +247,11 @@ namespace BizHawk.Client.EmuHawk
// outputs results in the console // outputs results in the console
public static void DebugHash() public static void DebugHash()
{ {
using var ofd = new OpenFileDialog using var ofd = new OpenFileDialog();
{
CheckFileExists = true, ofd.CheckFileExists = true;
CheckPathExists = true, ofd.CheckPathExists = true;
InitialDirectory = PathUtils.ExeDirectoryPath, ofd.InitialDirectory = PathUtils.ExeDirectoryPath;
};
string path = null; string path = null;
if (ofd.ShowDialog() if (ofd.ShowDialog()

View File

@ -16,15 +16,15 @@ namespace BizHawk.Client.EmuHawk
private ConsoleID _consoleId; private ConsoleID _consoleId;
private string _gameHash; private string _gameHash;
private readonly Dictionary<string, int> _cachedGameIds = new(); // keep around IDs per hash to avoid unneeded API calls for a simple RebootCore private readonly Dictionary<string, uint> _cachedGameIds = new(); // keep around IDs per hash to avoid unneeded API calls for a simple RebootCore
private GameData _gameData; private GameData _gameData;
private readonly Dictionary<int, GameData> _cachedGameDatas = new(); // keep game data around to avoid unneeded API calls for a simple RebootCore private readonly Dictionary<uint, GameData> _cachedGameDatas = new(); // keep game data around to avoid unneeded API calls for a simple RebootCore
public sealed class UserUnlocksRequest : RCheevoHttpRequest public sealed class UserUnlocksRequest : RCheevoHttpRequest
{ {
private LibRCheevos.rc_api_fetch_user_unlocks_request_t _apiParams; private LibRCheevos.rc_api_fetch_user_unlocks_request_t _apiParams;
private readonly IReadOnlyDictionary<int, Cheevo> _cheevos; private readonly IReadOnlyDictionary<uint, Cheevo> _cheevos;
protected override void ResponseCallback(byte[] serv_resp) protected override void ResponseCallback(byte[] serv_resp)
{ {
@ -33,10 +33,9 @@ namespace BizHawk.Client.EmuHawk
{ {
unsafe unsafe
{ {
var unlocks = (int*)resp.achievement_ids;
for (var i = 0; i < resp.num_achievement_ids; i++) for (var i = 0; i < resp.num_achievement_ids; i++)
{ {
if (_cheevos.TryGetValue(unlocks![i], out var cheevo)) if (_cheevos.TryGetValue(resp.achievement_ids[i], out var cheevo))
{ {
cheevo.SetUnlocked(_apiParams.hardcore, true); cheevo.SetUnlocked(_apiParams.hardcore, true);
} }
@ -57,7 +56,7 @@ namespace BizHawk.Client.EmuHawk
InternalDoRequest(apiParamsResult, ref api_req); InternalDoRequest(apiParamsResult, ref api_req);
} }
public UserUnlocksRequest(string username, string api_token, int game_id, bool hardcore, IReadOnlyDictionary<int, Cheevo> cheevos) public UserUnlocksRequest(string username, string api_token, uint game_id, bool hardcore, IReadOnlyDictionary<uint, Cheevo> cheevos)
{ {
_apiParams = new(username, api_token, game_id, hardcore); _apiParams = new(username, api_token, game_id, hardcore);
_cheevos = cheevos; _cheevos = cheevos;
@ -95,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
InternalDoRequest(apiParamsResult, ref api_req); InternalDoRequest(apiParamsResult, ref api_req);
} }
public GameDataRequest(string username, string api_token, int game_id, Func<bool> allowUnofficialCheevos) public GameDataRequest(string username, string api_token, uint game_id, Func<bool> allowUnofficialCheevos)
{ {
_apiParams = new(username, api_token, game_id); _apiParams = new(username, api_token, game_id);
_allowUnofficialCheevos = allowUnofficialCheevos; _allowUnofficialCheevos = allowUnofficialCheevos;
@ -144,7 +143,7 @@ namespace BizHawk.Client.EmuHawk
public class GameData public class GameData
{ {
public int GameID { get; } public uint GameID { get; }
public ConsoleID ConsoleID { get; } public ConsoleID ConsoleID { get; }
public string Title { get; } public string Title { get; }
private string ImageName { get; } private string ImageName { get; }
@ -153,14 +152,14 @@ namespace BizHawk.Client.EmuHawk
private ImageRequest _gameBadgeImageRequest; private ImageRequest _gameBadgeImageRequest;
private readonly IReadOnlyDictionary<int, Cheevo> _cheevos; private readonly IReadOnlyDictionary<uint, Cheevo> _cheevos;
private readonly IReadOnlyDictionary<int, LBoard> _lboards; private readonly IReadOnlyDictionary<uint, LBoard> _lboards;
public IEnumerable<Cheevo> CheevoEnumerable => _cheevos.Values; public IEnumerable<Cheevo> CheevoEnumerable => _cheevos.Values;
public IEnumerable<LBoard> LBoardEnumerable => _lboards.Values; public IEnumerable<LBoard> LBoardEnumerable => _lboards.Values;
public Cheevo GetCheevoById(int i) => _cheevos[i]; public Cheevo GetCheevoById(uint i) => _cheevos[i];
public LBoard GetLboardById(int i) => _lboards[i]; public LBoard GetLboardById(uint i) => _lboards[i];
public UserUnlocksRequest InitUnlocks(string username, string api_token, bool hardcore) public UserUnlocksRequest InitUnlocks(string username, string api_token, bool hardcore)
{ {
@ -184,7 +183,7 @@ namespace BizHawk.Client.EmuHawk
return requests; return requests;
} }
public int TotalCheevoPoints(bool hardcore) public long TotalCheevoPoints(bool hardcore)
=> _cheevos?.Values.Sum(c => c.IsEnabled && !c.Invalid && c.IsUnlocked(hardcore) ? c.Points : 0) ?? 0; => _cheevos?.Values.Sum(c => c.IsEnabled && !c.Invalid && c.IsUnlocked(hardcore) ? c.Points : 0) ?? 0;
public unsafe GameData(in LibRCheevos.rc_api_fetch_game_data_response_t resp, Func<bool> allowUnofficialCheevos) public unsafe GameData(in LibRCheevos.rc_api_fetch_game_data_response_t resp, Func<bool> allowUnofficialCheevos)
@ -195,20 +194,18 @@ namespace BizHawk.Client.EmuHawk
ImageName = resp.ImageName; ImageName = resp.ImageName;
RichPresenseScript = resp.RichPresenceScript; RichPresenseScript = resp.RichPresenceScript;
var cheevos = new Dictionary<int, Cheevo>(); var cheevos = new Dictionary<uint, Cheevo>();
var cptr = (LibRCheevos.rc_api_achievement_definition_t*)resp.achievements;
for (var i = 0; i < resp.num_achievements; i++) for (var i = 0; i < resp.num_achievements; i++)
{ {
cheevos.Add(cptr![i].id, new(in cptr[i], allowUnofficialCheevos)); cheevos.Add(resp.achievements[i].id, new(in resp.achievements[i], allowUnofficialCheevos));
} }
_cheevos = cheevos; _cheevos = cheevos;
var lboards = new Dictionary<int, LBoard>(); var lboards = new Dictionary<uint, LBoard>();
var lptr = (LibRCheevos.rc_api_leaderboard_definition_t*)resp.leaderboards;
for (var i = 0; i < resp.num_leaderboards; i++) for (var i = 0; i < resp.num_leaderboards; i++)
{ {
lboards.Add(lptr![i].id, new(in lptr[i])); lboards.Add(resp.leaderboards[i].id, new(in resp.leaderboards[i]));
} }
_lboards = lboards; _lboards = lboards;
@ -222,8 +219,8 @@ namespace BizHawk.Client.EmuHawk
ImageName = gameData.ImageName; ImageName = gameData.ImageName;
RichPresenseScript = gameData.RichPresenseScript; RichPresenseScript = gameData.RichPresenseScript;
_cheevos = gameData.CheevoEnumerable.ToDictionary<Cheevo, int, Cheevo>(cheevo => cheevo.ID, cheevo => new(in cheevo, allowUnofficialCheevos)); _cheevos = gameData.CheevoEnumerable.ToDictionary<Cheevo, uint, Cheevo>(cheevo => cheevo.ID, cheevo => new(in cheevo, allowUnofficialCheevos));
_lboards = gameData.LBoardEnumerable.ToDictionary<LBoard, int, LBoard>(lboard => lboard.ID, lboard => new(in lboard)); _lboards = gameData.LBoardEnumerable.ToDictionary<LBoard, uint, LBoard>(lboard => lboard.ID, lboard => new(in lboard));
} }
public GameData() public GameData()
@ -235,7 +232,7 @@ namespace BizHawk.Client.EmuHawk
private sealed class ResolveHashRequest : RCheevoHttpRequest private sealed class ResolveHashRequest : RCheevoHttpRequest
{ {
private LibRCheevos.rc_api_resolve_hash_request_t _apiParams; private LibRCheevos.rc_api_resolve_hash_request_t _apiParams;
public int GameID { get; private set; } public uint GameID { get; private set; }
// eh? not sure I want this retried, given the blocking behavior // eh? not sure I want this retried, given the blocking behavior
public override bool ShouldRetry => false; public override bool ShouldRetry => false;
@ -268,7 +265,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private int SendHash(string hash) private uint SendHash(string hash)
{ {
var resolveHashRequest = new ResolveHashRequest(hash); var resolveHashRequest = new ResolveHashRequest(hash);
PushRequest(resolveHashRequest); PushRequest(resolveHashRequest);
@ -276,16 +273,16 @@ namespace BizHawk.Client.EmuHawk
return resolveHashRequest.GameID; return resolveHashRequest.GameID;
} }
protected override int IdentifyHash(string hash) protected override uint IdentifyHash(string hash)
{ {
_gameHash ??= hash; _gameHash ??= hash;
return _cachedGameIds.GetValueOrPut(hash, SendHash); return _cachedGameIds.GetValueOrPut(hash, SendHash);
} }
protected override int IdentifyRom(byte[] rom) protected override uint IdentifyRom(byte[] rom)
{ {
var hash = new byte[33]; var hash = new byte[33];
if (_lib.rc_hash_generate_from_buffer(hash, _consoleId, rom, rom.Length)) if (_lib.rc_hash_generate_from_buffer(hash, _consoleId, rom, new((uint)rom.Length)))
{ {
return IdentifyHash(Encoding.ASCII.GetString(hash, 0, 32)); return IdentifyHash(Encoding.ASCII.GetString(hash, 0, 32));
} }
@ -315,7 +312,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private GameData GetGameData(int id) private GameData GetGameData(uint id)
{ {
var gameDataRequest = new GameDataRequest(Username, ApiToken, id, () => AllowUnofficialCheevos); var gameDataRequest = new GameDataRequest(Username, ApiToken, id, () => AllowUnofficialCheevos);
PushRequest(gameDataRequest); PushRequest(gameDataRequest);

View File

@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
InternalDoRequest(apiParamsResult, ref api_req); InternalDoRequest(apiParamsResult, ref api_req);
} }
public LboardTriggerRequest(string username, string api_token, int id, int value, string hash) public LboardTriggerRequest(string username, string api_token, uint id, int value, string hash)
{ {
_apiParams = new(username, api_token, id, value, hash); _apiParams = new(username, api_token, id, value, hash);
} }
@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
public class LBoard public class LBoard
{ {
public int ID { get; } public uint ID { get; }
public int Format { get; } public int Format { get; }
public string Title { get; } public string Title { get; }
public string Description { get; } public string Description { get; }

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
{ {
private LibRCheevos.rc_api_start_session_request_t _apiParams; private LibRCheevos.rc_api_start_session_request_t _apiParams;
public StartGameSessionRequest(string username, string apiToken, int gameId) public StartGameSessionRequest(string username, string apiToken, uint gameId)
{ {
_apiParams = new(username, apiToken, gameId); _apiParams = new(username, apiToken, gameId);
} }
@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
{ {
private LibRCheevos.rc_api_ping_request_t _apiParams; private LibRCheevos.rc_api_ping_request_t _apiParams;
public PingRequest(string username, string apiToken, int gameId, string richPresence) public PingRequest(string username, string apiToken, uint gameId, string richPresence)
{ {
_apiParams = new(username, apiToken, gameId, richPresence); _apiParams = new(username, apiToken, gameId, richPresence);
} }
@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (RichPresenceActive) if (RichPresenceActive)
{ {
var len = _lib.rc_runtime_get_richpresence(_runtime, _richPresenceBuffer, _richPresenceBuffer.Length, _peekcb, IntPtr.Zero, IntPtr.Zero); var len = _lib.rc_runtime_get_richpresence(_runtime, _richPresenceBuffer, new((uint)_richPresenceBuffer.Length), _peekcb, IntPtr.Zero, IntPtr.Zero);
CurrentRichPresence = Encoding.UTF8.GetString(_richPresenceBuffer, 0, len); CurrentRichPresence = Encoding.UTF8.GetString(_richPresenceBuffer, 0, len);
} }
else else

View File

@ -41,9 +41,9 @@ namespace BizHawk.Client.EmuHawk
private IntPtr _runtime; private IntPtr _runtime;
private readonly LibRCheevos.rc_runtime_event_handler_t _eventcb; private readonly LibRCheevos.rc_runtime_event_handler_t _eventcb;
private readonly LibRCheevos.rc_peek_t _peekcb; private readonly LibRCheevos.rc_runtime_peek_t _peekcb;
private readonly Dictionary<int, (ReadMemoryFunc Func, int Start)> _readMap = new(); private readonly Dictionary<uint, (ReadMemoryFunc Func, uint Start)> _readMap = new();
private ToolStripMenuItem _hardcoreModeMenuItem; private ToolStripMenuItem _hardcoreModeMenuItem;
private bool _hardcoreMode; private bool _hardcoreMode;
@ -369,12 +369,12 @@ namespace BizHawk.Client.EmuHawk
{ {
_memFunctions = CreateMemoryBanks(_consoleId, Domains, Emu.CanDebug() ? Emu.AsDebuggable() : null); _memFunctions = CreateMemoryBanks(_consoleId, Domains, Emu.CanDebug() ? Emu.AsDebuggable() : null);
var addr = 0; uint addr = 0;
foreach (var memFunctions in _memFunctions) foreach (var memFunctions in _memFunctions)
{ {
if (memFunctions.ReadFunc is not null) if (memFunctions.ReadFunc is not null)
{ {
for (var i = 0; i < memFunctions.BankSize; i++) for (uint i = 0; i < memFunctions.BankSize; i++)
{ {
_readMap.Add(addr + i, (memFunctions.ReadFunc, addr)); _readMap.Add(addr + i, (memFunctions.ReadFunc, addr));
} }
@ -392,7 +392,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var ids = GetRAGameIds(_mainForm.CurrentlyOpenRomArgs.OpenAdvanced, _consoleId); var ids = GetRAGameIds(_mainForm.CurrentlyOpenRomArgs.OpenAdvanced, _consoleId);
AllGamesVerified = !ids.Contains(0); AllGamesVerified = !ids.Contains(0u);
var gameId = ids.Count > 0 ? ids[0] : 0; var gameId = ids.Count > 0 ? ids[0] : 0;
_gameData = new(); _gameData = new();
@ -427,7 +427,9 @@ namespace BizHawk.Client.EmuHawk
// validate addresses now that we have cheevos init // validate addresses now that we have cheevos init
// ReSharper disable once ConvertToLocalFunction // ReSharper disable once ConvertToLocalFunction
#pragma warning disable IDE0039
LibRCheevos.rc_runtime_validate_address_t peekcb = address => _readMap.ContainsKey(address); LibRCheevos.rc_runtime_validate_address_t peekcb = address => _readMap.ContainsKey(address);
#pragma warning restore IDE0039
_lib.rc_runtime_validate_addresses(_runtime, _eventcb, peekcb); _lib.rc_runtime_validate_addresses(_runtime, _eventcb, peekcb);
_gameInfoForm.Restart(_gameData.Title, _gameData.TotalCheevoPoints(HardcoreMode), CurrentRichPresence ?? "N/A"); _gameInfoForm.Restart(_gameData.Title, _gameData.TotalCheevoPoints(HardcoreMode), CurrentRichPresence ?? "N/A");
@ -613,10 +615,10 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private int PeekCallback(int address, int num_bytes, IntPtr ud) private uint PeekCallback(uint address, uint num_bytes, IntPtr ud)
{ {
byte Peek(int addr) uint Peek(uint addr)
=> _readMap.TryGetValue(addr, out var reader) ? reader.Func(addr - reader.Start) : (byte)0; => _readMap.TryGetValue(addr, out var reader) ? reader.Func(addr - reader.Start) : 0u;
return num_bytes switch return num_bytes switch
{ {

View File

@ -23,9 +23,9 @@ namespace BizHawk.Client.EmuHawk
private Bitmap _unlockedBadge, _lockedBadge; private Bitmap _unlockedBadge, _lockedBadge;
private readonly RCheevos.Cheevo _cheevo; private readonly RCheevos.Cheevo _cheevo;
private readonly Func<int, string> _getCheevoProgress; private readonly Func<uint, string> _getCheevoProgress;
public RCheevosAchievementForm(RCheevos.Cheevo cheevo, Func<int, string> getCheevoProgress) public RCheevosAchievementForm(RCheevos.Cheevo cheevo, Func<uint, string> getCheevoProgress)
{ {
InitializeComponent(); InitializeComponent();
titleBox.Text = cheevo.Title; titleBox.Text = cheevo.Title;

View File

@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void Restart(IEnumerable<RCheevos.Cheevo> cheevos, Func<int, string> getCheevoProgress) public void Restart(IEnumerable<RCheevos.Cheevo> cheevos, Func<uint, string> getCheevoProgress)
{ {
flowLayoutPanel1.Controls.Clear(); flowLayoutPanel1.Controls.Clear();
DisposeCheevoForms(); DisposeCheevoForms();
@ -52,14 +52,14 @@ namespace BizHawk.Client.EmuHawk
{ {
_updateCooldown = 5; _updateCooldown = 5;
for (int i = 0; i < _cheevoForms.Length; i++) foreach (var form in _cheevoForms)
{ {
_cheevoForms[i].OnFrameAdvance(hardcore); form.OnFrameAdvance(hardcore);
} }
var reorderedForms = _cheevoForms.OrderByDescending(f => f.OrderByKey()).ToArray(); var reorderedForms = _cheevoForms.OrderByDescending(f => f.OrderByKey()).ToArray();
for (int i = 0; i < _cheevoForms.Length; i++) for (var i = 0; i < _cheevoForms.Length; i++)
{ {
if (_cheevoForms[i] != reorderedForms[i]) if (_cheevoForms[i] != reorderedForms[i])
{ {

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
Shown += (_, _) => IsShown = true; Shown += (_, _) => IsShown = true;
} }
public void Restart(string gameTitle, int totalPoints, string richPresence) public void Restart(string gameTitle, long totalPoints, string richPresence)
{ {
titleTextBox.Text = gameTitle; titleTextBox.Text = gameTitle;
totalPointsBox.Text = totalPoints.ToString(); totalPointsBox.Text = totalPoints.ToString();
@ -28,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
_iconLoaded = false; _iconLoaded = false;
} }
public void OnFrameAdvance(Bitmap gameIcon, int totalPoints, string lboardStr, string richPresence) public void OnFrameAdvance(Bitmap gameIcon, long totalPoints, string lboardStr, string richPresence)
{ {
// probably bad idea to set this every frame, so // probably bad idea to set this every frame, so
if (!_iconLoaded && gameIcon is not null) if (!_iconLoaded && gameIcon is not null)

View File

@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public abstract partial class RetroAchievements public abstract partial class RetroAchievements
{ {
public enum ConsoleID : int public enum ConsoleID : uint
{ {
UnknownConsoleID = 0, UnknownConsoleID = 0,
MegaDrive = 1, MegaDrive = 1,

View File

@ -13,10 +13,10 @@ namespace BizHawk.Client.EmuHawk
public abstract partial class RetroAchievements public abstract partial class RetroAchievements
{ {
protected bool AllGamesVerified { get; set; } protected bool AllGamesVerified { get; set; }
protected abstract int IdentifyHash(string hash); protected abstract uint IdentifyHash(string hash);
protected abstract int IdentifyRom(byte[] rom); protected abstract uint IdentifyRom(byte[] rom);
private int HashDisc(string path, ConsoleID consoleID) private uint HashDisc(string path, ConsoleID consoleID)
{ {
// this shouldn't throw in practice, this is only called when loading was successful! // this shouldn't throw in practice, this is only called when loading was successful!
using var disc = DiscExtensions.CreateAnyType(path, e => throw new(e)); using var disc = DiscExtensions.CreateAnyType(path, e => throw new(e));
@ -276,7 +276,7 @@ namespace BizHawk.Client.EmuHawk
return IdentifyHash(hash); return IdentifyHash(hash);
} }
private int HashArcade(string path) private uint HashArcade(string path)
{ {
// Arcade wants to just hash the filename (with no extension) // Arcade wants to just hash the filename (with no extension)
var name = Encoding.UTF8.GetBytes(Path.GetFileNameWithoutExtension(path)); var name = Encoding.UTF8.GetBytes(Path.GetFileNameWithoutExtension(path));
@ -284,7 +284,7 @@ namespace BizHawk.Client.EmuHawk
return IdentifyHash(hash); return IdentifyHash(hash);
} }
private int Hash3DS(string path) private uint Hash3DS(string path)
{ {
// 3DS is too big to hash as a byte array... // 3DS is too big to hash as a byte array...
var hash = new byte[33]; var hash = new byte[33];
@ -292,9 +292,9 @@ namespace BizHawk.Client.EmuHawk
? IdentifyHash(Encoding.ASCII.GetString(hash, 0, 32)) : 0; ? IdentifyHash(Encoding.ASCII.GetString(hash, 0, 32)) : 0;
} }
protected IReadOnlyList<int> GetRAGameIds(IOpenAdvanced ioa, ConsoleID consoleID) protected IReadOnlyList<uint> GetRAGameIds(IOpenAdvanced ioa, ConsoleID consoleID)
{ {
var ret = new List<int>(); var ret = new List<uint>();
switch (ioa.TypeName) switch (ioa.TypeName)
{ {
case OpenAdvancedTypes.OpenRom: case OpenAdvancedTypes.OpenRom:

View File

@ -94,32 +94,32 @@ namespace BizHawk.Client.EmuHawk
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate byte ReadMemoryFunc(int address); public delegate byte ReadMemoryFunc(uint address);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void WriteMemoryFunc(int address, byte value); public delegate void WriteMemoryFunc(uint address, byte value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ReadMemoryBlockFunc(int address, IntPtr buffer, int bytes); public delegate uint ReadMemoryBlockFunc(uint address, IntPtr buffer, uint bytes);
protected class MemFunctions protected class MemFunctions
{ {
protected readonly MemoryDomain _domain; protected readonly MemoryDomain _domain;
private readonly int _domainAddrStart; // addr of _domain where bank begins private readonly uint _domainAddrStart; // addr of _domain where bank begins
private readonly int _addressMangler; // of course, let's *not* correct internal core byteswapping! private readonly uint _addressMangler; // of course, let's *not* correct internal core byteswapping!
public ReadMemoryFunc ReadFunc { get; protected init; } public ReadMemoryFunc ReadFunc { get; protected init; }
public WriteMemoryFunc WriteFunc { get; protected init; } public WriteMemoryFunc WriteFunc { get; protected init; }
public ReadMemoryBlockFunc ReadBlockFunc { get; protected init; } public ReadMemoryBlockFunc ReadBlockFunc { get; protected init; }
public readonly int BankSize; public readonly uint BankSize;
public RAMemGuard MemGuard { get; set; } public RAMemGuard MemGuard { get; set; }
protected virtual int FixAddr(int addr) protected virtual uint FixAddr(uint addr)
=> _domainAddrStart + addr; => _domainAddrStart + addr;
protected virtual byte ReadMem(int addr) protected virtual byte ReadMem(uint addr)
{ {
using (MemGuard.EnterExit()) using (MemGuard.EnterExit())
{ {
@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
protected virtual void WriteMem(int addr, byte val) protected virtual void WriteMem(uint addr, byte val)
{ {
using (MemGuard.EnterExit()) using (MemGuard.EnterExit())
{ {
@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
protected virtual int ReadMemBlock(int addr, IntPtr buffer, int bytes) protected virtual uint ReadMemBlock(uint addr, IntPtr buffer, uint bytes)
{ {
addr = FixAddr(addr); addr = FixAddr(addr);
@ -153,7 +153,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var ret = new byte[length]; var ret = new byte[length];
_domain.BulkPeekByte(((long)addr).RangeToExclusive(end), ret); _domain.BulkPeekByte(((long)addr).RangeToExclusive(end), ret);
Marshal.Copy(ret, 0, buffer, length); Marshal.Copy(ret, 0, buffer, (int)length);
} }
else else
{ {
@ -170,7 +170,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public MemFunctions(MemoryDomain domain, int domainAddrStart, long bankSize, int addressMangler = 0) public MemFunctions(MemoryDomain domain, uint domainAddrStart, long bankSize, uint addressMangler = 0)
{ {
_domain = domain; _domain = domain;
_domainAddrStart = domainAddrStart; _domainAddrStart = domainAddrStart;
@ -180,12 +180,12 @@ namespace BizHawk.Client.EmuHawk
WriteFunc = WriteMem; WriteFunc = WriteMem;
ReadBlockFunc = ReadMemBlock; ReadBlockFunc = ReadMemBlock;
if (bankSize > int.MaxValue) if (bankSize > uint.MaxValue)
{ {
throw new OverflowException("bankSize is too big!"); throw new OverflowException("bankSize is too big!");
} }
BankSize = (int)bankSize; BankSize = (uint)bankSize;
} }
} }
@ -203,10 +203,10 @@ namespace BizHawk.Client.EmuHawk
// this is a complete hack because the libretro Intelli core sucks and so achievements are made expecting this format // this is a complete hack because the libretro Intelli core sucks and so achievements are made expecting this format
private class IntelliMemFunctions : MemFunctions private class IntelliMemFunctions : MemFunctions
{ {
protected override int FixAddr(int addr) protected override uint FixAddr(uint addr)
=> (addr >> 1) + (~addr & 1); => (addr >> 1) + (~addr & 1);
protected override byte ReadMem(int addr) protected override byte ReadMem(uint addr)
{ {
if ((addr & 2) != 0) if ((addr & 2) != 0)
{ {
@ -216,7 +216,7 @@ namespace BizHawk.Client.EmuHawk
return base.ReadMem(addr); return base.ReadMem(addr);
} }
protected override void WriteMem(int addr, byte val) protected override void WriteMem(uint addr, byte val)
{ {
if ((addr & 2) != 0) if ((addr & 2) != 0)
{ {
@ -226,7 +226,7 @@ namespace BizHawk.Client.EmuHawk
base.WriteMem(addr, val); base.WriteMem(addr, val);
} }
protected override int ReadMemBlock(int addr, IntPtr buffer, int bytes) protected override uint ReadMemBlock(uint addr, IntPtr buffer, uint bytes)
{ {
if (addr >= BankSize) if (addr >= BankSize)
{ {
@ -268,7 +268,7 @@ namespace BizHawk.Client.EmuHawk
private readonly IDebuggable _debuggable; private readonly IDebuggable _debuggable;
private readonly MemoryDomain _vram; // our vram is unpacked, but RA expects it packed private readonly MemoryDomain _vram; // our vram is unpacked, but RA expects it packed
private byte ReadVRAMPacked(int addr) private byte ReadVRAMPacked(uint addr)
{ {
return (byte)(((_vram.PeekByte(addr * 4 + 0) & 3) << 6) return (byte)(((_vram.PeekByte(addr * 4 + 0) & 3) << 6)
| ((_vram.PeekByte(addr * 4 + 1) & 3) << 4) | ((_vram.PeekByte(addr * 4 + 1) & 3) << 4)
@ -276,7 +276,7 @@ namespace BizHawk.Client.EmuHawk
| ((_vram.PeekByte(addr * 4 + 3) & 3) << 0)); | ((_vram.PeekByte(addr * 4 + 3) & 3) << 0));
} }
protected override byte ReadMem(int addr) protected override byte ReadMem(uint addr)
{ {
using (MemGuard.EnterExit()) using (MemGuard.EnterExit())
{ {
@ -291,7 +291,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
protected override void WriteMem(int addr, byte val) protected override void WriteMem(uint addr, byte val)
{ {
using (MemGuard.EnterExit()) using (MemGuard.EnterExit())
{ {
@ -310,7 +310,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
protected override int ReadMemBlock(int addr, IntPtr buffer, int bytes) protected override uint ReadMemBlock(uint addr, IntPtr buffer, uint bytes)
{ {
if (addr >= BankSize) if (addr >= BankSize)
{ {
@ -367,12 +367,12 @@ namespace BizHawk.Client.EmuHawk
}; };
// these consoles will use part of the system bus at an offset // these consoles will use part of the system bus at an offset
private static readonly Dictionary<ConsoleID, (int Start, int Size)[]> UsePartialSysBus = new() private static readonly Dictionary<ConsoleID, (uint Start, uint Size)[]> UsePartialSysBus = new()
{ {
[ConsoleID.MasterSystem] = new[] { (0xC000, 0x2000) }, [ConsoleID.MasterSystem] = new[] { (0xC000u, 0x2000u) },
[ConsoleID.GameGear] = new[] { (0xC000, 0x2000) }, [ConsoleID.GameGear] = new[] { (0xC000u, 0x2000u) },
[ConsoleID.Colecovision] = new[] { (0x6000, 0x400) }, [ConsoleID.Colecovision] = new[] { (0x6000u, 0x400u) },
[ConsoleID.SG1000] = new[] { (0xC000, 0x2000), (0x2000, 0x2000), (0x8000, 0x2000) }, [ConsoleID.SG1000] = new[] { (0xC000u, 0x2000u), (0x2000u, 0x2000u), (0x8000u, 0x2000u) },
}; };
// anything more complicated will be handled accordingly // anything more complicated will be handled accordingly
@ -381,7 +381,7 @@ namespace BizHawk.Client.EmuHawk
{ {
var mfs = new List<MemFunctions>(); var mfs = new List<MemFunctions>();
void TryAddDomain(string domain, int? size = null, int addressMangler = 0) void TryAddDomain(string domain, uint? size = null, uint addressMangler = 0)
{ {
if (domains.Has(domain)) if (domains.Has(domain))
{ {
@ -422,7 +422,7 @@ namespace BizHawk.Client.EmuHawk
mfs.Add(new(domains["68K RAM"], 0, domains["68K RAM"].Size, 1)); mfs.Add(new(domains["68K RAM"], 0, domains["68K RAM"].Size, 1));
TryAddDomain("32X RAM", addressMangler: 1); TryAddDomain("32X RAM", addressMangler: 1);
// our picodrive doesn't byteswap its SRAM, so... // our picodrive doesn't byteswap its SRAM, so...
TryAddDomain("SRAM", addressMangler: domains["SRAM"] is MemoryDomainIntPtrSwap16Monitor ? 1 : 0); TryAddDomain("SRAM", addressMangler: domains["SRAM"] is MemoryDomainIntPtrSwap16Monitor ? 1u : 0u);
break; break;
case ConsoleID.SNES: case ConsoleID.SNES:
mfs.Add(new(domains["WRAM"], 0, domains["WRAM"].Size)); mfs.Add(new(domains["WRAM"], 0, domains["WRAM"].Size));