Jump to content
  • 0

DA commands


SanguinettiMods
 Share

Question

13 answers to this question

Recommended Posts

  • 0

Let's give gbi.h a look...

 

...
#define	G_MTX			0xda
...
/*
 * G_MTX: parameter flags
 */
#ifdef	F3DEX_GBI_2
# define G_MTX_MODELVIEW	0x00	/* matrix types */
# define G_MTX_PROJECTION	0x04
# define G_MTX_MUL		0x00	/* concat or load */
# define G_MTX_LOAD		0x02
# define G_MTX_NOPUSH		0x00	/* push or not */
# define G_MTX_PUSH		0x01
#else	/* F3DEX_GBI_2 */
...
#define	gDma2p(pkt, c, adrs, len, idx, ofs)				\
{									\
	Gfx *_g = (Gfx *)(pkt);						\
	_g->words.w0 = (_SHIFTL((c),24,8)|_SHIFTL(((len)-1)/8,19,5)|	\
			_SHIFTL((ofs)/8,8,8)|_SHIFTL((idx),0,8));	\
	_g->words.w1 = (unsigned int)(adrs);				\
}
...
#ifdef	F3DEX_GBI_2
# define	gSPMatrix(pkt, m, p)	\
		gDma2p((pkt),G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0)
http://naesten.dyndns.org:8080/psyq/man/gsp/gSPMatrix.html
Link to comment
Share on other sites

  • 0

The pointer (don't reference it as bbxxxxxx! just xxxxxxxx! this nasty habit will come to bite you in the ass some day) is a pointer to a matrix. Matrices are very powerful - they can perform translation, rotation, and scaling all in a 4x4 data set, as described in the document I linked to. Internally, OoT uses matrices all over the main display list to correctly scale the map, and position and animate objects. In some cases, however, the actor will set up a matrix in a special segment - above segment 8 - and it is to be used to translate vertices, a well known example being the "cloth" that connects link's limbs. tbh I don't completely understand it myself.

Link to comment
Share on other sites

  • 0

You're not going to like this answer.

 

I went on a wild goose chase in RAM, and here's what I got for the display list that renders Saria:

Posted Image

 

The "format" of the 0xDB06 commands is:

0xDB0600xx zzzzzzzz

x is segment * 4

z is the RAM address of that segment

I reference them as 0xDB06 because 0xDB is used for many purposes, but it is only used for setting segments when it is 0xDB06.

 

And a note on this perculiar matrix format:

 

aaaabbbb ccccdddd

eeeeffff gggghhhh

iiiijjjj kkkkllll

mmmmnnnn oooopppp

AAAABBBB CCCCDDDD

EEEEFFFF GGGGHHHH

IIIIJJJJ KKKKLLLL

MMMMNNNN OOOOPPPP

 

lowercase are the portion of the number before the decimal point,

uppercase/65536 is the portion of the number after the decimal point

both are signed.

 

Rows/columns:

a = [1,1]

b = [1,2]

c = [1,3]

d = [1,4]

e = [2,1]

..

h = [2,4]

i = [3,1]

..

l = [3,4]

m = [4,1]

..

p = [4,4]

 

 

ex:

[row 1, column 1] = a + (signed short)A/0x10000

 

The matrix components are as follows:

Posted Image

 

Now, the bad news: This matrix is generated and modified each frame. You can't have it be static in an object file.

Link to comment
Share on other sites

  • 0

I figured this out and noticed this was never actually answered, so I'm gonna post it here:

 

DA Set Matrix
Format: [DA ss 00 tt bb oo oo oo]
ss - ((size_of_matrix_in_bytes - 1)/4) << 3
bb - bank matrix is stored in
oo - offset of matrix
tt - instruction/matrix type
MODELVIEW = 0x01 PROJECTION = 0x05
LOAD = 0x03 PUSH = 0x00

The matrix itself is always 4x4 in size and composed of half-floats (16-bit floats)

Link to comment
Share on other sites

  • 0

The matrix components are as follows:

Posted Image

 

I know I am probably going to run in to this sooner or later when/if I start on custom objects, so I may as well ask while this topic is still alive. I have no problem working with matrices from a mathematical perspective but I really don't understand how these are being used in terms of the object file/display list they are applied to. If anyone could give a proper explanation of what each component is for or point me to some more information then that would be really nice.

Link to comment
Share on other sites

  • 0

I know I am probably going to run in to this sooner or later when/if I start on custom objects, so I may as well ask while this topic is still alive. I have no problem working with matrices from a mathematical perspective but I really don't understand how these are being used in terms of the object file/display list they are applied to. If anyone could give a proper explanation of what each component is for or point me to some more information then that would be really nice.

 

They're DA instructions are used for multi-matrix transforms, (allowing vertices to be affected by more than 1 transformation matrix), which fills the joints between 2 display lists.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.