Support WUPS 0.4, remove some unused code.

This commit is contained in:
Maschell 2021-03-16 17:55:32 +01:00
parent 1491e2283f
commit f11649bc36
7 changed files with 44 additions and 294 deletions

View File

@ -1,7 +1,7 @@
FROM wiiuenv/devkitppc:20210101 FROM wiiuenv/devkitppc:20210101
COPY --from=wiiuenv/wiiumodulesystem:20210219 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiumodulesystem:20210313 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20210109 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20210316 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libfunctionpatcher:20210109 /artifacts $DEVKITPRO COPY --from=wiiuenv/libfunctionpatcher:20210109 /artifacts $DEVKITPRO
WORKDIR project WORKDIR project

View File

@ -88,20 +88,6 @@ void PluginManagement::memsetBSS(const std::vector<PluginContainer> &plugins) {
} }
} }
void PluginManagement::callDeinitHooks(plugin_information_t *pluginInformation) {
CallHook(pluginInformation, WUPS_LOADER_HOOK_RELEASE_FOREGROUND);
CallHook(pluginInformation, WUPS_LOADER_HOOK_APPLICATION_END);
CallHook(pluginInformation, WUPS_LOADER_HOOK_DEINIT_PLUGIN);
CallHook(pluginInformation, WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
CallHook(pluginInformation, WUPS_LOADER_HOOK_FINI_WUT_STDCPP);
CallHook(pluginInformation, WUPS_LOADER_HOOK_FINI_WUT_NEWLIB);
CallHook(pluginInformation, WUPS_LOADER_HOOK_FINI_WUT_MALLOC);
DEBUG_FUNCTION_LINE_VERBOSE("Done calling deinit hooks");
}
void PluginManagement::RestorePatches(plugin_information_t *pluginInformation, BOOL pluginOnly) { void PluginManagement::RestorePatches(plugin_information_t *pluginInformation, BOOL pluginOnly) {
for (int32_t plugin_index = pluginInformation->number_used_plugins - 1; plugin_index >= 0; plugin_index--) { for (int32_t plugin_index = pluginInformation->number_used_plugins - 1; plugin_index >= 0; plugin_index--) {
FunctionPatcherRestoreFunctions(pluginInformation->plugin_data[plugin_index].info.functions, pluginInformation->plugin_data[plugin_index].info.number_used_functions); FunctionPatcherRestoreFunctions(pluginInformation->plugin_data[plugin_index].info.functions, pluginInformation->plugin_data[plugin_index].info.number_used_functions);
@ -112,6 +98,16 @@ void PluginManagement::RestorePatches(plugin_information_t *pluginInformation, B
} }
void PluginManagement::unloadPlugins(plugin_information_t *gPluginInformation, MEMHeapHandle pluginHeap, BOOL freePluginData) { void PluginManagement::unloadPlugins(plugin_information_t *gPluginInformation, MEMHeapHandle pluginHeap, BOOL freePluginData) {
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_MALLOC);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_NEWLIB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_STDCPP);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_DEINIT_PLUGIN);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_STDCPP);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_NEWLIB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_MALLOC);
RestorePatches(gPluginInformation, true); RestorePatches(gPluginInformation, true);
for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) { for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) {
plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]); plugin_information_single_t *plugin = &(gPluginInformation->plugin_data[plugin_index]);
@ -155,13 +151,7 @@ void PluginManagement::unloadPlugins(plugin_information_t *gPluginInformation, M
} }
void PluginManagement::callInitHooks(plugin_information_t *pluginInformation) { void PluginManagement::callInitHooks(plugin_information_t *pluginInformation) {
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_VID_MEM);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_KERNEL);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_OVERLAY);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_PLUGIN); CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_PLUGIN);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_WUT_MALLOC);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_WUT_NEWLIB);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_WUT_STDCPP);
DEBUG_FUNCTION_LINE_VERBOSE("Done calling init hooks"); DEBUG_FUNCTION_LINE_VERBOSE("Done calling init hooks");
} }
@ -184,9 +174,8 @@ void PluginManagement::PatchFunctionsAndCallHooks(plugin_information_t *gPluginI
DCFlushRange((void *) 0x00800000, 0x00800000); DCFlushRange((void *) 0x00800000, 0x00800000);
ICInvalidateRange((void *) 0x00800000, 0x00800000); ICInvalidateRange((void *) 0x00800000, 0x00800000);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB);
for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) { for (int32_t plugin_index = 0; plugin_index < gPluginInformation->number_used_plugins; plugin_index++) {
CallHookEx(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_START, plugin_index); CallHookEx(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_STARTS, plugin_index);
FunctionPatcherPatchFunction(gPluginInformation->plugin_data[plugin_index].info.functions, gPluginInformation->plugin_data[plugin_index].info.number_used_functions); FunctionPatcherPatchFunction(gPluginInformation->plugin_data[plugin_index].info.functions, gPluginInformation->plugin_data[plugin_index].info.number_used_functions);
CallHookEx(gPluginInformation, WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, plugin_index); CallHookEx(gPluginInformation, WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, plugin_index);
} }

View File

@ -22,6 +22,4 @@ public:
static std::vector<PluginContainer> loadPlugins(const std::vector<PluginData> &pluginList, MEMHeapHandle pHeader, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length); static std::vector<PluginContainer> loadPlugins(const std::vector<PluginData> &pluginList, MEMHeapHandle pHeader, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
static void RestorePatches(plugin_information_t *pluginInformation, BOOL pluginOnly); static void RestorePatches(plugin_information_t *pluginInformation, BOOL pluginOnly);
static void callDeinitHooks(plugin_information_t *pluginInformation);
}; };

View File

@ -20,31 +20,24 @@ bool HasHookCallHook(plugin_information_t *pluginInformation, wups_loader_hook_t
} }
static const char **hook_names = (const char *[]) { static const char **hook_names = (const char *[]) {
"WUPS_LOADER_HOOK_INIT_OVERLAY",
"WUPS_LOADER_HOOK_INIT_KERNEL",
"WUPS_LOADER_HOOK_INIT_VID_MEM",
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC", "WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC", "WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB", "WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
"WUPS_LOADER_HOOK_FINI_WUT_NEWLIB", "WUPS_LOADER_HOOK_FINI_WUT_NEWLIB",
"WUPS_LOADER_HOOK_INIT_WUT_STDCPP", "WUPS_LOADER_HOOK_INIT_WUT_STDCPP",
"WUPS_LOADER_HOOK_FINI_WUT_STDCPP", "WUPS_LOADER_HOOK_FINI_WUT_STDCPP",
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
"WUPS_LOADER_HOOK_INIT_PLUGIN", "WUPS_LOADER_HOOK_INIT_PLUGIN",
"WUPS_LOADER_HOOK_DEINIT_PLUGIN", "WUPS_LOADER_HOOK_DEINIT_PLUGIN",
"WUPS_LOADER_HOOK_APPLICATION_START", "WUPS_LOADER_HOOK_APPLICATION_STARTS",
"WUPS_LOADER_HOOK_FUNCTIONS_PATCHED", "WUPS_LOADER_HOOK_FUNCTIONS_PATCHED",
"WUPS_LOADER_HOOK_RELEASE_FOREGROUND", "WUPS_LOADER_HOOK_RELEASE_FOREGROUND",
"WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND", "WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND",
"WUPS_LOADER_HOOK_APPLICATION_END", "WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT",
"WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND", "WUPS_LOADER_HOOK_APPLICATION_ENDS",
"WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE", "WUPS_LOADER_HOOK_VSYNC"};
"WUPS_LOADER_HOOK_VSYNC",
"WUPS_LOADER_HOOK_GET_CONFIG",
"WUPS_LOADER_HOOK_VID_DRC_DRAW",
"WUPS_LOADER_HOOK_VID_TV_DRAW",
"WUPS_LOADER_HOOK_APPLET_START"};
void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) { void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
if(hook_type != WUPS_LOADER_HOOK_VSYNC) { if(hook_type != WUPS_LOADER_HOOK_VSYNC) {
@ -71,21 +64,18 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) { } else if (hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_START) { } else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_STARTS) {
wups_loader_app_started_args_t args; ((void (*)()) ((uint32_t *) func_ptr))();
((void (*)(wups_loader_app_started_args_t)) ((uint32_t *) func_ptr))(args);
} else if (hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) { } else if (hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_END) { } else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_ENDS) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) { } else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) { } else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) { } else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) { } else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) {
@ -94,6 +84,10 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) { } else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND) { } else if (hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND) {
((void (*)()) ((uint32_t *) func_ptr))(); ((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) { } else if (hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) {

View File

@ -26,16 +26,21 @@ WUMS_INITIALIZE(args) {
WHBLogPrintf("Init successful"); WHBLogPrintf("Init successful");
} }
WUMS_APPLICATION_REQUESTS_EXIT() {
CallHook(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT);
}
WUMS_APPLICATION_ENDS() { WUMS_APPLICATION_ENDS() {
DEBUG_FUNCTION_LINE("Reset alreadyPatched flags for dynamic functions"); CallHook(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_ENDS);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_STDCPP);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_NEWLIB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_MALLOC);
auto pluginInformation = gPluginInformation; auto pluginInformation = gPluginInformation;
for (int32_t plugin_index = pluginInformation->number_used_plugins - 1; plugin_index >= 0; plugin_index--) { for (int32_t plugin_index = pluginInformation->number_used_plugins - 1; plugin_index >= 0; plugin_index--) {
FunctionPatcherRestoreDynamicFunctions(pluginInformation->plugin_data[plugin_index].info.functions, pluginInformation->plugin_data[plugin_index].info.number_used_functions); FunctionPatcherRestoreDynamicFunctions(pluginInformation->plugin_data[plugin_index].info.functions, pluginInformation->plugin_data[plugin_index].info.number_used_functions);
} }
FunctionPatcherRestoreDynamicFunctions(method_hooks_hooks_static, method_hooks_size_hooks_static); FunctionPatcherRestoreDynamicFunctions(method_hooks_hooks_static, method_hooks_size_hooks_static);
DEBUG_FUNCTION_LINE("Call hooks");
CallHook(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_END);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
} }
WUMS_APPLICATION_STARTS() { WUMS_APPLICATION_STARTS() {
@ -155,6 +160,11 @@ WUMS_APPLICATION_STARTS() {
DCFlushRange((void *) pluginDataHeap, gPluginDataHeapSize); DCFlushRange((void *) pluginDataHeap, gPluginDataHeapSize);
ICInvalidateRange((void *) pluginDataHeap, gPluginDataHeapSize); ICInvalidateRange((void *) pluginDataHeap, gPluginDataHeapSize);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_MALLOC);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_NEWLIB);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_STDCPP);
CallHook(gPluginInformation, WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB);
if (initNeeded) { if (initNeeded) {
PluginManagement::callInitHooks(gPluginInformation); PluginManagement::callInitHooks(gPluginInformation);
} }

View File

@ -14,239 +14,7 @@ DECL_FUNCTION(void, GX2WaitForVsync, void) {
real_GX2WaitForVsync(); real_GX2WaitForVsync();
} }
uint8_t vpadPressCooldown = 0xFF;
uint8_t angleX_counter = 0;
float angleX_delta = 0.0f;
float angleX_last = 0.0f;
uint8_t angleX_frameCounter = 0;
void checkMagic(VPADStatus *buffer) {
// buffer->angle stores the rotations per axis since the app started.
// Each full rotation add/subtracts 1.0f (depending on the direction).
// Check for rotation every only 5 frames.
angleX_frameCounter++;
if (angleX_frameCounter >= 5) {
// Get how much the gamepad rotated within the last 5 frames.
float diff_angle = -(buffer->angle.x - angleX_last);
// We want the gamepad to make (on average) at least 0.16% (1/6) of a full rotation per 5 frames (for 6 times in a row).
float target_diff = (0.16f);
// Calculate if rotated enough in this step (including the delta from the last step).
float total_diff = (diff_angle + angleX_delta) - target_diff;
if (total_diff > 0.0f) {
// The rotation in this step was enough.
angleX_counter++;
// When the gamepad rotated ~0.16% for 6 times in a row we made a full rotation!
if (angleX_counter > 5) {
//ConfigUtils::openConfigMenu();
// reset stuff.
angleX_counter = 0;
angleX_delta = 0.0f;
} else {
// Save difference as it will be added on the next check.
angleX_delta = total_diff;
}
} else {
// reset counter if it stopped rotating.
angleX_counter = 0;
}
angleX_frameCounter = 0;
angleX_last = buffer->angle.x;
}
}
DECL_FUNCTION(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buffer_size, int32_t *error) {
int32_t result = real_VPADRead(chan, buffer, buffer_size, error);
if (result > 0 && (buffer[0].hold == (VPAD_BUTTON_PLUS | VPAD_BUTTON_R | VPAD_BUTTON_L)) && vpadPressCooldown == 0 && OSIsHomeButtonMenuEnabled()) {
//if(MemoryMapping::isMemoryMapped()) {
//MemoryMapping::readTestValuesFromMemory();
//} else {
// DEBUG_FUNCTION_LINE("Memory was not mapped. To test the memory please exit the plugin loader by pressing MINUS\n");
//}
vpadPressCooldown = 0x3C;
}
if (result > 0 && (buffer[0].hold == (VPAD_BUTTON_L | VPAD_BUTTON_DOWN | VPAD_BUTTON_MINUS)) && vpadPressCooldown == 0 && OSIsHomeButtonMenuEnabled()) {
//ConfigUtils::openConfigMenu();
vpadPressCooldown = 0x3C;
} else if (result > 0 && OSIsHomeButtonMenuEnabled()) {
checkMagic(buffer);
}
if (vpadPressCooldown > 0) {
vpadPressCooldown--;
}
return result;
}
/*
void setupContextState() {
g_vid_ownContextState = (GX2ContextState*)memalign(
GX2_CONTEXT_STATE_ALIGNMENT,
sizeof(GX2ContextState)
);
if(g_vid_ownContextState == NULL) {
OSFatal("VideoSquoosher: Failed to alloc g_vid_ownContextState\n");
}
GX2SetupContextStateEx(g_vid_ownContextState, 1);
GX2SetContextState(g_vid_ownContextState);
GX2SetColorBuffer(&g_vid_main_cbuf, GX2_RENDER_TARGET_0);
//GX2SetDepthBuffer(&tvDepthBuffer);
GX2SetContextState(g_vid_originalContextSave);
DEBUG_FUNCTION_LINE("Setup contest state done\n");
}
void initTextures() {
GX2InitColorBuffer(&g_vid_main_cbuf,
GX2_SURFACE_DIM_2D,
1280, 720, 1,
GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM,
GX2_AA_MODE_1X
);
if (g_vid_main_cbuf.surface.image_size) {
g_vid_main_cbuf.surface.image_data = MemoryUtils::alloc(
g_vid_main_cbuf.surface.image_size,
g_vid_main_cbuf.surface.align
);
if(g_vid_main_cbuf.surface.image_data == NULL) {
OSFatal("Failed to alloc g_vid_main_cbuf\n");
}
DEBUG_FUNCTION_LINE("Allocated %dx%d g_vid_main_cbuf %08X\n",
g_vid_main_cbuf.surface.width,
g_vid_main_cbuf.surface.height,
g_vid_main_cbuf.surface.image_data);
} else {
DEBUG_FUNCTION_LINE("GX2InitTexture failed for g_vid_main_cbuf!\n");
}
GX2InitTexture(&g_vid_drcTex,
854, 480, 1, 0,
GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM,
GX2_SURFACE_DIM_2D,
GX2_TILE_MODE_LINEAR_ALIGNED
);
g_vid_drcTex.surface.use = (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE);
if (g_vid_drcTex.surface.image_size) {
g_vid_drcTex.surface.image_data = MemoryUtils::alloc(
g_vid_drcTex.surface.image_size,
g_vid_drcTex.surface.align);
if(g_vid_drcTex.surface.image_data == NULL) {
OSFatal("VideoSquoosher: Failed to alloc g_vid_drcTex\n");
}
GX2Invalidate(GX2_INVALIDATE_CPU, g_vid_drcTex.surface.image_data, g_vid_drcTex.surface.image_size);
DEBUG_FUNCTION_LINE("VideoSquoosher: allocated %dx%d g_vid_drcTex %08X\n",
g_vid_drcTex.surface.width,
g_vid_drcTex.surface.height,
g_vid_drcTex.surface.image_data);
} else {
DEBUG_FUNCTION_LINE("VideoSquoosher: GX2InitTexture failed for g_vid_drcTex!\n");
}
GX2InitTexture(&g_vid_tvTex,
1280, 720, 1, 0,
GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM,
GX2_SURFACE_DIM_2D,
GX2_TILE_MODE_LINEAR_ALIGNED
);
g_vid_tvTex.surface.use =
(GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE);
DCFlushRange(&g_vid_tvTex, sizeof(GX2Texture));
if (g_vid_tvTex.surface.image_size) {
g_vid_tvTex.surface.image_data = MemoryUtils::alloc(
g_vid_tvTex.surface.image_size,
g_vid_tvTex.surface.align
);
if(g_vid_tvTex.surface.image_data == NULL) {
OSFatal("VideoSquoosher: Failed to alloc g_vid_tvTex\n");
}
GX2Invalidate(GX2_INVALIDATE_CPU, g_vid_tvTex.surface.image_data, g_vid_tvTex.surface.image_size);
DEBUG_FUNCTION_LINE("VideoSquoosher: allocated %dx%d g_vid_tvTex %08X\n",
g_vid_tvTex.surface.width,
g_vid_tvTex.surface.height,
g_vid_tvTex.surface.image_data);
} else {
DEBUG_FUNCTION_LINE("VideoSquoosher: GX2InitTexture failed for g_vid_tvTex!\n");
}
GX2InitSampler(&g_vid_sampler,
GX2_TEX_CLAMP_CLAMP,
GX2_TEX_XY_FILTER_BILINEAR
);
}
DECL_FUNCTION(void, GX2SetContextState, GX2ContextState * curContext) {
if(gAppStatus == WUPS_APP_STATUS_FOREGROUND) {
g_vid_originalContextSave = curContext;
}
real_GX2SetContextState(curContext);
}
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer* cbuf, int32_t target) {
bool hasDRCHook = HasHookCallHook(WUPS_LOADER_HOOK_VID_DRC_DRAW);
bool hasTVHook = HasHookCallHook(WUPS_LOADER_HOOK_VID_TV_DRAW);
if(gAppStatus != WUPS_APP_STATUS_FOREGROUND || !g_NotInLoader || (!hasDRCHook && !hasTVHook)) {
return real_GX2CopyColorBufferToScanBuffer(cbuf,target);
}
if (!g_vid_drcTex.surface.image_data) {
initTextures();
}
if(g_vid_ownContextState == NULL) {
setupContextState();
}
if(target == 1) {
TextureUtils::copyToTexture(cbuf,&g_vid_tvTex);
if(!hasTVHook) {
return real_GX2CopyColorBufferToScanBuffer(cbuf,target);
}
} else if(target == 4) {
TextureUtils::copyToTexture(cbuf,&g_vid_drcTex);
if(!hasDRCHook) {
return real_GX2CopyColorBufferToScanBuffer(cbuf,target);
}
}
GX2SetContextState(g_vid_ownContextState);
GX2ClearColor(&g_vid_main_cbuf, 1.0f, 1.0f, 1.0f, 1.0f);
GX2SetContextState(g_vid_ownContextState);
GX2SetViewport(
0.0f, 0.0f,
g_vid_main_cbuf.surface.width, g_vid_main_cbuf.surface.height,
0.0f, 1.0f
);
GX2SetScissor(
0, 0,
g_vid_main_cbuf.surface.width, g_vid_main_cbuf.surface.height
);
if(target == 1) {
//drawTexture(&g_vid_tvTex, &g_vid_sampler, 0, 0, 1280, 720, 1.0f);
CallHook(WUPS_LOADER_HOOK_VID_TV_DRAW);
} else if(target == 4) {
//drawTexture(&g_vid_drcTex, &g_vid_sampler, 0, 0, 1280, 720, 1.0f);
CallHook(WUPS_LOADER_HOOK_VID_DRC_DRAW);
}
GX2SetContextState(g_vid_originalContextSave);
return real_GX2CopyColorBufferToScanBuffer(&g_vid_main_cbuf,target);
}*/
static uint32_t lastData0 = 0; static uint32_t lastData0 = 0;
DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint32_t flags) { DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint32_t flags) {
int32_t res = real_OSReceiveMessage(queue, message, flags); int32_t res = real_OSReceiveMessage(queue, message, flags);
if (queue == OSGetSystemMessageQueue()) { if (queue == OSGetSystemMessageQueue()) {
@ -272,16 +40,7 @@ DECL_FUNCTION(void, OSReleaseForeground) {
} }
function_replacement_data_t method_hooks_hooks_static[] __attribute__((section(".data"))) = { function_replacement_data_t method_hooks_hooks_static[] __attribute__((section(".data"))) = {
//MAKE_MAGIC(GX2SetTVBuffer, LIB_GX2, STATIC_FUNCTION),
//MAKE_MAGIC(GX2SetDRCBuffer, LIB_GX2, STATIC_FUNCTION),
REPLACE_FUNCTION(GX2WaitForVsync, LIBRARY_GX2, GX2WaitForVsync), REPLACE_FUNCTION(GX2WaitForVsync, LIBRARY_GX2, GX2WaitForVsync),
//MAKE_MAGIC(GX2CopyColorBufferToScanBuffer, LIB_GX2, STATIC_FUNCTION),
//MAKE_MAGIC(GX2SetContextState, LIB_GX2, STATIC_FUNCTION),
REPLACE_FUNCTION(VPADRead, LIBRARY_VPAD, VPADRead),
//MAKE_MAGIC(OSIsAddressValid, LIB_CORE_INIT, STATIC_FUNCTION),
//MAKE_MAGIC(__OSPhysicalToEffectiveUncached, LIB_CORE_INIT, STATIC_FUNCTION),
//MAKE_MAGIC(__OSPhysicalToEffectiveCached, LIB_CORE_INIT, STATIC_FUNCTION),
//MAKE_MAGIC(OSEffectiveToPhysical, LIB_CORE_INIT, STATIC_FUNCTION),
REPLACE_FUNCTION(OSReceiveMessage, LIBRARY_COREINIT, OSReceiveMessage), REPLACE_FUNCTION(OSReceiveMessage, LIBRARY_COREINIT, OSReceiveMessage),
REPLACE_FUNCTION(OSReleaseForeground, LIBRARY_COREINIT, OSReleaseForeground) REPLACE_FUNCTION(OSReleaseForeground, LIBRARY_COREINIT, OSReleaseForeground)
}; };

View File

@ -111,7 +111,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
} else if (key.compare("description") == 0) { } else if (key.compare("description") == 0) {
pluginInfo.setDescription(value); pluginInfo.setDescription(value);
} else if (key.compare("wups") == 0) { } else if (key.compare("wups") == 0) {
if (value.compare("0.2") != 0) { if (value.compare("0.4") != 0) {
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str()); DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return std::nullopt; return std::nullopt;
} }