Add "Force Touch Inventory"

This commit is contained in:
TheBrokenRail 2022-04-11 19:59:21 -04:00
parent 0150879d2b
commit f455780833
4 changed files with 21 additions and 2 deletions

View File

@ -31,3 +31,4 @@ TRUE Fix Furnace Not Checking Item Auxiliary
TRUE Improved Cursor Rendering
FALSE Disable V-Sync
TRUE Fix Options Screen
FALSE Force Touch Inventory

View File

@ -47,7 +47,7 @@ else()
add_library(sign SHARED src/sign/sign.cpp)
target_link_libraries(sign reborn-patch symbols feature input)
add_library(touch SHARED src/touch/touch.c)
add_library(touch SHARED src/touch/touch.cpp)
target_link_libraries(touch reborn-patch symbols feature)
add_library(override SHARED src/override/override.c)

View File

@ -10,6 +10,11 @@ static int32_t Minecraft_isTouchscreen_injection(__attribute__((unused)) unsigne
return 1;
}
// IngameBlockSelectionScreen Memory Allocation Override
static unsigned char *operator_new_IngameBlockSelectionScreen_injection(__attribute__((unused)) uint32_t size) {
return (unsigned char *) ::operator new(TOUCH_INGAME_BLOCK_SELECTION_SCREEN_SIZE);
}
// Init
void init_touch() {
int touch_gui = feature_has("Touch GUI", server_disabled);
@ -24,6 +29,12 @@ void init_touch() {
// Show Block Outlines
int block_outlines = feature_has("Show Block Outlines", 0);
unsigned char outline_patch[4] = {block_outlines ? !touch_gui : touch_gui, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
unsigned char outline_patch[4] = {(unsigned char) (block_outlines ? !touch_gui : touch_gui), 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
patch((void *) 0x4a210, outline_patch);
// Force Touch Inventory
if (feature_has("Force Touch Inventory", server_disabled)) {
overwrite_call((void *) 0x2943c, (void *) operator_new_IngameBlockSelectionScreen_injection);
overwrite_call((void *) 0x29444, (void *) Touch_IngameBlockSelectionScreen);
}
}

View File

@ -495,6 +495,13 @@ static void *StartMenuScreen_init_vtable_addr = (void *) 0x105194;
static uint32_t StartMenuScreen_options_button_property_offset = 0x98; // Button
// Touch::IngameBlockSelectionScreen
#define TOUCH_INGAME_BLOCK_SELECTION_SCREEN_SIZE 0x16c
typedef unsigned char *(*Touch_IngameBlockSelectionScreen_t)(unsigned char *screen);
static Touch_IngameBlockSelectionScreen_t Touch_IngameBlockSelectionScreen = (Touch_IngameBlockSelectionScreen_t) 0x3afbc;
// SelectWorldScreen
static Screen_tick_t SelectWorldScreen_tick = (Screen_tick_t) 0x38a2c;