Merged some duplicated logic in load_sprite_pak(...)