shithub: cstory

Download patch

ref: f36fc61de3dada74f5f5861db9a1c5addcc8242f
parent: 38484613d5ade3ff4302db348dda8cc0f8faaf48
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Jan 6 10:52:07 EST 2020

Made Input.cpp more ASM-accurate

There was one ASM-inaccuracy I missed last time, but now I've also
made the file's memory layout accurate (it appears that global
variable initialisation actually affects the order they reside in
memory).

--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -19,12 +19,12 @@
 	LPDIRECTINPUTDEVICE2A device;
 } DirectInputPair;
 
-static LPDIRECTINPUTDEVICE2A joystick;
-static LPDIRECTINPUTA lpDI;
+// The original names for these variables are unknown
+static LPDIRECTINPUTA lpDI = NULL;
+static LPDIRECTINPUTDEVICE2A joystick = NULL;
+static int joystick_neutral_x = 0;
+static int joystick_neutral_y = 0;
 
-static int joystick_neutral_x;
-static int joystick_neutral_y;
-
 void ReleaseDirectInput(void)
 {
 	if (joystick != NULL)
@@ -40,7 +40,7 @@
 	}
 }
 
-// The original name for this function is unknown
+// The original name for this function and its variables are unknown
 BOOL SetDeviceAquire(BOOL aquire)
 {
 	if (aquire == TRUE)
@@ -57,6 +57,7 @@
 	return TRUE;
 }
 
+// It looks like Pixel declared his functions early, so he could forward-reference
 BOOL HookAllDirectInputDevices(HWND hWnd);
 BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
 
@@ -75,7 +76,7 @@
 	return TRUE;
 }
 
-// The original name for this function is unknown
+// The original name for this function and its variables are unknown
 BOOL HookAllDirectInputDevices(HWND hWnd)
 {
 	DirectInputPair directinput_objects;
@@ -83,7 +84,8 @@
 	directinput_objects.device = NULL;
 	directinput_objects.lpDI = lpDI;
 
-	lpDI->AddRef();
+	directinput_objects.lpDI->AddRef();
+
 	lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumDevices_Callback, &directinput_objects, DIEDFL_ATTACHEDONLY);
 
 	if (directinput_objects.lpDI != NULL)
@@ -108,7 +110,7 @@
 	return TRUE;
 }
 
-// The original name for this function is unknown
+// The original name for this function and its variables are unknown
 BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
 {
 	static int already_ran;