Users browsing this thread: 3 Guest(s)
CMPR texture file decoding
#1
Hi everyone,

A few months ago I've created this thread, but since then I got further. I'm trying to get MySims Kingdom Wii's texture files that are stored in compressed archive-like files called packages, used by many Sims games but are different from a game to an another. Thanks to S3PE software (it's the only package editor able to open almost every MySims packages) I got into a MySims Kingdom package, but it only let me export files from package because the software is not designed for this kind of package. When extracted, I got the unreadable image file, and thanks to Dolphin's texture compression format detector I know the game uses CMPR (or DXT1).

User TGE created a script that let us extract models from specific packages from an another MySims game and it also extracts the package's TPLs, even if package format is different and does not work for MySims Kingdom's packages I'm pretty sure that texture compression is similar so the maxscript could contains useful informations:

Code:
gc()
enableSceneRedraw()
clearlistener()

global globalStartTime = timestamp()
global globalImportedFilePath = ""
global globalBoolApplyNormals = false
global globalBoolApplySkinning = false


-- Structs

struct PakEntryInfoStruct
(
  unk1,     -- u32
  unk2,     -- u32
  offset,     -- u32
  size,        -- u32
  type        -- procedural, u32
)

struct VertDescriptorStruct
(
  gxAttr                 = 0, -- byte
  stride                 = 0, -- byte
  unk                     = 0, -- 4 bytes
  vertArrayOffset     = 0  -- u32
)


-- General helper functions

fn GetOpenFile =
(
  clearlistener()
  local fname = getOpenFileName \
  caption:"Open Model" \
  types:"Package file (*.package)|*.package" \
  historyCategory:"PACKAGEWII Object Presets"
  if (fname == undefined) then
  (
      return undefined
  )
  else
  (
      globalImportedFilePath = fname
      local f = fopen fname "rb"
      return f
  )
)

-- Reading functions

fn ReadBEShort fstream =
(
  return bit.swapBytes (ReadShort fstream #unsigned) 1 2
)

fn ReadBELong fstream =
(
  return bit.swapBytes (bit.swapBytes (ReadLong fstream #unsigned) 1 4) 2 3
)

fn ReadBEFloat fstream =
(
  return bit.intAsFloat (bit.swapBytes (bit.swapBytes (ReadLong fstream #unsigned) 1 4) 2 3)
)

fn ReadBEVector3 fstream =
(
  return [(ReadBEFloat fstream), (ReadBEFloat fstream), (ReadBEFloat fstream)]
)

fn ReadBEVector4 fstream =
(
  return [(ReadBEFloat fstream), (ReadBEFloat fstream), (ReadBEFloat fstream), (ReadBEFloat fstream)]
)

fn ReadBEMatrix44 fstream =
(
  return matrix3 (ReadBEVector4 fstream) (ReadBEVector4 fstream) (ReadBEVector4 fstream) (ReadBEVector4 fstream)
)

fn WriteBELong fstream val =
(
  WriteLong fstream (bit.swapBytes (bit.swapBytes val 1 4) 2 3)
)

fn WriteBEShort fstream val =
(
  WriteShort fstream (bit.swapBytes val 1 2)
)

fn GetEntryType fstream offset =
(
  local startPos = ftell fstream

Like said in my previous thread, this is the error I get in S3PE when trying to get a preview of the image file, it could be also useful:

Code:
Error reading resource 0x00B2D882-0x00000000-0xBA6D3A63FDA1EED7
Front-end Distribution: 14-0222-1852
Library Distribution: 14-0222-1852

Source: mscorlib
Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
----
Stack trace:
 à System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
 à System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
 à System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
 à System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
 à System.Activator.CreateInstance(Type type, Object[] args)
 à S3PIDemoFE.ABuiltInValueControl.<>c__DisplayClassd.<Lookup>b__a(KeyValuePair`2 x)
 à System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
 à System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
 à System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
 à S3PIDemoFE.MainForm.getPreviewControl()
----

Source: DDSPanel
Assembly: DDSPanel, Version=1402.22.1843.33690, Culture=neutral, PublicKeyToken=null
DDS Magic Number invalid.  Got 0x4901FE14, expected 0x20534444 ('DDS ').  At 0x00000004.
----
Stack trace:
 à System.Drawing.Dds.DdsHeader..ctor(Stream s)
 à System.Drawing.Dds..ctor(Stream s)
 à System.Drawing.DdsFile.Load(Stream input, Boolean supportHSV)
 à System.Windows.Forms.DDSPanel.DDSLoad(Stream stream, Boolean supportHSV)
 à S3PIDemoFE.DDSControl..ctor(Stream s)
----

The file format is definitely not DDS. So what could it be, and if it's custom, how could I find the way to get a view of these image files? Dolphin is useful for getting textures from the game, but what I'm trying to get is fully unused in the game, that's why it's so interesting for me to view these files.

What do you think guys? Is someone able to get something from the file I have attached? In this archive, the first file is a random texture extracted from a package exactly how S3PE extracts it, even if .DDS is not correct. The other file is a whole (light) package containing exactly two image files in case the file I extracted is broken and/or someone wants to create a program or something that could extracts readable textures directly from the package. I have not tested Wimgt from Wiimms SZS tools because for an unknown reason my computer doesn't want to install it. However this software seems to be the most complete one for this use so it's possible it can decode the files. Like said below, all other tools, including BrawlBox, are not working. Help is truly appreciated, thanks a lot.


Attached Files
.zip   MSK files.zip (Size: 265.25 KB / Downloads: 186)
Sorry for bad spelling, I don't speak fluent English.
Reply
Thanked by:
#2
You can use BrawlBox to open up the TPL texture container. S3PE crashes because it expects a valid DDS header, but seeing as the format doesn't use DDS, it will crash.
Reply
Thanked by:
#3
(11-05-2016, 06:37 AM)TGE Wrote: You can use BrawlBox to open up the TPL texture container. S3PE crashes because it expects a valid DDS header, but seeing as the format doesn't use DDS, it will crash.

I tried BrawlBox and many other TPL opener software but none is opening them. In the case of BrawlBox, I got the following error: "Unable to recognize input file".
Sorry for bad spelling, I don't speak fluent English.
Reply
Thanked by:
#4
Any idea?
Sorry for bad spelling, I don't speak fluent English.
Reply
Thanked by:


Forum Jump: