Th128/Binary hacks
< Th128
Jump to navigation
Jump to search
Development of this patch has moved to GitHub. Please use the Issues page there to discuss possible improvements or additions to this patch, or simply send a pull request. For now, the existing wiki pages of this patch will remain for the sake of documentation, but they are no longer functional. |
Bugs
Safe sprintf (call #1)(sprintf_call_1 ) |
||
---|---|---|
Address |
|
|
Code | 50 e8 [strings_vsprintf] 8985 7cffffff 89bd 78ffffff push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x84],eax
mov dword ptr ss:[ebp-0x88],edi
|
Safe sprintf (call #2)(sprintf_call_2 ) |
||
---|---|---|
Address |
|
|
Code | 50 e8 [strings_vsprintf] 8985 78ffffff push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x88],eax
|
Safe sprintf (call #3)(sprintf_call_3 ) |
||
---|---|---|
Address |
|
|
Code | 50 e8 [strings_vsprintf] 8985 74ffffff push eax
call [strings_vsprintf]
mov dword ptr ss:[ebp-0x8c],eax
|
Safe sprintf (replace pointer)(sprintf_rep ) |
||
---|---|---|
Address |
|
|
Code | 8b mov ebx, dword ptr ss:[
|
Logging
Restore the game's built-in logging(log_restore ) |
||
---|---|---|
Description | Very useful for debugging. | |
Address |
|
|
Code | e9 [log_printf] jmp [log_printf]
|
Textbox size
Correct text length calculation for Fairy Wars-style text boxes(fw_textbox_size ) |
||
---|---|---|
Description | This replaces the basic text box length calculation (string length * 8) with a call to GetTextExtent.
To apply these for later games, do an instruction search for: sub eax, edx
lea ecx,[eax*8]
and ecx,fffffff0
PUSH opcode to reflect the register with the string buffer address (EDI in this case). |
|
Address |
|
|
Code | ff35 bc2a4d00 57 e8 [GetTextExtentForFont] 89c1 90 90 90 push dword ptr ds:[th128.4d2abc]
push edi
call [GetTextExtentForFont]
mov ecx,eax
nop (*3)
|
Spells
Spell card alignment(spell_align ) |
||
---|---|---|
Description | In this game, the fonts for dialog and spell cards have different sizes. For this reason, we would have to reset the font after the SelectObject setup - otherwise, dialog text width calculation would use the wrong font for the rest of the game. Thus, GetTextExtentForFont is used, which takes the font for the calculation as a parameter and does temporary font selection on its own. | |
Address |
|
|
Code | c1e9 04 83e1 01 51 ff75 0c ff75 08 ff35 cc2a4d00 ff75 18 e8 [GetTextExtentForFont] 50 db04e4 58 90 90 90 shr ecx, 4
and ecx, 00000001
push ecx
push dword ptr ss:[ebp+0C]
push dword ptr ss:[ebp+8]
push dword ptr ds:[th128.004d2acc]
push dword ptr ss:[ebp+18]
call [GetTextExtentForFont]
push eax
fild dword ptr ss:[esp]
pop eax
nop (*3)
|
Player data
Remove spell "alignment" in the result screen(result_spell_align ) |
||
---|---|---|
Address |
|
|
Code | 31c0 xor eax,eax
|