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

Burnout Dominator PS2 texture

Featured Replies

  • Supporter

Hi there. I have a problem with reading palette data. Not sure how big is.

I have made Noesis script but I need to know how to correct read palette data and return it back to buffer.

from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
   handle = noesis.register("Burnout Dominator - Texture", ".ps2tex")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
   noesis.logPopup()
   return 1
        
def noepyCheckType(data):
   bs = NoeBitStream(data)
   if len(data) < 20:
      return 0
   return 1
   
def noepyLoadRGBA(data, texList):
    bs = NoeBitStream(data)
    baseName = rapi.getExtensionlessName(rapi.getLocalFileName(rapi.getInputName()))
    bs.read(4)
    RwRawDataOffset = bs.readUInt()
    RwPaletteOffset = bs.readUInt()
    RwTextureWidth = bs.readUInt()
    RwTextureHeight = bs.readUInt()
    RwBitDepth = bs.readUInt()
    bs.read(136)
    RwPaletteIndex = bs.readUByte()
    RwPaletteSize = bs.readUByte()*4
    bs.read(7)
    RwTextureName = bs.readString()
    bs.seek(RwRawDataOffset, NOESEEK_ABS)
    RwRawDataSize = bs.readBytes(RwTextureWidth * RwTextureHeight)
    
    bs.seek(RwPaletteOffset, NOESEEK_ABS)
    RwPaletteDataSize = bs.readBytes(RwPaletteSize)
    
    RwRawData = rapi.imageUntwiddlePS2(RwRawDataSize, RwTextureWidth, RwTextureHeight, 8)
    RwPaletteData = rapi.imageDecodeRawPal(RwRawData, RwPaletteDataSize, RwTextureWidth, RwTextureHeight, 8, "R8G8B8A8", noesis.DECODEFLAG_PS2SHIFT)
    
    texFmt = noesis.NOESISTEX_RGBA32
    texList.append(NoeTexture(RwTextureName, RwTextureWidth, RwTextureHeight, RwPaletteData, texFmt))
    return 1

I appreciate your help guys!

Anyway here is code from Edness:

        if palCount == 1:
            palData = boPS2Read32({4: 16, 8: 256}.get(bitDepth))
        elif bitDepth == 8 and palCount <= 8:
            # Interleaved-grouped palette splitter
            palData = [list() for pal in range(8)]
            for pal in range(16):
                boPS2Read32(16, palData[0])
                boPS2Read32(16, palData[1])
                if palCount == 3 or palCount >= 5:
                    boPS2Read32(16, palData[2])
                    if palCount >= 7:
                        boPS2Read32(16, palData[3])
            if palCount >= 4:
                for pal in range(16):
                    boPS2Read32(16, palData[4])
                    boPS2Read32(16, palData[5])
                    if palCount >= 5:
                        boPS2Read32(16, palData[6])
                        if palCount >= 7:
                            boPS2Read32(16, palData[7])
            palData = [bytearray(palData[pal]) for pal in range(8)]

            palNum = 1
            boPS2TexPal(palData[0])
            palNum = 2
            boPS2TexPal(palData[1])
            if palCount == 3 or palCount >= 5:
                palNum += 1
                boPS2TexPal(palData[2])
                if palCount >= 7:
                    palNum += 1
                    boPS2TexPal(palData[3])
            if palCount >= 4:
                palNum += 1
                boPS2TexPal(palData[4])
                palNum += 1
                boPS2TexPal(palData[5])
                if palCount >= 6:
                    palNum += 1
                    boPS2TexPal(palData[6])
                    if palCount == 8:
                        palNum += 1
                        boPS2TexPal(palData[7])
            return
        else:
            noesis.doException(BoExcFmt + "{} {}".format(bitDepth, palCount))
        texData = rapi.imageDecodeRawPal(texData, palData, texWidth, texHeight, 8, "R8G8B8A8", noesis.DECODEFLAG_PS2SHIFT if bitDepth == 8 else 0)

 

ps2_tex.7z

Edited by h3x3r

Solved by Rabatini

  • Author
  • Supporter

This gives me pretty solid output, but still not perfect...

	RwPalette0Buffer = bytearray()
            
	for i in range(RwPaletteIndex):
		RwPalette0 = bs.read(32)
		bs.read(96)
		RwPalette0Buffer.extend(RwPalette0)

image.png.4c34b9ca07f731356392419bcaf23d49.png

  • Supporter
  • Solution

try this.

 

from inc_noesis import *
import noesis
import rapi

def registerNoesisTypes():
    handle = noesis.register("Burnout Dominator - Texture", ".ps2tex")
    noesis.setHandlerTypeCheck(handle, noepyCheckType)
    noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
    return 1

def noepyCheckType(data):
    if len(data) < 20:
        return 0
    return 1

def noepyLoadRGBA(data, texList):
    bs = NoeBitStream(data)

    bs.read(4)
    RwRawDataOffset = bs.readUInt()
    RwPaletteOffset = bs.readUInt()
    RwTextureWidth = bs.readUInt()
    RwTextureHeight = bs.readUInt()
    RwBitDepth = bs.readUInt()

    bs.seek(136, NOESEEK_REL)
    RwPaletteIndex = bs.readUByte()
    RwHeaderPalByte = bs.readUByte()
    bs.read(7)
    RwTextureName = bs.readString()

    bs.seek(RwRawDataOffset, NOESEEK_ABS)
    RwRawDataSize = bs.readBytes(RwTextureWidth * RwTextureHeight)
    RwRawData = rapi.imageUntwiddlePS2(RwRawDataSize, RwTextureWidth, RwTextureHeight, RwBitDepth)

    bs.seek(RwPaletteOffset, NOESEEK_ABS)

    fileSize = len(data)
    palDataSize = fileSize - RwPaletteOffset
    palCount = 1

    if RwBitDepth == 8:
        palCount = palDataSize // 1024
        if palCount == 0:
            palCount = 1

    pal_arrays = [bytearray() for _ in range(8)]

    if RwBitDepth == 8 and palCount > 1:
        for i in range(16):
            pal_arrays[0].extend(bs.readBytes(64))
            pal_arrays[1].extend(bs.readBytes(64))
            if palCount == 3 or palCount >= 5:
                pal_arrays[2].extend(bs.readBytes(64))
                if palCount >= 7:
                    pal_arrays[3].extend(bs.readBytes(64))

        if palCount >= 4:
            for i in range(16):
                pal_arrays[4].extend(bs.readBytes(64))
                pal_arrays[5].extend(bs.readBytes(64))
                if palCount >= 5:
                    pal_arrays[6].extend(bs.readBytes(64))
                    if palCount >= 7:
                        pal_arrays[7].extend(bs.readBytes(64))

    elif RwBitDepth == 8 and palCount == 1:
        pal_arrays[0] = bs.readBytes(1024)

    elif RwBitDepth == 4:
        for i in range(palCount):
            if i < 8:
                pal_arrays[i] = bs.readBytes(64)

    for i, current_pal in enumerate(pal_arrays):
        if len(current_pal) > 0:
            texData = rapi.imageDecodeRawPal(RwRawData, current_pal, RwTextureWidth, RwTextureHeight, RwBitDepth, "R8G8B8A8", noesis.DECODEFLAG_PS2SHIFT)
            texName = RwTextureName
            if palCount > 1:
                texName = "{}_pal{}".format(RwTextureName, i)
            texList.append(NoeTexture(texName, RwTextureWidth, RwTextureHeight, texData, noesis.NOESISTEX_RGBA32))

    return 1

 

  • Author
  • Supporter

Thank you! You are amazing!

EDiT: BTW i found palette size at 0x60 uint32() - 80, so there's no need for this except for palDataSize var:

fileSize = len(data)

palDataSize = fileSize - RwPaletteOffset

Edited by h3x3r

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.