refactor: Entire code base, thread and log usage

Boils down to:
- Include headers
- Reduce boiler plate with helpers
- Swap out explicit usages with core API layer
  and ensure the right API is configured beforehand
This commit is contained in:
icex2
2024-08-14 17:53:51 +02:00
parent 82d1a2df52
commit 93e0a090bc
338 changed files with 1307 additions and 641 deletions
+2
View File
@@ -4,6 +4,8 @@ deplibs_ddrhook2 := \
avs \
libs_ddrhook2 := \
avs-util \
core \
acioemu \
ddrhook-util \
p3ioemu \
+18 -10
View File
@@ -2,9 +2,14 @@
#include <stdbool.h>
#include "avs-util/core-interop.h"
#include "bemanitools/ddrio.h"
#include "bemanitools/eamio.h"
#include "core/log.h"
#include "core/thread.h"
#include "ddrhook-util/_com4.h"
#include "ddrhook-util/extio.h"
#include "ddrhook-util/gfx.h"
@@ -25,7 +30,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/log.h"
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
static bool my_dll_entry_main(void);
@@ -119,10 +123,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info("Initializing DDR IO backend");
ddr_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(ddr_io_set_loggers);
ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = ddr_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
return false;
@@ -131,11 +137,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (com4) {
log_info("Initializing card reader backend");
eam_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(eam_io_set_loggers);
ok =
eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
return false;
@@ -174,8 +181,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
goto end;
}
log_to_external(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
// Use AVS APIs
avs_util_core_interop_thread_avs_impl_set();
avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
+2 -1
View File
@@ -1,3 +1,5 @@
#include "core/log.h"
#include "ddrhook2/master.h"
#include "ddrhook-util/dinput.h"
@@ -10,7 +12,6 @@
#include "p3ioemu/devmgr.h"
#include "util/defs.h"
#include "util/log.h"
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);