Page 2 of 7 FirstFirst 1 2 3 4 ... LastLast
Results 11 to 20 of 70

Thread: DK2 texture format

  
  1. #11
    Demon Spawn
    Join Date
    Sep 2009
    Location
    Germany
    Posts
    188

    Default Re: DK2 texture format

    Well, most probably the textures are loaded at startup and used some time later when they're needed. That's why I didn't follow that code in IDA but debugged it.
    So I put some breakpoints on the read texture data at v12 (which starts with that strange int resxy to break as soon as the game touches the data again.
    But it doesn't. I think this should mean it isn't changed anymore and passed directly to DirectX, but S3TC uses fixed-rate compression and I don't know what was used before.

    Maybe using a proxy dll like IKSLM did for DKER would shed some light on it, but I'm not really familiar with COM, DX & Co.

  2. #12
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: DK2 texture format

    I'm sure you can find it with these ways too...

    Anyway, first try to take a look at:
    Code:
    int __thiscall sub_5907D0(struct eheapitm1 *this, int a1, int a2, int a3)
    Especially its subfunctions.

    btw, function (off_67039C + 32) was:
    Code:
    int __thiscall sub_5906C0(struct eheapitm1 *this, int *a2)
    {
      *a2 = this->mem14_len;
      return this->ptrfield_14;
    }
    This is how I realized that the class with vtable at .rdata:0067039C must have a decoder in its methods.

  3. #13
    Demon Spawn
    Join Date
    Sep 2009
    Location
    Germany
    Posts
    188

    Default Re: DK2 texture format

    Hell yeah!
    Just found a fantastic plugin that scans for vtables and look what it yielded:

  4. #14
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: DK2 texture format

    Wow.. you mean it was able to name all vtables?
    How!?
    I WANT IT!

    EDIT:
    I just tried to name them manually; I see the names, but I have no idea where's an offset for every name.
    Last edited by mefistotelis; October 2nd, 2009 at 12:35.

  5. #15
    Demon Spawn
    Join Date
    Sep 2009
    Location
    Germany
    Posts
    188
    Last edited by Trass3r; October 8th, 2009 at 22:01.

  6. #16
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: DK2 texture format

    Thank you!

    btw, I've got quite mature IDA project for DK1 (all routines named, most of structures defined). Let me know if you want it.

    Oh, and don't forget to check the function which I posted before

  7. #17
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: DK2 texture format

    Code:
    class CEngineSurfaceBase {
      public:
        CEngineSurfaceBase(long w, long h);
        virtual ~CEngineSurfaceBase();
        virtual void fill(unsigned short val);
        virtual bool put_image(struct CEngineSurfaceBase *dst, int pos_x, int pos_y);
        virtual bool get_image(struct CEngineSurfaceBase *src, int pos_x, int pos_y);
        virtual int func_10(void) = 0;
        virtual bool out_supported(void) = 0;
        virtual unsigned char *get_out_buffer(void)
        virtual void func_1C(int a2);
        virtual unsigned char *get_data_buffer(long *len);
    
        long width;
        long height;
        unsigned long line_len;
        void *ptrfield_10;
    };
    
    
    class CEngineCompressedSurface public CEngineSurfaceBase {
      public:
        CEngineCompressedSurface();
        virtual ~CEngineCompressedSurface();
        virtual bool put_image(struct CEngineSurfaceBase *dst, int pos_x, int pos_y);
        virtual bool get_image(struct CEngineSurfaceBase *src, int pos_x, int pos_y);
        virtual int func_10(void);
        virtual bool out_supported(void);
        virtual unsigned char *get_data_buffer(long *len);
    
        unsigned char *data;
        long data_len;
    };
    Did you made any progress?
    Last edited by mefistotelis; October 4th, 2009 at 19:58.

  8. #18
    Demon Spawn
    Join Date
    Sep 2009
    Location
    Germany
    Posts
    188

    Default Re: DK2 texture format

    So, have you already found the decompression function?

  9. #19
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: DK2 texture format

    Quote Originally Posted by Trass3r View Post
    So, have you already found the decompression function?
    yes.
    It's complex.

    I've reworked a lot of code around it, but didn't touched it - it's scary. Floating point arithmetic. Very scary.

    Code:
    bool CEngineCompressedSurface::put_image(struct CEngineSurfaceBase *dst, int pos_x, int pos_y)
    {
      unsigned char *obuf;
      unsigned char *ptr;
      class GraphicsParams *gr_par;
    
      if ( !dst->out_supported() )
        return false;
      obuf = dst->get_out_buffer();
      gr_par = dst->graph_params;
      ptr = obuf + dst->line_len * pos_y + pos_x * gr_par->bytes_per_pix;
      sub_5B2450(gr_par->mask_g1, gr_par->mask_b1, gr_par->mask_a1, gr_par->mask_r1);
      sub_5B26F0(this->data, ptr, dst->line_len, this->width, this->height);
      dst->func_1C(obuf);
      return true;
    }
    First one seems to make some arrays; 2nd one in the decoder.

    I will upload the whole project when I have more time. It has all classes/structures defined, only decoder (and encoder - I found it too) is missing.

  10. #20
    Demon Spawn
    Join Date
    Sep 2009
    Location
    Germany
    Posts
    188

    Default Re: DK2 texture format

    Yeah baby
    We could try to write a wrapper around the exe if the en-/decoder is that heavy.

Similar Threads

  1. Best dk2 AI!!!
    By blragh in forum Dungeon Keeper 2
    Replies: 49
    Last Post: November 27th, 2010, 12:26
  2. Dk1 vs dk2
    By dk2player in forum Off Topic
    Replies: 34
    Last Post: October 6th, 2009, 17:43
  3. A complete guide: How to play DK2 multiplayer
    By Ðârk Âñgêl in forum DK2 Multiplayer
    Replies: 0
    Last Post: September 1st, 2009, 15:55

Tags for this Thread

Posting Permissions

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