Network Protocol/RACEDATA

From Custom Mario Kart
< Network Protocol
Revision as of 11:13, 3 May 2013 by Wiimm (talk | contribs) (Created page with "This pages is related to MKWii Network Protocol and describes the record type '''RACEDATA'''. RACEDATA records contain the player specific race data of a client. Dependin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This pages is related to MKWii Network Protocol and describes the record type RACEDATA.

RACEDATA records contain the player specific race data of a client. Depending on the number of player on a Wii, one or two records are send. The RACEDATA records follow immediately the RACE record with general racing information.

Here is the record read function in GNU C notation. The function notation is used, because some values are bit packed. This code was created by a code generator.

    d->pos[0]		= be32(src+ 0x000 )   >> 4 & 0x0FFFFFFFu;
    d->pos[1]		= be32(src+ 0x003 )        & 0x0FFFFFFFu;
    d->pos[2]		= be32(src+ 0x007 )   >> 4 & 0x0FFFFFFFu;
    d->drift		=      src[ 0x032 ]   >> 6 &       0x03u;
    d->already_drifted	=      src[ 0x032 ]   >> 4 &       0x01u;
    d->rank		= be16(src+ 0x032 )   >> 7 &     0x000Fu;

    return 0x34; // last analyzed offset + 1

    //-------------------------------
    //     Reference Statistics
    //-------------------------------
    // bits : off-1 .. off-2 : usage
    //-------------------------------
    //   84 : 000.0 .. 00a.3 :   1
    //  316 : 00a.4 .. 031.7 :   -
    //    2 : 032.0 .. 032.1 :   1
    //    1 : 032.2 .. 032.2 :   -
    //    1 : 032.3 .. 032.3 :   1
    //    1 : 032.4 .. 032.4 :   -
    //    4 : 032.5 .. 033.0 :   1
    //-------------------------------

And here the code of a self written code generator script. The script creates data structures and the read function above. The byte offset is hex, all others are decimal numbers.

 !--------------------------------------------------------------------------------------
 !                        byte+bit
 ! type	name		 N offset bits	comment
 !--------------------------------------------------------------------------------------
   s32	pos		 3   0  0 28	x+y+z positions in 1/16 units, 0x9f42783 is 0.0
   u8	drift		 -  32  0  2	0:no drift, 1:drift, 2:blue, 3:yellow
   u8	already_drifted	 -  32  3  1	1: driver has drived at least once
   u8	rank		 -  32  5  4	rank in race
 !--------------------------------------------------------------------------------------


Template:MKWii Network Protocol