Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.
Zero Tolerance for Disrespect

strange swizzle ps2 4bit

Featured Replies

Hello, help me solve the problem with the Noesis plugin. it incorrectly shows the ps2 swizzle 4bpp texture, but some programs also do this incorrectly. thanks in advance

if use MummGGTool:

width = 64, height = 32, bpp = 4

4bqkebi.png

inside Noesis i use:

data = rapi.imageUntwiddlePS2(data, width, height,  4)
data = rapi.imageDecodeRawPal(data, palette, width, height,  4, 'r8g8b8a8', 1)

if width = 32, height = 64

ZQHCsgf.png

if width = 64, height = 32

sUVf89Q.png

if use "Console Texture Explorer":

1XyTKXk.png

s0000_023.zip

Solved by DKDave

  • Author
22 hours ago, DKDave said:

It looks like the data is in blocks of 32x32 (0x200 bytes)

thank its true, i so suspected it. but the first program led me astray

3LDxoP1.png

offtopic:

I found the code on github and 8bits work well, but 4bits look bad, what's wrong with them? swizzle_ps2.py

need: pkFsVXF.png have:bPqcZoc.png

Spoiler
def unswizzle_ps2_8bit(image_data, img_width, img_height):
    unswizzled_data = bytearray(img_width * img_height)
    for y in range(img_height):
        for x in range(img_width):
            block_location = (y & (~0xF)) * img_width + (x & (~0xF)) * 2
            swap_selector = (((y + 2) >> 2) & 0x1) * 4
            pos_y = (((y & (~3)) >> 1) + (y & 1)) & 0x7
            column_location = pos_y * img_width * 2 + ((x + swap_selector) & 0x7) * 4
            byte_num = ((y >> 1) & 1) + ((x >> 2) & 2)
            swizzle_id = block_location + column_location + byte_num
            unswizzled_data[y * img_width + x] = image_data[swizzle_id]
    return unswizzled_data

def unswizzle_ps2_4bit(image_data, img_width, img_height):
    pixels = bytearray(img_width * img_height)

    for i in range(img_width * img_height // 2):
        index = image_data[i]
        id2 = (index >> 4) & 0xF
        id1 = index & 0xF
        pixels[i * 2] = id1
        pixels[i * 2 + 1] = id2

    new_pixels = unswizzle_ps2_8bit(pixels, img_width, img_height)

    unswizzled_data = bytearray(img_width * img_height)
    for i in range(img_width * img_height // 2):
        idx1 = new_pixels[i * 2]
        idx2 = new_pixels[i * 2 + 1]
        idx = ((idx2 << 4) | idx1) & 0xFF
        unswizzled_data[i] = idx

    return unswizzled_data

 

en013_01.zip

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.