Th12/Binary hacks

From Touhou Patch Center
Jump to: navigation, search

Bugs

Score counter bugfix (jumps)
(fix_score_1)
Description Original hack by Nereid. Corrects the score display for scores exceeding 231 points by changing signed jumps and multiplications to unsigned ones.
Address
v1.00b0x401631, 0x40166a, 0x4016ab
Code
  1. 73
  1.  
Score counter bugfix (multiplications)
(fix_score_2)
Description Original hack by Nereid. Corrects the score display for scores exceeding 231 points by changing signed jumps and multiplications to unsigned ones.
Address
v1.00b0x401651, 0x401699, 0x4016cf
Code
  1. e1
  1.  
Safe sprintf (call #1)
(sprintf_call_1)
Address
v1.00b0x46078d
Code
  1. 50
  2. e8 [strings_vsprintf]
  3. 8944e4 14
  1. push eax
  2. call [strings_vsprintf]
  3. mov dword ptr ss:[esp+0x14],eax
Safe sprintf (call #2)
(sprintf_call_2)
Address
v1.00b0x460839, 0x460929
Code
  1. 50
  2. e8 [strings_vsprintf]
  3. 8944e4 1c
  1. push eax
  2. call [strings_vsprintf]
  3. mov dword ptr ss:[esp+0x1c],eax
Safe sprintf (replace pointer)
(sprintf_rep)
Description The safe sprintf pointer is at a different ESP offset in both functions. Thus, we simply leave out the offset from this hack, as it's already at the same position in the original code.
Address
v1.00b0x4608b7, 0x4607d4, 0x46099b
Code
  1. 8b5ce4
  1. mov ebx, dword ptr ss:[esp+

Spells

Spell card alignment
(spell_align)
Description Same procedure as always. Don't forget that this one push indeed uses ESP (th12 was compiled with stack frames turned off), calculate the correct stack offset, and you're set.
Address
v1.00b0x460867
Code
  1. 8b96 80040000
  2. 51
  3. d1ea
  4. 83e2 01
  5. 52
  6. ffb4e4 a8000000
  7. ffb4e4 a8000000
  8. ff35 54e54c00
  9. 53
  10. e8 [GetTextExtentForFont]
  11. 83c0 04
  12. 50
  13. db04e4
  14. 58
  15. 85c0
  16. 90
  1. mov edx,dword ptr ds:[esi+480]
  2. push ecx
  3. shr edx, 1
  4. and edx, 00000001
  5. push edx
  6. push dword ptr ss:[esp+0xa8]
  7. push dword ptr ss:[esp+0xa8]
  8. push dword ptr ds:[th12.4ce554]
  9. push ebx
  10. call [GetTextExtentForFont]
  11. add eax, 4
  12. push eax
  13. fild dword ptr ss:[esp]
  14. pop eax
  15. test eax, eax
  16. nop

Player data

Remove spell "alignment" in the result screen
(result_spell_align)
Address
v1.00b0x46098a
Code
  1. 31c0
  1. xor eax,eax