Skip to content

Instantly share code, notes, and snippets.

@iamgreaser
Created May 26, 2013 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamgreaser/5651429 to your computer and use it in GitHub Desktop.
Save iamgreaser/5651429 to your computer and use it in GitHub Desktop.
touhou nojoy patches
Here, have some patches.
These are patches to disable joystick support for when you'd rather have a joy-to-key mapper than the terribleness that is 99% of games with joystick support not being able to handle a 28-axis controller properly.
You must tick the "Don't use DirectInput for joystick" box for this to actually work, as it doesn't touch those.
Also, these are for the latest (as of writing) full versions.
The general procedure is:
* Look for all instances of joyGetPosEx - there should be exactly 3.
* Make the code pretend that it always returns a nonzero value in all 3 cases.
For instance, this is one of the relevant places in TH07's disassembly:
ALIGN 16
?_03773:push ebp ; 00430290 _ 55
mov ebp, esp ; 00430291 _ 8B. EC
sub esp, 52 ; 00430293 _ 83. EC, 34
mov dword [ebp-34H], 52 ; 00430296 _ C7. 45, CC, 00000034
mov dword [ebp-30H], 255 ; 0043029D _ C7. 45, D0, 000000FF
lea eax, [ebp-34H] ; 004302A4 _ 8D. 45, CC
push eax ; 004302A7 _ 50
push 0 ; 004302A8 _ 6A, 00
call near [imp_joyGetPosEx] ; 004302AA _ FF. 15, 0048D220(d)
test eax, eax ; 004302B0 _ 85. C0
jz ?_03774 ; 004302B2 _ 74, 18
; ^ NOP this opcode with two 0x90 bytes
push ?_15147 ; 004302B4 _ 68, 00497D9C(d)
push ?_15997 ; 004302B9 _ 68, 00624210(d)
call ?_03849 ; 004302BE _ E8, 0000132D
add esp, 8 ; 004302C3 _ 83. C4, 08
mov ax, 1 ; 004302C6 _ 66: B8, 0001
jmp ?_03775 ; 004302CA _ EB, 15
If on the other hand it's a jnz or something that doesn't include zero,
you'll need to find what byte to use for a force jump.
Said one other case I have is for a longer-than-usual conditional jump,
which involves changing 0F 85 to 90 E9.
Enjoy!
-- GreaseMonkey
TH06:
0001CF82: 74 -> 90
0001CF83: 18 -> 90
0001D00A: 74 -> 90
0001D00B: 09 -> 90
0001D6D5: 74 -> 90
0001D6D6: 0A -> 90
TH07:
0002F6B2: 74 -> 90
0002F6B3: 18 -> 90
0002F836: 74 -> 90
0002F837: 0C -> 90
0002FE0A: 74 -> 90
0002FE0B: 0A -> 90
TH08:
0003CEE2: 74 -> 90
0003CEE3: 18 -> 90
0003CF66: 74 -> 90
0003CF67: 0C -> 90
0003D62A: 74 -> 90
0003D62B: 0A -> 90
TH09:
0002AA1F: 0F -> 90
0002AA20: 85 -> E9
0002AB8E: 0F -> 90
0002AB8F: 85 -> E9
0002BD15: 74 -> 90
0002BD16: 27 -> 90
TH10:
000494E5: 74 -> 90
000494E6: 28 -> 90
000495FF: 0F -> 90
00049600: 85 -> E9
0004993C: 0F -> 90
0004993D: 85 -> E9
TH11:
000565C5: 74 -> 90
000565C6: 29 -> 90
000566CF: 74 -> 90
000566D0: 17 -> 90
00056A0C: 0F -> 90
00056A0D: 85 -> E9
TH12:
00061DD5: 74 -> 90
00061DD6: 29 -> 90
00061EDF: 74 -> 90
00061EE0: 17 -> 90
0006221C: 0F -> 90
0006221D: 85 -> E9
TH12.8:
00067D1F: 74 -> 90
00067D20: 32 -> 90
00067E3F: 74 -> 90
00067E40: 17 -> 90
0006817C: 0F -> 90
0006817D: 85 -> E9
TH13:
000704DF: 74 -> 90
000704E0: 32 -> 90
000705FF: 74 -> 90
00070600: 17 -> 90
0007097C: 0F -> 90
0007097D: 85 -> E9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment