gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Decoding a FIFO display list

#88814 - ikaris - Wed Jun 21, 2006 6:53 pm

Hi everyone,

I'd like to write an exporter for Maya to generate the .h directly.

(I know there's one for Max, but you have to copy and paste a TXT file, then run it through a processor...)

However, I have to say that the FIFO code is not as easy to understand as Immediate Mode rendering !

Can anyone translate this for me ? (its from the display list 1 example... which is crashing for me in Dualis 20.3... see my other post :) )

Code:
u32 triangle[] =
{
   12,
   FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR),
   GL_TRIANGLE,
   RGB15(31,0,0),
   VERTEX_PACK(inttov16(-1),inttov16(-1)), VERTEX_PACK(0,0),
   RGB15(0,31,0),
   FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END),
   VERTEX_PACK(inttov16(1),inttov16(-1)), VERTEX_PACK(0,0),
   RGB15(0,0,31),
   VERTEX_PACK(inttov16(0),inttov16(1)), VERTEX_PACK(0,0),
};


I understand that first there's a "FIFO_COMMAND_PACK" that contains the data it will be expecting (i.e. the first one is expecting to begin, get some color info, then vertex position info, then color info again).

However, the sequence and why its looking for color twice and vertex position data once before moving onto the next pack is beyond me !

Can anyone clear this one up ?

I've seen this post:

http://forum.gbadev.org/viewtopic.php?t=9830

but it really didn't clear it up for me any more...

Thanks !

#88817 - Mighty Max - Wed Jun 21, 2006 7:18 pm

You want to send 4 commandparts. each set of commands takes the command info (the PACK) and the parameters to each part of that pack. Thats 4 possible subcommands.

The original code would do

glBegin,
glColor,glVertex
glColor,glVertex
glColor,glVertex
glEnd

Which are 8 commands and have to be devided into 2 packs. with the cut at the 2nd color/vertex pair

At least thats what i understand it from the code snipset
_________________
GBAMP Multiboot

#88819 - ikaris - Wed Jun 21, 2006 7:28 pm

OK that clears things up a tiny bit...

so:

- the FIFO_COMMAND_PACK command can have up to four elements inside the brackets ()... the first should have FIFO_BEGIN and the last should have FIFO_END at the end...

- possible commands are: FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_END

- possible commands INSIDE each pack are: RGB15(), VERTEX_PACK

However, one question still remains:

How does the VERTEX_PACK work ?

Here is JUST the VERTEX_PACK commands:

Code:

VERTEX_PACK(inttov16(-1),inttov16(-1)),
VERTEX_PACK(0,0),

VERTEX_PACK(inttov16(1),inttov16(-1)),
VERTEX_PACK(0,0),

VERTEX_PACK(inttov16(0),inttov16(1)),
VERTEX_PACK(0,0),


These obviously make up the three triangles... however, why are there 4 numbers for each, instead of 3 ? Why are there TWO commands instead of one per vertex ? Shouldn't each represent an XYZ value ?

Also, why do some numbers need to have inttov16 and others do not ?

#88836 - Mighty Max - Wed Jun 21, 2006 8:38 pm

The vertex needs to send 3 data chunks(the components), yes. Each coordinate needs 16 bits to encode, so that 2 components pack into one 32bit word. The second command is to pad the 3rd component into the second 32bit word passed.

The triangle rendered in your example is obvious flat, so that the last component is 0, and as inttov16(0)==0 this conversation is dropped.

It should be VERTEX_PACK(x,y) , VERTEX_PACK(z,0)
_________________
GBAMP Multiboot

#88844 - ikaris - Wed Jun 21, 2006 9:02 pm

Thanks a bunch !

One last question: What if the amount of data is not a perfect multiple of 4 ?

I'll post the Maya converter (for those interested) once its done, now that I understand the format better !

#88867 - ikaris - Wed Jun 21, 2006 11:06 pm

To answer my own question:

It looks like the "FIFO_NOP" command is used when there's no elements in side a FIFO_COMMAND_PACK

For example, this pack only has two elements... a texture coordinates command and a vertex command... so FIFO_NOP is used for the other two.

Code:

FIFO_COMMAND_PACK(FIFO_TEX_COORD, FIFO_VERTEX16, FIFO_NOP,FIFO_NOP),
TEXTURE_PACK(floatot16(0.000000),floatot16(0.000000)),
VERTEX_PACK(floatov16(10.000000),floatov16(0.000000)),VERTEX_PACK(floatov16(10.000000),0),