Th125/Binary hacks

From Touhou Patch Center
Jump to: navigation, search

Bugs

Safe sprintf (call)
(sprintf_call)
Address
v1.00aRx5f8dc
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 (replace pointer)
(sprintf_rep)
Address
v1.00aRx5f903
Code
  1. 8b54e4
  1. mov edx, dword ptr ss:[esp+

Logging

Restore the game's built-in logging
(log_restore)
Description Very useful for debugging.
Address
v1.00a0x4653c0
Code
  1. e9 [log_printf]
  1. jmp [log_printf]

Spells

Spell card alignment
(spell_align)
Description ... and fixing the buffer overflow bug while we're at it.
Address
v1.00a0x45f979
Code
  1. 8b8e 88040000
  2. 8bbe fc030000
  3. d947 38
  4. c1e9 04
  5. 83e1 01
  6. 51
  7. 8b94e4 b0000000
  8. 52
  9. ffb4e4 a8000000
  10. ffb4e4 a8000000
  11. ff35 08094d00
  12. 52
  13. e8 [GetTextExtentForFont]
  14. 50
  15. db04e4
  16. 58
  17. eb 2e
  18. 90 90 90 90 90 90 90 90
  19. 90 90 90 90 90 90 90 90
  20. 90 90 90 90 90 90 90 90
  21. 90 90 90 90 90 90 90 90
  22. 90 90 90 90 90 90 90 90
  23. 90 90 90 90 90 90
  1. mov ecx,dword ptr ds:[esi+488]
  2. mov edi,dword ptr ds:[esi+3FC]
  3. fld dword ptr ds:[edi+38]
  4. shr ecx,4
  5. and ecx,00000001
  6. push ecx
  7. mov edx,dword ptr ss:[esp+0B0]
  8. push edx
  9. push dword ptr ss:[esp+0A8]
  10. push dword ptr ss:[esp+0A8]
  11. push dword ptr ds:[th125.4d0908] ; spell font
  12. push edx
  13. call [GetTextExtentForFont]
  14. push eax
  15. fild dword ptr ss:[esp]
  16. pop eax
  17. jmp short +0x2e
  18. nop (*0x2e)

Compatibility

Ensure correct size of ruby font
(font_ruby_size)
Description The English patch uses a larger size for the ruby text font. I don't know why, probably some leftover debugging code. This sets it back to its normal size.
Address
v1.00a0x44cfcb
Code
  1. 6a 0f
  1. push 0f

Ruby

Render ruby text in one pass
(skip_ruby_loop)
Description Same hack as for th11.
Address
v1.00a0x44d0e0
Code
  1. 90
  2. 90
  1. nop
  2. nop