PDA

View Full Version : [Tutorial] DPPt Palette Colors

Alpha de Splash
April 20th, 2009, 7:59 AM
Here's my two cents on the Palette Colors:
Files extracted having the RLCN file type, or the RLCN magic stamp (hex: 524C 434E) are palette files. after that there are 18 words (36 bytes) of information about filesize which seem to be mostly the same. Then are the colors. Each color is 1 word (2 bytes) long. and i have created an algorithm for the hexadecimal equivalent of the color: (written in PHP by me)

//This is a comment
\$byte = str_split(\$bytes);//\$byte[0] is first digit of the word, \$bytes[3] is 4th digit
//These are the variables for the Digits of the word
\$byte[0] = hexdec(\$byte[0]);//first digit(decimal)
\$byte[1] = hexdec(\$byte[1]);//2nd digit(decimal)
\$byte[2] = hexdec(\$byte[2]);//3rd digit(decimal)
\$byte[3] = hexdec(\$byte[3]);//4th digit(decimal)

if (\$byte[0]%2==0){//if the first digit evenly divides by 2 (has a zero remainder)
\$data = 0;// just another variable
}
else {//if it is odd
\$data = 8;
}

\$hex[0] = dechex(((\$byte[1]-(\$byte[1]%2))/2)+\$data);
//take the first digit and drop down to the nearest even number (1 to 0, 2 to 2, 9 to 8)and divide by two. then add the thing from above. This is the first hexadecimal number of the color

\$data = ((\$byte[1]%2)*8);//sets a variable to either 0 if the second digit of the word is even or 8 if odd

\$hex[1] = dechex(\$data);//turn that variable just above into the second digit of the color (it doesn't really need to be turned back into hex because it is same)

\$data = ((\$byte[3]%4)*4);// take the remainder of the last digit of the word when divided by 4 (6 divided by 4 is 1 remainder 2, so use 2).

\$hex[2] = dechex(((\$byte[0]-(\$byte[0]%4))/4)+\$data);//drop the value of the first byte to the nearest 4 (10 goes to 8, 7 to 4, 4 to 4)and add the variable from above

if (\$byte[1]%4==0||\$byte[1]%4==1){//if the remainder when divided by 4 is 0 or is 1, set the variable to 0
\$data = 0;
}
else{// if it is 2 or 3, set it to 8
\$data = 8;
}

\$hex[3] = dechex(\$data);// that variable is the 4th number of the color

if (\$byte[3] > 7){//if the last digit of the word is 8,9,10...14,15, or 16 then the variable is 1
\$data = 1;
}
else{//if the digit is 7 or under, the variable is 0
\$data = 0;
}

\$hex[4] = dechex(((\$byte[2]%8)*2)+\$data);// the remainder of the 3rd digit of the word when divided by 8 is multiplied by 2 then added to the variable above to make the 5th number of the color

if ((\$byte[3]<8 && \$byte[3]>4) || (\$byte[3]<16 && \$byte[3]>11)){
\$data = 8;//if the last digit is 5,6,7,12,13,14,15 then the variable is 8
}
else{//if the last digit is 0,1,2,3,4,8,9,10,11 then it is 0
\$data = 0;
}

\$hex[5] = dechex(\$data);// that becomes the last variable

\$fullhexstring = '#' . \$hex[0] . \$hex[1] . \$hex[2] . \$hex[3] . \$hex[4] . \$hex[5];// are combined now to get the final result

I am well aware that there are tools that can do this, but we should know what is actually going on. Feel free to criticize.