Skip to content

Commit

Permalink
v0.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomiejduda committed Jun 22, 2024
1 parent 9c4ee5e commit b3d24d2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ noesis*/
log.txt
config.ini
build_final/
*.log
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ To use script with Noesis, please follow below steps:

# Badges
![GitHub](https://img.shields.io/github/license/bartlomiejduda/EA-Graphics-Manager?style=plastic)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![GitHub repo size](https://img.shields.io/github/repo-size/bartlomiejduda/EA-Graphics-Manager?style=plastic)
![GitHub all releases](https://img.shields.io/github/downloads/bartlomiejduda/EA-Graphics-Manager/total)
![GitHub last commit](https://img.shields.io/github/last-commit/bartlomiejduda/EA-Graphics-Manager?style=plastic)
Expand Down
51 changes: 31 additions & 20 deletions src/EA_Image/ea_image_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import struct
import traceback

from reversebox.common.logger import get_logger
from reversebox.compression.compression_refpack import RefpackHandler
Expand Down Expand Up @@ -150,7 +151,7 @@ def _set_little_endianess():
self.f_dir_endianess = "<" # little

# set endianess for the rest of the file
if self.sign in ("SHPG", "SHPM", "ShpG", "ShpM"):
if self.sign in ("SHPG", "ShpG", "ShpM"):
_set_big_endianess()
else:
_set_little_endianess()
Expand Down Expand Up @@ -380,25 +381,35 @@ def _is_image_swizzled() -> bool:

# unswizzling logic
if _is_image_swizzled():
if self.sign in ("SHPX", "ShpX", "SHPI", "ShpF"): # for XBOX and PC games
image_data = unswizzle_morton(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
elif self.sign in ("SHPM", "ShpM"): # for PSP games
image_data = unswizzle_psp(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
elif self.sign in ("SHPS", "ShpS") and (entry_type < 8 or entry_type > 15): # for PS2 games
if get_bpp_for_image_type(entry_type) == 4:
image_data = unswizzle_ps2_4bit(image_data, ea_dir_entry.h_width, ea_dir_entry.h_height)
elif get_bpp_for_image_type(entry_type) == 8:
image_data = unswizzle_ps2_8bit(image_data, ea_dir_entry.h_width, ea_dir_entry.h_height)
elif self.sign in ("SHPG", "ShpG"): # for WII/GameCube games
image_data = unswizzle_gamecube(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
else:
logger.warning(f"Swizzling for signature {self.sign} is not supported yet!")
try:
if self.sign in ("SHPX", "ShpX", "SHPI", "ShpF"): # for XBOX and PC games
image_data = unswizzle_morton(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
elif self.sign in ("SHPM", "ShpM"): # for PSP games
image_data = unswizzle_psp(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
elif self.sign in ("SHPS", "ShpS") and (
entry_type < 8 or entry_type > 15
): # for PS2 games (standard textures)
if get_bpp_for_image_type(entry_type) == 4:
image_data = unswizzle_ps2_4bit(image_data, ea_dir_entry.h_width, ea_dir_entry.h_height)
elif get_bpp_for_image_type(entry_type) == 8:
image_data = unswizzle_ps2_8bit(image_data, ea_dir_entry.h_width, ea_dir_entry.h_height)
elif (
self.sign in ("SHPS", "ShpS") and entry_type >= 8 and entry_type <= 15
): # for PS2 games (GST textures)
pass # swizzling handled by decoder
elif self.sign in ("SHPG", "ShpG"): # for WII/GameCube games
image_data = unswizzle_gamecube(
image_data, ea_dir_entry.h_width, ea_dir_entry.h_height, get_bpp_for_image_type(entry_type)
)
else:
logger.warning(f"Swizzling for signature {self.sign} is not supported yet!")
except Exception as error:
logger.error(f"Error while unswizzling images! Error: {error}")
logger.error(traceback.format_exc())

# decoding logic
if entry_type == 1:
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from src.GUI.GUI_main import EAManGui

VERSION_NUM = "v0.21.2"
VERSION_NUM = "v0.21.3"

logger = get_logger("main")

Expand Down

0 comments on commit b3d24d2

Please sign in to comment.