Network Protocol/RACEHEADER 2
< Network Protocol
Jump to navigation
Jump to search
Revision as of 22:24, 12 June 2015 by Leseratte (talk | contribs) (Created page with "This pages is related to MKWii Network Protocol and describes the record type '''RACEHEADER_2'''. Here is the record read function in GNU C notation. The function notatio...")
This pages is related to MKWii Network Protocol and describes the record type RACEHEADER_2.
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->item_size = src[ 0x007 ]; d->timer = be16(src+ 0x00a ); d->team = be16(src+ 0x012 ); d->vehicle[0] = src[ 0x016 ]; d->driver[0] = src[ 0x017 ]; d->vehicle[1] = src[ 0x018 ]; d->driver[1] = src[ 0x019 ]; d->track = src[ 0x01e ]; d->client_slot[0] = src[ 0x020 ]; d->client_slot[1] = src[ 0x021 ]; d->client_slot[2] = src[ 0x022 ]; d->client_slot[3] = src[ 0x023 ]; d->client_slot[4] = src[ 0x024 ]; d->client_slot[5] = src[ 0x025 ]; d->client_slot[6] = src[ 0x026 ]; d->client_slot[7] = src[ 0x027 ]; d->client_slot[8] = src[ 0x028 ]; d->client_slot[9] = src[ 0x029 ]; d->client_slot[10] = src[ 0x02a ]; d->client_slot[11] = src[ 0x02b ]; d->engine = src[ 0x02c ]; d->end_time[0] = be32(src+ 0x036 -1) >> 5 & 0x0007FFFFu; d->end_time[1] = be32(src+ 0x03a ) >> 6 & 0x0007FFFFu; d->player_idx[0] = src[ 0x040 ]; d->player_idx[1] = src[ 0x041 ]; d->finish_timer = be16(src+ 0x046 ); return 0x48; // last analyzed offset + 1 //------------------------------- // Reference Statistics //------------------------------- // bits : off-1 .. off-2 : usage //------------------------------- // 56 : 000.0 .. 006.7 : - // 8 : 007.0 .. 007.7 : 1 // 16 : 008.0 .. 009.7 : - // 16 : 00a.0 .. 00b.7 : 1 // 48 : 00c.0 .. 011.7 : - // 16 : 012.0 .. 013.7 : 1 // 16 : 014.0 .. 015.7 : - // 32 : 016.0 .. 019.7 : 1 // 32 : 01a.0 .. 01d.7 : - // 8 : 01e.0 .. 01e.7 : 1 // 8 : 01f.0 .. 01f.7 : - // 104 : 020.0 .. 02c.7 : 1 // 72 : 02d.0 .. 035.7 : - // 19 : 036.0 .. 038.2 : 1 // 20 : 038.3 .. 03a.6 : - // 19 : 03a.7 .. 03d.1 : 1 // 22 : 03d.2 .. 03f.7 : - // 16 : 040.0 .. 041.7 : 1 // 32 : 042.0 .. 045.7 : - // 16 : 046.0 .. 047.7 : 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 !------------------------------------------------------------------------------------------ u8 item_size - 07 0 8 ? complete length := 0xc0 + 'item_size' u16 *timer - 0a 0 16 racing time, 59.94 Hz u16 team - 12 0 16 not null: team bit field, 0=blue, 1=red u8 vehicle 2 - - - vehicle index of each user > vehicle[0] - 16 0 8 > vehicle[1] - 18 0 8 u8 driver 2 - - - driver index of each user > driver[0] - 17 0 8 > driver[1] - 19 0 8 u8 track - 1e 0 8 index of current track u8 client_slot 12 20 0 8 relation race_slot(index) : client slot (0xff=none) u8 engine - 2c 0 8 engine: 0:50cc, 1:100cc, 2:150cc, 3:mirror u32 *end_time 2 - - - the end time of each user, max. 63:59.999 > *end_time[0] - 36 0 19 > *end_time[1] - 3a 7 19 u8 player_idx 2 40 0 8 start index of both players u16 finish_timer - 46 0 16 time since leader finish, 59.94 Hz !------------------------------------------------------------------------------------------