the Phrozen Forums
  Graphics and Animation
  Hex editing directions.......

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Hex editing directions.......
Incandescent One
Honorary Warlord

Posts: 272
From: Great Britain
Registered: Nov 2001

posted 08 December 2001 10:36     Click Here to See the Profile for Incandescent One   Click Here to Email Incandescent One        Reply w/Quote   Visit Incandescent One's Homepage!
So i'm curious now, how are the directions in a .cl2 file (D,LD,L,UL,U,UR,R,RD) hexed to that of a normal .dcc (DL,UL,UR,DR,D,L,U,R)? Anyone willing to share this, i'm sure it saves a lot of time

IP Logged

FoxBat
Moderator

Posts: 1618
From: PA, USA
Registered: Feb 2001

posted 08 December 2001 12:39     Click Here to See the Profile for FoxBat   Click Here to Email FoxBat        Reply w/Quote   
Quick rundown of the "basic" cl2 format.

First 8 dwords are pointers to "frame group pointers".

Frame group pointers, are groups pointers to all the frames for a single direction. The first dword in a "frame group pointer" entry is the # of frames of animation. Then you have the pointer to the beginning of the first animation, then the second, then the third.... up to the last, and then a pointer to the byte right AFTER the end of the last animation. Also, all these pointers are "relative": that is, you add the value here with the value of the pointer that pointed TO the whole frame group, to get the actual location.

Eg

Beginning of file:20x

Go to 20x:

05 00 00 00

5 frames. At 24x:

05 86 00 00

8605x + 20x = 8625x

The first frame for the first direcion thus starts at 8625x.

Now about the directions.

U=up
UR=up right diagonal
R=right
DR= down right diagonal
D=down
DL= down left diagonal
L= left
UL=up left diagonal

D1:

D DL L UL U UR R DR

D2:

DL UL UR DR D L U R


So what to do with this?

You can just change the order of the initial pointers pointing to the frame group pointers, symbolically start with

A B C D E F G H

copy the values around to make

B D F H A C E G

however, there's a problem. Cv5 demands that A not move (it uses this to determine where the pointers to frame groups end) Therefore we must do

A D F H B C E G

and then, you have to go in and change all of the frame pointers to get A to point at B's frames, and B's to As. You can't get away with just changing the pointer to the frame pointers. Copy B's pointers to A and A's to B. Add (B - A) to the now-B's pointers, subtract (B - A) from now-A's pointers.

[This message has been edited by FoxBat (edited 08 December 2001).]

IP Logged

Incandescent One
Honorary Warlord

Posts: 272
From: Great Britain
Registered: Nov 2001

posted 08 December 2001 14:42     Click Here to See the Profile for Incandescent One   Click Here to Email Incandescent One        Reply w/Quote   Visit Incandescent One's Homepage!
Originally posted by FoxBat:
Also, all these pointers are "relative": that is, you add the value here with the value of the pointer that pointed TO the whole frame group, to get the actual location.

Eg

Beginning of file:20x

Go to 20x:

0500 0000

5 frames.
At 24x:

0586 0000

The first frame for the first direcion thus starts at 8625x.

I was with you up until that point

First dword:
2000 0000
At 20x, 16 frames:
1000 0000
At 24x i've got this dword:
4002 0000
I couldn't work out how you arrived at 8625x in your example
I keep yawning to increase the internal dimensions of my head and let my brain wander round a bit, but its not getting me anywhere! Thanx a lot btw, i do appreciate it, Could you get back to me on this?


IP Logged

FoxBat
Moderator

Posts: 1618
From: PA, USA
Registered: Feb 2001

posted 08 December 2001 18:22     Click Here to See the Profile for FoxBat   Click Here to Email FoxBat        Reply w/Quote   
Remember to reverse the dwords.

Ie

06 85 00 00 == 00008506x

then add 20x

00008526x

[This message has been edited by FoxBat (edited 08 December 2001).]

IP Logged

Incandescent One
Honorary Warlord

Posts: 272
From: Great Britain
Registered: Nov 2001

posted 09 December 2001 10:59     Click Here to See the Profile for Incandescent One   Click Here to Email Incandescent One        Reply w/Quote   Visit Incandescent One's Homepage!
Hey Foxbat, you're a star i've changed all the anims around, got my palette probs sorted out now as i'm not converting from .gif.
So, i can finally say it's finished, thanx for your patience man

IP Logged

FoxBat
Moderator

Posts: 1618
From: PA, USA
Registered: Feb 2001

posted 09 December 2001 15:16     Click Here to See the Profile for FoxBat   Click Here to Email FoxBat        Reply w/Quote   
Still, it would be nice to understand why there is so much pallete trouble with gifs. (Got any ideas Teknyoko? I'm sure youve had to deal with this kinda stuff for DotD)

IP Logged

Incandescent One
Honorary Warlord

Posts: 272
From: Great Britain
Registered: Nov 2001

posted 09 December 2001 16:00     Click Here to See the Profile for Incandescent One   Click Here to Email Incandescent One        Reply w/Quote   Visit Incandescent One's Homepage!
Hey foxbat, could have been any number of factors in my screwy palettes, not least of which was the fact that i was using a superunique that doesn't have a palshift, to overwrite a superunique in another area of the game.
Plus, the Gif studio i was using generated it's own palettes as it went along that were never the same twice!!
The end result is all that counts for me, but, i too would still like to know the reason behind this problem

IP Logged

TeknoKyo
Forum Admin.

Posts: 1734
From:
Registered: Feb 2001

posted 10 December 2001 23:48     Click Here to See the Profile for TeknoKyo   Click Here to Email TeknoKyo        Reply w/Quote   Visit TeknoKyo's Homepage!
This is a good reason why Foxbat should be a moderator here ...

As for gif to .dcc colors ... it's usually during the .dcc save using the various pallette options. ... I posted a new topic on .gifs and .dcc.

------------------
http://www.planetdiablo.com/teknokyo/

IP Logged

BlacKD
Serf

Posts: 11
From: Curitiba, Paraná, Brazil
Registered: Aug 2001

posted 13 December 2001 00:27     Click Here to See the Profile for BlacKD   Click Here to Email BlacKD        Reply w/Quote   
I've created a small VB program to do that HEX Stuff. Just have to load a .cl2 file or any folder (it will scan that folder and subfolders for .cl2 files) and will do the proper changes.
I just need to know if am I doing something wrong with the directions (It will be easy to fix in case it turns to be wrong).

I need someone to load any original .cl2 file and then compare the result of my porgram with the result of doing it on HEX by hand. If its the same, the directions are OK. Please say if the directions are messed to:
raogabriel@oceanfree.net

The program is here:
http://lightning.prohosting.com/~raoni//files/Realigner.zip


Anyway, I'm facing some problems with the common dialog interface (ocx)
so maybe you won't be able to load single files. Just use the folder button.
Please report if the commondialog (used when selecting single files) is not working.

IP Logged

BlacKD
Serf

Posts: 11
From: Curitiba, Paraná, Brazil
Registered: Aug 2001

posted 13 December 2001 01:26     Click Here to See the Profile for BlacKD   Click Here to Email BlacKD        Reply w/Quote   
' *
' This code was designed by BlacK****
' raogabriel@oceanfree.net
' *
'Creates a new type to store info
Public Type FRAME_GROUP
A As Long
B As Long
C As Long
D As Long
E As Long
F As Long
G As Long
H As Long
End Type
Public Function Realign(filename As String) As Long
'Freefile, obviously
filenum = FreeFile
'Variables to store the number of frames
Dim n_frames_a As Long
Dim n_frames_b As Long
'Arrays to deal with
Dim array_a() As Long
Dim array_b() As Long
Dim new_array_a() As Long
Dim new_array_b() As Long
'Create the frames
Dim my_old_frames As FRAME_GROUP
Dim my_new_frames As FRAME_GROUP
On Error GoTo 1
Open filename For Binary As filenum
'VB first offset is 1, not 0
Get #filenum, 1, my_old_frames
'Checks if the file has 8 directions (must have a 32 bytes header)
'therefore,the first frame group should be at 32
If my_old_frames.A = 32 Then
'Get the number of frames
Get #filenum, 1 + my_old_frames.A, n_frames_a
Get #filenum, 1 + my_old_frames.B, n_frames_b
'Checks if n_frames_a=n_frames_b
'otherwise, how could we swap?
If n_frames_a = n_frames_b Then
'Redim arrays to (frames+last_byte_info)
'We don't need to change the number of frames, since it is the same
'so we only need to grab the info of frames+last byte
ReDim array_a(1 To n_frames_a + 1) As Long
ReDim array_b(1 To n_frames_b + 1) As Long
ReDim new_array_a(1 To n_frames_a + 1) As Long
ReDim new_array_b(1 To n_frames_b + 1) As Long
'Fill the old arrays
'We don't need to get the nframes again, grab the stuff at frame group start+4
Get #filenum, 5 + my_old_frames.A, array_a
Get #filenum, 5 + my_old_frames.B, array_b
'Fill the new arrays
Dim t As Integer
For t = 1 To (UBound(array_b))
new_array_a(t) = array_b(t) + my_old_frames.B - my_old_frames.A
Next t
'I know, use two FOR-NEXT is lamme but this is suposed to be an easy code
For t = 1 To (UBound(array_a))
new_array_b(t) = array_a(t) + my_old_frames.A - my_old_frames.B
Next t
'Fill the new offsets
my_new_frames.A = my_old_frames.A
my_new_frames.B = my_old_frames.D
my_new_frames.C = my_old_frames.F
my_new_frames.D = my_old_frames.H
my_new_frames.E = my_old_frames.B
my_new_frames.F = my_old_frames.C
my_new_frames.G = my_old_frames.E
my_new_frames.H = my_old_frames.H
'Put the stuff back
Put #filenum, 1, my_new_frames
Put #filenum, 5 + my_old_frames.A, new_array_a
Put #filenum, 5 + my_old_frames.B, new_array_b
Close #filenum
'Success!
Realign = 0
Else
'n_frames_a<>n_frames_b so we fail
Realign = -3
End If
Else
'File is not 8 directions based
Realign = -2
End If
Exit Function
'Could not open file
1 Realign = -1
End Function

IP Logged

mandzo
Moderator

Posts: 658
From: Bulgaria,Sofia
Registered: Aug 2001

posted 17 December 2001 08:17     Click Here to See the Profile for mandzo   Click Here to Email mandzo        Reply w/Quote   Visit mandzo's Homepage!
hey man cool prog but there is one wrong direction you the last one must be rigth not right down you have to fix that but it still is a cool tool

------------------
Read or DIE
Muahahahaha

the next beta is coming and its beter then ever

IP Logged

BlacKD
Serf

Posts: 11
From: Curitiba, Paraná, Brazil
Registered: Aug 2001

posted 17 December 2001 09:31     Click Here to See the Profile for BlacKD   Click Here to Email BlacKD        Reply w/Quote   
I'll take time to fix this.
I'm on vacation, that's why I needed to know if the program was bugged, so I could fix it. I don't have VB right here and neither I have the mood to take a look on this stuff. This will have to wait till 15 January.

Thanks for the reply mandzo. I got your message on my ICQ.

IP Logged

All times are Central Standard Time

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | The PhrozenKeep

© PhrozenKeep.com . all buttons made by the Evilenglishman . swords and shields by DigiBO.


Ultimate Bulletin Board 5.47c