ps2¶
Support for PS2 GS texture swizzling.
- hacktools.ps2.unswizzle4(pixels, w, h)[source]¶
Unswizzle a 4bpp texture uploaded to GS memory as PSMCT16.
Simulates a GS memory transfer: the data was sent as a PSMCT16 image of w/2 x h/2 pixels and gets sampled as PSMT4, w x h pixels. The map from output pixel to input byte/nibble is cached for each size.
- Parameters:
pixels – Swizzled 4bpp texture data.
w (int) – Width of the texture.
h (int) – Height of the texture.
- Returns:
A bytearray of w * h palette indexes, one per byte.
- Return type:
bytearray
- hacktools.ps2.swizzle4(pixels, w, h)[source]¶
Swizzle a 4bpp texture, inverse of
unswizzle4().- Parameters:
pixels – Sequence of w * h palette indexes, one per byte.
w (int) – Width of the texture.
h (int) – Height of the texture.
- Returns:
A bytearray of the swizzled 4bpp texture data, two indexes per byte.
- Return type:
bytearray
- hacktools.ps2.unswizzleP6T4(pixels, w, h)[source]¶
Unswizzle a 4bpp P6T texture, returning one index per byte.
- Parameters:
w (int)
h (int)
- Return type:
bytearray
- hacktools.ps2.swizzleP6T4(pixels, w, h, size)[source]¶
Swizzle a 4bpp P6T texture from one index per byte into a size bytes buffer.
- Parameters:
w (int)
h (int)
size (int)
- Return type:
bytearray
- hacktools.ps2.unswizzle8(pixels, w, h, default=0)[source]¶
Unswizzle an 8bpp texture, works on any sequence (indexes or colors).
- Parameters:
pixels – Swizzled sequence of w * h pixels.
w (int) – Width of the texture.
h (int) – Height of the texture.
default – Value used for out of bounds pixels.
- Returns:
The unswizzled list of pixels.
- Return type:
list
- hacktools.ps2.swizzle8(pixels, w, h, default=0)[source]¶
Swizzle an 8bpp texture, works on any sequence (indexes or colors).
- Parameters:
w (int)
h (int)
- Return type:
list
- hacktools.ps2.unswizzlePalette(swizzled)[source]¶
Unswizzle a CSM1 256 colors palette by swapping the middle 8 colors of each 32 colors block.
- Parameters:
swizzled (list)
- Return type:
list
- hacktools.ps2.swizzlePalette(unswizzled)[source]¶
Swizzle a CSM1 256 colors palette, inverse of
unswizzlePalette().- Parameters:
unswizzled (list)
- Return type:
list