GIF packet questions
Posted: Sun May 29, 2005 7:49 am
I just finished manually disassembing the setupscr structure in debug-scr_printf-init_scr. Boy, there is nothing better for learning than doing it the hard way.
My first question is, how can this packet structure be 16 bit aligned and still work when the doc's say GIF packets must be 128 bit aligned?
static struct t_setupscr setupscr __attribute__ (( aligned (16) )) = {
{ 0x100000000000800E, 0xE, 0xA0000, 0x4C, 0x8C, 0x4E },
{ 27648, 30976 },
{ 0x18 },
{ 0, 639, 0, 223 },
{ 0x40, 1, 0x1a, 1, 0x46, 0, 0x45, 0x70000,
0x47, 0x30000, 0x47, 6, 0, 0x3F80000000000000, 1, 0x79006C00, 5,
0x87009400, 5, 0x70000, 0x47 }
};
Next, in the packet and graph library why do we load by u64's?
#define GIF_SET_FRAME(A,B,C,D) \
(u64)((A) & 0x000001FF) << 0 | (u64)((B) & 0x0000003F) << 16 | \
(u64)((C) & 0x0000003F) << 24 | (u64)((D) & 0xFFFFFFFF) << 32
#define GIF_REG_FRAME_1 0x4C // Frame buffer setting. (Context 1)
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
Why not:
#define GIF_SET_FRAME_1(A,B,C,D) \
(u64)((A) & 0x000001FF) << 0 | (u64)((B) & 0x0000003F) << 16 | \
(u64)((C) & 0x0000003F) << 24 | (u64)((D) & 0xFFFFFFFF) << 32 | \
(u8)((0x4c) << 64
packet_append_128(&graph_packet, GIF_SET_FRAME_1(address >> 13, graph_get_width() >> 6, current_psm, 0));
And regarding PACKED Mode, how come all the examples are as follows:
// Set up the draw buffer.
packet_append_64(&graph_packet, GIF_SET_TAG(5, 1, 0, 0, GIF_TAG_PACKED, 1));
packet_append_64(&graph_packet, 0x0E);
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
packet_append_64(&graph_packet, GIF_SET_SCISSOR(0, graph_get_width() - 1, 0, graph_get_height() - 1));
packet_append_64(&graph_packet, GIF_REG_SCISSOR_1);
packet_append_64(&graph_packet, GIF_SET_TEST(0, 0, 0, 0, 0, 0, 1, 2));
packet_append_64(&graph_packet, GIF_REG_TEST_1);
packet_append_64(&graph_packet, GIF_SET_XYOFFSET((2048 - (graph_get_width() >> 1)) << 4, (2048 - (graph_get_height() >> 1)) << 4));
packet_append_64(&graph_packet, GIF_REG_XYOFFSET_1);
packet_append_64(&graph_packet, GIF_SET_PRMODECONT(1));
packet_append_64(&graph_packet, GIF_REG_PRMODECONT);
Instead of:
// Set up the draw buffer.
packet_append_64(&graph_packet, GIF_SET_TAG(5, 1, 0, 0, GIF_TAG_PACKED, 1));
packet_append_64(&graph_packet, GIF_REG_PRMODECONT|GIF_REG_XYOFFSET_1|GIF_REG_TEST_1|GIF_REG_SCISSOR_1|GIF_REG_FRAME_1);
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_SET_SCISSOR(0, graph_get_width() - 1, 0, graph_get_height() - 1));
packet_append_64(&graph_packet, GIF_SET_TEST(0, 0, 0, 0, 0, 0, 1, 2));
packet_append_64(&graph_packet, GIF_SET_XYOFFSET((2048 - (graph_get_width() >> 1)) << 4, (2048 - (graph_get_height() >> 1)) << 4));
packet_append_64(&graph_packet, GIF_SET_PRMODECONT(1));
Isn't this a better format for conserving memory space and improving transfer speed?
And the last question, with the GIF defines, i.e., GIF_REG_FRAME_1 there is a // comment character followed by the comment. Later in the packet_append the preprocessor symbol is referenced as an argument.
#define GIF_REG_FRAME_1 0x4C // Frame buffer setting. (Context 1)
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
Shouldn't this be preprocessed as:
packet_append_64(&graph_packet, 0x4C // Frame buffer setting. (Context 1));
And cause a compiler error?
Mucha apreciaciĆ³n!
My first question is, how can this packet structure be 16 bit aligned and still work when the doc's say GIF packets must be 128 bit aligned?
static struct t_setupscr setupscr __attribute__ (( aligned (16) )) = {
{ 0x100000000000800E, 0xE, 0xA0000, 0x4C, 0x8C, 0x4E },
{ 27648, 30976 },
{ 0x18 },
{ 0, 639, 0, 223 },
{ 0x40, 1, 0x1a, 1, 0x46, 0, 0x45, 0x70000,
0x47, 0x30000, 0x47, 6, 0, 0x3F80000000000000, 1, 0x79006C00, 5,
0x87009400, 5, 0x70000, 0x47 }
};
Next, in the packet and graph library why do we load by u64's?
#define GIF_SET_FRAME(A,B,C,D) \
(u64)((A) & 0x000001FF) << 0 | (u64)((B) & 0x0000003F) << 16 | \
(u64)((C) & 0x0000003F) << 24 | (u64)((D) & 0xFFFFFFFF) << 32
#define GIF_REG_FRAME_1 0x4C // Frame buffer setting. (Context 1)
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
Why not:
#define GIF_SET_FRAME_1(A,B,C,D) \
(u64)((A) & 0x000001FF) << 0 | (u64)((B) & 0x0000003F) << 16 | \
(u64)((C) & 0x0000003F) << 24 | (u64)((D) & 0xFFFFFFFF) << 32 | \
(u8)((0x4c) << 64
packet_append_128(&graph_packet, GIF_SET_FRAME_1(address >> 13, graph_get_width() >> 6, current_psm, 0));
And regarding PACKED Mode, how come all the examples are as follows:
// Set up the draw buffer.
packet_append_64(&graph_packet, GIF_SET_TAG(5, 1, 0, 0, GIF_TAG_PACKED, 1));
packet_append_64(&graph_packet, 0x0E);
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
packet_append_64(&graph_packet, GIF_SET_SCISSOR(0, graph_get_width() - 1, 0, graph_get_height() - 1));
packet_append_64(&graph_packet, GIF_REG_SCISSOR_1);
packet_append_64(&graph_packet, GIF_SET_TEST(0, 0, 0, 0, 0, 0, 1, 2));
packet_append_64(&graph_packet, GIF_REG_TEST_1);
packet_append_64(&graph_packet, GIF_SET_XYOFFSET((2048 - (graph_get_width() >> 1)) << 4, (2048 - (graph_get_height() >> 1)) << 4));
packet_append_64(&graph_packet, GIF_REG_XYOFFSET_1);
packet_append_64(&graph_packet, GIF_SET_PRMODECONT(1));
packet_append_64(&graph_packet, GIF_REG_PRMODECONT);
Instead of:
// Set up the draw buffer.
packet_append_64(&graph_packet, GIF_SET_TAG(5, 1, 0, 0, GIF_TAG_PACKED, 1));
packet_append_64(&graph_packet, GIF_REG_PRMODECONT|GIF_REG_XYOFFSET_1|GIF_REG_TEST_1|GIF_REG_SCISSOR_1|GIF_REG_FRAME_1);
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_SET_SCISSOR(0, graph_get_width() - 1, 0, graph_get_height() - 1));
packet_append_64(&graph_packet, GIF_SET_TEST(0, 0, 0, 0, 0, 0, 1, 2));
packet_append_64(&graph_packet, GIF_SET_XYOFFSET((2048 - (graph_get_width() >> 1)) << 4, (2048 - (graph_get_height() >> 1)) << 4));
packet_append_64(&graph_packet, GIF_SET_PRMODECONT(1));
Isn't this a better format for conserving memory space and improving transfer speed?
And the last question, with the GIF defines, i.e., GIF_REG_FRAME_1 there is a // comment character followed by the comment. Later in the packet_append the preprocessor symbol is referenced as an argument.
#define GIF_REG_FRAME_1 0x4C // Frame buffer setting. (Context 1)
packet_append_64(&graph_packet, GIF_SET_FRAME(address >> 13, graph_get_width() >> 6, current_psm, 0));
packet_append_64(&graph_packet, GIF_REG_FRAME_1);
Shouldn't this be preprocessed as:
packet_append_64(&graph_packet, 0x4C // Frame buffer setting. (Context 1));
And cause a compiler error?
Mucha apreciaciĆ³n!