Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 48
  1. #11
    EmuTalk Member
    Join Date
    Jun 2007
    Posts
    61
    Looks interesting, when do you think you'll be able to post the program?

    Last edited by antidote; October 7th, 2009 at 01:50.


    • Advertising

      advertising
      EmuTalk.net
      has no influence
      on the ads that
      are displayed
        
       

  2. #12
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    18
    Possibly after we get this segment figured out and the mesh headers, I'd like to not release it until we have basic support for all the files in all the games, but, revl8n has his own say, he can release whenever he's ready as I can too. So who knows?

    But it will be released, and it will be open source! ^_^

    if someone could come on and tell us how the material segment is laid out that'd be really awesome, the stuff after what texture what segment uses. >_> Attribute data and the like
    Last edited by interdpth; October 7th, 2009 at 04:36.

  3. #13
    EmuTalk Member
    Join Date
    Jun 2007
    Posts
    61
    Sarah! oh Sarah! *picks up rock*

    hmm... sorry can't find him...

    Wish I knew how to help you, i'll take a look but I know next to nothing about image formats.

  4. #14
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    18
    Got blending and all that stuff working. So new screenshots.
    Tomorrow i'll take a look at material defs seeing as how I now know lighting is controlled in there.

    The viewer is officially called MPxViewer.
    Revl8n is taking a look at the animation stuff right now, hopefully we can finish CMDL soon, and move on to other things.

    There's a surprise at the end XD

    Beta Gravity
    Yes, there is more to the inside, it's just that circle textured. We never see inside it...I wonder why they felt the need to texture it




    Basic MP2 support.
    Material Definitions and other bugs are plaguing MPxViewer for now, support will be added of course.

  5. #15
    EmuTalk Member
    Join Date
    Feb 2007
    Posts
    72
    MP2 support? Nice! Keep up the good work!
    Any plans for MP3 too?

  6. #16
    EmuTalk Member
    Join Date
    Jun 2007
    Posts
    61
    *Drools* blending

    Well looking good keep up the excellent work

  7. #17
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    18
    Yes of course there will be MP3 support! ^_^

    Honestly i've had enough of the CMDL format, we'll probably get back to eventually, but models render amazingly.

    But in this update, you'll see that we have a tree view now, it needs a bit more work. XD

    But raw texture viewer is now implemented, and a skeleton viewer is too! ^_^




    Samus's skeleto
    some cool looking texture.

  8. #18
    EmuTalk Member
    Join Date
    Jun 2007
    Posts
    61
    *GLOMPS* I luv you Interdpth!

  9. #19
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    18
    Update:


    We also have some support for MREA's but this is the one I wanted to show.

  10. #20
    EmuTalk Member
    Join Date
    Jun 2007
    Posts
    61
    mp3 lzo compression = cracked

    Code:
    //version 2.0 (20061001)
    //by thakis
    
    //decompresses compressed metroid prime files.
    //metroid prime 1 uses zlib compression,
    //metroid prime 2 uses segmented LZO1x (thanks to SkippyJr
    // for pointing this out)
    
    //zlib decompression is handled by http://www.zlib.net/,
    //LZO code (lzo.h/c) was taken from ffmpegs libavcodec.
    
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>
    #include "zlib.h"
    #include "lzo.h"
    
    using namespace std;
    
    typedef unsigned char u8;
    typedef unsigned short u16;
    typedef unsigned int u32;
    
    char* fname;
    vector<u8> dst;
    
    inline void toWORD(u16& d)
    {
        u8 w1 = d & 0xff;
        u8 w2 = (d >> 8) & 0xff;
        d = (w1 << 8) | w2;
    }
    
    inline void toDWORD(u32& d)
    {
        u8 w1 = d & 0xff;
        u8 w2 = (d >> 8) & 0xff;
        u8 w3 = (d >> 16) & 0xff;
        u8 w4 = d >> 24;
        d = (w1 << 24) | (w2 << 16) | (w3 << 8) | w4;
    }
    
    #pragma pack(push, 1)
    
    struct HeaderMP1_2
    {
        u32 uncompSize;
        //mp1 has 0x78da (zlib stream with maximal compression)
        //mp2 has something else :-P (lzo doesn't seem to have a header)
        u16 compressionMethod;
    };
    
    struct HeaderMP3
    {
        char id[4];
        u32 unk; // version maybe?
        u32 unk2; // Hash?
        u32 uncompSize;
    };
    
    
    #pragma pack(pop)
    int decompressZLib(u8* source, int sourceSize, u8* dest, int dstSize)
    {
        int ret;
        z_stream strm;
    
        // allocate decompression state
        strm.zalloc = Z_NULL;
        strm.zfree = Z_NULL;
        strm.opaque = Z_NULL;
        strm.avail_in = sourceSize;
        strm.next_in = source;
        ret = inflateInit(&strm);
        if (ret != Z_OK)
            return ret;
    
        //decompress input
        strm.avail_out = dstSize;
        strm.next_out = dest;
        ret = inflate(&strm, Z_NO_FLUSH);
        assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
        switch (ret)
        {
        case Z_NEED_DICT:
            ret = Z_DATA_ERROR;     /* and fall through */
        case Z_DATA_ERROR:
        case Z_MEM_ERROR:
            (void)inflateEnd(&strm);
            return ret;
        }
    
        assert(strm.avail_out == 0);
        assert(ret == Z_STREAM_END);
    
        // clean up and return
        (void)inflateEnd(&strm);
        return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
    }
    
    int decompressLZO(u8* source, int sourceSize, u8* dest, u32& dstSize)
    {
        int size = dstSize;
        int result = lzo1x_decode(dest, &size, source, &sourceSize);
        dstSize = size;
        return result;
    }
    
    void WriteFile(FILE * inFile, u32 uncompSize, int size = 0)
    {
        if (size == 0)
        {
            u32 bytesLeft = uncompSize;
            while (bytesLeft > 0)
            {
                u16 segmentSize;
                fread(&segmentSize, sizeof(segmentSize), 1, inFile);
                toWORD(segmentSize);
                vector<u8> src(segmentSize);
                fread(&src[0], 1, segmentSize, inFile);
    
                int result = decompressLZO(&src[0], segmentSize,
                                           &dst[uncompSize - bytesLeft], bytesLeft);
    
                if ((result & LZO_ERROR) != 0)
                {
                    cerr << "Failed to decompress \'" << fname << "\'" << endl;
                    system("pause");
                    return;
                }
            }
        }
        else
        {
            vector<u8> src(size - 4);
            fread(&src[0], 1, size - 4, inFile);
            fclose(inFile);
    
            if (decompressZLib(&src[0], size - 4, &dst[0], uncompSize) != Z_OK)
            {
                cerr << "Failed to decompress \'" << fname << "\'" << endl;
                return;
            }
        }
        //write buffer to output file
        string inName = fname, outName;
        string::size_type pos = inName.rfind('\\');
        if (pos != string::npos)
            outName = inName.substr(0, pos + 1) + "0" + inName.substr(pos + 1);
        else
            outName = "0" + inName;
    
        FILE* outFile = fopen(outName.c_str(), "wb");
        if (outFile == NULL)
            return;
    
        fwrite(&dst[0], 1, uncompSize, outFile);
        fclose(outFile);
    }
    
    void decompressMP1_2()
    {
        FILE* inFile = fopen(fname, "rb");
    
        //get file size
        fseek(inFile, 0, SEEK_END);
        int size = ftell(inFile);
        fseek(inFile, 0, SEEK_SET);
    
        //read file
        HeaderMP1_2 h;
        fread(&h, sizeof(h), 1, inFile);
        toDWORD(h.uncompSize);
        toWORD(h.compressionMethod);
        fseek(inFile, -2, SEEK_CUR);
    
        //decompress to buffer
        dst.resize(h.uncompSize);
        if (h.compressionMethod == 0x78da)
            WriteFile(inFile, h.uncompSize, size);
        else
            WriteFile(inFile, h.uncompSize);
    }
    
    void decompressMP3()
    {
        FILE* inFile = fopen(fname, "rb");
    
        HeaderMP3 h;
    
        fread(&h, sizeof(h), 1, inFile);
        toDWORD(h.unk);
        toDWORD(h.unk2);
        toDWORD(h.uncompSize);
    
        dst.resize(h.uncompSize);
    
        WriteFile(inFile, h.uncompSize);
    }
    
    int main(int argc, char* argv[])
    {
        if (argc < 2)
            return EXIT_FAILURE;
    
        FILE* inFile = fopen(argv[1], "rb");
        if (inFile == NULL)
            return EXIT_FAILURE;
        fname = argv[1];
        u16 tmp;
        fread(&tmp, sizeof(tmp), 1, inFile);
        toWORD(tmp);
        fclose(inFile);
        switch (tmp)
        {
        case 0x434d:
            decompressMP3();
            break;
        default:
            decompressMP1_2();
            break;
        }
    
        return EXIT_SUCCESS;
    }
    currently the code is rather rough because i JUST cracked it and haven't had a chance to clean up the source and add support for the other formats back. so currently it can only decompress metroid prime 3 files

    EDIT:
    cleaned and reorginized
    Download here: mDecomp.zip
    EDIT2:
    Hmmm it seems that TXTR files use a different compression scheme, i'll have to look into that.
    Last edited by antidote; October 27th, 2009 at 09:18.

Page 2 of 5 FirstFirst 1234 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •