User blog:1Zulu/Inner workings

This is a page with a collection of information about PvZ2 code, the OBBs, and more gained through reverse engin... I mean, code introspection.

This content is targeted towards programmers who may want to expand upon my work. I'll open-source OBB Patcher and related tools when I feel it's more ready.

OBB Format
The OBB file is composed of resources laid down in blocks with the following format:

header). The Chinese version uses default compression ( header).

Both the headers and the data are aligned to 4096 offsets to allow for fast random access.

Texture Formats
Textures are resources named *.PTX. In addition to the uncompressed size, the header also contains the dimensions of the texture. These are stored exactly 32 bytes after the name, and are also 32-bit ints in little endian order.

As far as I can tell, PvZ2 uses three texture formats (all of them are header-less):

Uncompressed
These are simply uncompressed RGBA8888, ie: RGBA with 8-bit color depth.

The iOS version for some reason inverts the blue and red channels.

These textures require a size of.

ETC1
These are compressed textures used by the Android version.

It's composed of ETC1 data followed by the uncompressed alpha channel. For example, in a 512x512 the first 131072 bytes are the ETC1 data, and the next 262144 bytes is the alpha channel.

These textures require a size of  bytes.

PVRTC
These are compressed textures used in the iOS versions.

They are simply PVRTC 4bpp RGBA textures stripped of their headers.