Skip to content

Instantly share code, notes, and snippets.

@SnowyMouse
Created August 1, 2023 21:34
Show Gist options
  • Save SnowyMouse/53a7178c121e1aaf3daae875f91b7e45 to your computer and use it in GitHub Desktop.
Save SnowyMouse/53a7178c121e1aaf3daae875f91b7e45 to your computer and use it in GitHub Desktop.
.intel_syntax noprefix
.text
;# Fix sprite sheet width so that width = height (fixes particles)
;#
;# by Snowy~
;#
;# This is meant to return at the end of a function with this signature: 83C4085F5E5D6689185B83C42CC3
;#
;# Just paste it at the C3 at the end, overwriting everything after it. It's a bunch of exception handlers which don't
;# really matter because they're useless anyway without source code (closed source mod tools... eugh!).
;#
;# Just don't trigger them and you'll be fine!
fix_sprite_sheets_patch:
;# Watch out. We're going to be doing some insane stuff~
pushad
;# Load the number of sprite sheets into ECX
movsx ecx, word ptr [esp+0x7C]
;# Now load the pointer to the first sprite sheet pointer into EDX
lea edx, dword ptr [esp+0xA4]
sprite_sheet_loop:
;# Check if the loop is done (ECX == 0); otherwise decrement
and ecx, ecx
jz sprite_sheet_loop_done
dec ecx
;# Load the next pointer
mov edi, dword ptr [edx]
add edx, 4
;# Now load the width and height, then compare them.
mov ax, word ptr [edi+0x8]
mov bx, word ptr [edi+0xA]
cmp ax, bx
jb height_bigger
width_bigger:
;# width >= height
mov word ptr [edi+0xA], ax
jmp sprite_sheet_loop
height_bigger:
;# height > width
mov word ptr [edi+0x8], bx
jmp sprite_sheet_loop
;# Cleanup
sprite_sheet_loop_done:
popad
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment