Register for your free account! | Forgot your password?

You last visited: Today at 06:18

  • Please register to post and access all features, it's quick, easy and FREE!


TQ Custom RLE Ecoded Images

Reply
 
Old 08/06/2018, 15:32   #16
 
elite*gold: 0
Join Date: Jul 2018
Posts: 15
Received Thanks: 9
Quote:
Originally Posted by Super Aids View Post
This is really interesting. MAM was godlike.
It really is. I've been really excited about this project. Although the client rebuild isn't really progressing yet for above reasons, the alpha release is almost ready. Server is functional and English client is patched and working too. We are still translating the DB and fixing bugs, but nearly there


So these files are still being tricky little bastards. No variation of the HSV seems to give me correct or expected colors. Thus, I seem to have hit another wall. I haven't yet found the flag which decides vertical orientation / origin pixel position (tells you to draw from top/down left/right), so some of the sprites are still flipped (eww).

Looks like my best bet might really be to reverse engineer the game client to understand how it reads and operates on the RLE files. Although I have had some success in reverse engineering different packet calculations (including a nasty little bug with a battle action packet), these RLEs still insist on being the death of me. I tracked down the code which finds the '.RLE' extension, but it looks like it just results in storing the file in memory, then continues on its merry way doing other non image related operations. So something must pick it up from memory to parse the file and draw to screen. Problem is hunting down WHAT does that.

For any of you who might've worked on reversing conquer, are there any tips you may be able to provide? I know a lot of their assets are in c3(2.5d~) format, but perhaps there are certain sprites or 2d images that get used and drawn using similar methods. I see a lot of references to borland TForms, and various import drawing libraries, but these seem to handle drawing aspects of the forms, and not actual sprites. But perhaps I am making a bad assumption there. Just because there isn't a visible form doesn't mean the monsters aren't drawn on some form element.



Jonathis is offline  
Old 08/07/2018, 09:30   #17
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,615
Received Thanks: 833
Quote:
Originally Posted by Jonathis View Post
but it looks like it just results in storing the file in memory, then continues on its merry way doing other non image related operations. So something must pick it up from memory to parse the file and draw to screen. Problem is hunting down WHAT does that.
Well since you can see that it stores it in memory then you'd also have the address in which the data is stored at.

What you could do is scan for that address and from that you should be able to get where it's used.

It might be a little tricky though.


Super Aids is offline  
Old 08/13/2018, 02:45   #18
 
elite*gold: 0
Join Date: Jul 2018
Posts: 15
Received Thanks: 9
RLE files have successfully been fully decoded *YAY*

After toiling away for many an hour, I finally reversed enough of the game client to find all the RLE to RGB conversions and header info needed. Sad to say, the HSL range color changes still remain unsolved, I have at least located part of the code behind that as well, and am working on deciphering it.

Lots of testing done and I confirmed the RLE is stored in HSL and converted into a 16bit RGB, which is upscaled to 32bit (24 bit rgb + 8bit alpha). If anyone wants the details on how the RLE file and header are read, just let me know.

Fortunately, not all RLE sprites have color conversions though. Some come in their native colors such as the following character sprites:



I can finally proceed with my client rebuild! Very exciting. Started working on an animator test already, which is going pretty smoothly.

Some of the source logic is pretty funky. At some point I ought to do lots of mathy things to figure out the bitshift and bitwise operation equivalents in human readable math form. Kinda not too excited about the idea of that though lol..

Here is the color map HSL to RGB code:
Code:
void RLEtoRGB(int* rgb, HSLColor in)
{
	unsigned _int8 mColor[3];
	mColor[0] = in.hue;
	mColor[1] = in.sat;
	mColor[2] = in.light;

	int C;
	unsigned _int8 Z=0, X1, X2;
	int v3, v4;

	C = 4 * mColor[2];
	if (mColor[1]) {
		v3 = mColor[0] & 0x1F;
		v4 = C * mColor[1];
		Z = (((unsigned int)mColor[2] << 8) - v4) >> 6;
		X1 = (((unsigned int)mColor[2] << 13) - v3 * v4) >> 11;
		X2 = (v3 * v4 + ((unsigned int)mColor[2] << 13) - 32 * v4) >> 11;

		switch ((signed int)mColor[0] >> 5) {
			case 0:
				ConvertTo16BitRGB((BYTE*)rgb, C, X2, Z);
				break;
			case 1:
				ConvertTo16BitRGB((BYTE*)rgb, X1, C, Z);
				break;
			case 2:
				ConvertTo16BitRGB((BYTE*)rgb, Z, C, X2);
				break;
			case 3:
				ConvertTo16BitRGB((BYTE*)rgb, Z, X1, C);
				break;
			case 4:
				ConvertTo16BitRGB((BYTE*)rgb, X2, Z, C);
				break;
			case 5:
				ConvertTo16BitRGB((BYTE*)rgb, C, Z, X1);
				break;
			default:
				ConvertTo16BitRGB((BYTE*)rgb, 0, 0, 0);
				break;
		}
	}
	else {
		ConvertTo16BitRGB((BYTE*)rgb, C, C, C);
	}
}

BYTE* ConvertTo16BitRGB(BYTE *rgb, int a, int b, int c) {
	*rgb = *rgb & 0xE0 | (c >> 3) & 0x1F;
	*(WORD *)rgb = *(WORD *)rgb & 0xF81F | 32 * ((b >> 2) & 0x3F);
	rgb[1] = rgb[1] & 7 | 8 * ((a >> 3) & 0x1F);
	return rgb;
}
Jonathis is offline  
Thanks
3 Users
Old 08/13/2018, 11:29   #19
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,615
Received Thanks: 833
Can't wait to see where this goes. I hope it's not another project that gets lost in a desert of lost motivation.


Super Aids is offline  
Old 08/13/2018, 18:32   #20
 
elite*gold: 0
Join Date: Jul 2018
Posts: 15
Received Thanks: 9
Quote:
Originally Posted by Super Aids View Post
Can't wait to see where this goes. I hope it's not another project that gets lost in a desert of lost motivation.
It helps having a team of people to work with, though I am the only programmer. The alpha rerelease is very soon, as we only have the auto-patch server to get up and running, and a few bugs to fix, sans all the Chinese translations which'll be a continuous project lol. Client rebuild project is in prep for our next phase. Since botting ran rampant on the game back in the day, the plan is to actually integrate the bots into the client and 'restructure' the game around the concept of automating the menial things, while emphasizing the more interesting aspects of the game.

As for the motivation issue.. I spent a month and a half decoding these RLEs. If I can get through that mess, I have no concerns about motivation on this project
Jonathis is offline  
Thanks
1 User
Old 08/13/2018, 19:03   #21

 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,394
Received Thanks: 1,055
Quote:
Originally Posted by Jonathis View Post
It helps having a team of people to work with, though I am the only programmer. The alpha rerelease is very soon, as we only have the auto-patch server to get up and running, and a few bugs to fix, sans all the Chinese translations which'll be a continuous project lol. Client rebuild project is in prep for our next phase. Since botting ran rampant on the game back in the day, the plan is to actually integrate the bots into the client and 'restructure' the game around the concept of automating the menial things, while emphasizing the more interesting aspects of the game.

As for the motivation issue.. I spent a month and a half decoding these RLEs. If I can get through that mess, I have no concerns about motivation on this project
Are you using TQ AutoPatch? I made a server for it a while back, could send you the source code if you don't want to develop it or do a custom AutoPatch.
CptSky is offline  
Thanks
1 User
Old 08/13/2018, 19:48   #22
 
elite*gold: 0
Join Date: Jul 2018
Posts: 15
Received Thanks: 9
Quote:
Originally Posted by CptSky View Post
Are you using TQ AutoPatch? I made a server for it a while back, could send you the source code if you don't want to develop it or do a custom AutoPatch.
That would be amazing. We have one of their old auto-patch servers, without source code. It seems to run structurally the same way as the CO one, so I'm assuming it ought to work with yours too by the sound of it. I would much appreciate that


Jonathis is offline  
Reply

Tags
decoding, image, rle, tq



« Packet update class "10014" and name packet "SpawnPlayer" with source alex 3D | hi »

Similar Threads
MLE AND RLE is has been Detected
08/03/2009 - Grand Chase Philippines - 24 Replies
detect na poh ung ating moonlight engine at radical engine kailan poh mag kakamerun ng bagong engine!!!??



All times are GMT +2. The time now is 06:18.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.