예제 #1
0
파일: immediate.c 프로젝트: mtheall/citro3d
void C3D_ImmSendAttrib(float x, float y, float z, float w)
{
	union
	{
		u32 packed[3];
		struct
		{
			u8 x[3];
			u8 y[3];
			u8 z[3];
			u8 w[3];
		};
	} param;

	// Convert the values to float24
	write24(param.x, f32tof24(x));
	write24(param.y, f32tof24(y));
	write24(param.z, f32tof24(z));
	write24(param.w, f32tof24(w));

	// Reverse the packed words
	u32 p = param.packed[0];
	param.packed[0] = param.packed[2];
	param.packed[2] = p;

	// Send the attribute
	GPUCMD_AddIncrementalWrites(GPUREG_FIXEDATTRIB_DATA0, param.packed, 3);
}
static u_char *write_audio_packet(u_char *buf, int prefix, uint32_t timestamp,
                                      const void *data, uint32_t size) {
    *buf = 8;
    write24(buf + 1, size + 2);
    write24(buf + 4, timestamp % 0x1000000);
    buf[7] = (timestamp / 0x1000000) & 0xff;
    buf[8] = buf[9] = buf[10] = 0;
    buf[11] = 0xaf;
    buf[12] = prefix ? 0 : 1;
    memcpy(buf + 13, data, size);
    write32(buf + 13 + size, size + 2 + 11);
    return buf + 13 + size + 4;
}
static u_char *write_video_packet(u_char *buf, int keyframe, int prefix, uint32_t comp_offset,
                                uint32_t timestamp,
                                const void *data, uint32_t size) {
    *buf = 9;
    write24(buf + 1, size + 5);
    write24(buf + 4, timestamp % 0x1000000);
    buf[7] = (timestamp / 0x1000000) & 0xff;
    buf[8] = buf[9] = buf[10] = 0;
    buf[11] = (prefix || keyframe) ? 0x17 : 0x27;
    buf[12] = prefix ? 0 : 1;
    write24(buf + 13, comp_offset);
    memcpy(buf + 16, data, size);
    write32(buf + 16 + size, size + 5 + 11);
    return buf + 16 + size + 4;
}
static void write32(u_char *buf, uint32_t value) {
    buf[0] = value / 0x1000000;
    write24(buf + 1, value);
}