Filesystem/rel/StaticR.rel

From Custom Mario Kart
Jump to navigation Jump to search

The file StaticR.rel is the only file in directory /rel and contains much data for the Mario Kart Wii. All 4 known versions (PAL, NTSC, NTSC/J and KOREA) differ in size and content. All data is stored as big endian values. It is very hard to find things in StaticR.rel, because it seems to be an exported data section of a dol: It has no structure but the related dol knows where the data is stored.


Track Order Tables

There are 5 copies of the track assigning tables in the file. The tables consists of 32 32-bit numbers. Each value from 0 to 31 (0x1f) is used exactly once.

File offsets of the 5 tables
Table file offsets Comments
PAL NTSC NTSC/J KOREA
1 0x37fcd0 0x37fbe0 0x37f9a0 0x3800b0 Staff Ghost Data order (unsure)
2 0x384f58 0x3839e0 0x384c28 0x385348 ?
3 0x397da8 0x397450 0x397588 0x3981e8 Used for track selection and racing.
4 0x398130 0x3977d8 0x397910 0x398570 Used for cup selection.
5 0x39d040 0x39b300 0x39c820 0x39d480 ?
  • The comments are based on tests with the PAL version.
  • The standard setting is: 8,1,2,4, 0,5,6,7, 9,15,11,3, 14,10,12,13, 16,20,25,26, 27,31,23,18, 21,30,29,17, 24,22,19,28
  • In the BMG message files the track names are stored beginning from message IDs (MID) 0x2454 and 0x2490. Add the slot value to find the specific messages.

The following table shows the native order (not reordered by the above tables) of all tracks and the corresponding file names:

      std  file name            sound standard      fast sound  track track
 idx slot  of track             slot  sound file name   f.name  abbr. name
----------------------------------------------------------------------------------------------
  8.  1.1  beginner_course      0x7d  n_Circuit32_n         _f  LC    Luigi Circuit
  1.  1.2  farm_course          0x77  n_Farm_n              _F  MMM   Moo Moo Meadows
  2.  1.3  kinoko_course        0x79  n_Kinoko_n            _F  MG    Mushroom Gorge
  4.  1.4  factory_course       0x7b  STRM_N_FACTORY_N      _F  TF    Toad's Factory
----------------------------------------------------------------------------------------------
  0.  2.1  castle_course        0x7d  n_Circuit32_n         _f  MC    Mario Circuit
  5.  2.2  shopping_course      0x7f  n_Shopping32_n        _f  CM    Coconut Mall
  6.  2.3  boardcross_course    0x81  n_Snowboard32_n       _F  DKS   DK Summit
  7.  2.4  truck_course         0x83  STRM_N_TRUCK_N        _F  WGM   Wario's Gold Mine
----------------------------------------------------------------------------------------------
  9.  3.1  senior_course        0x87  n_Daisy32_n           _f  DC    Daisy Circuit
 15.  3.2  water_course         0x85  STRM_N_WATER_N        _F  KC    Koopa Cape
 11.  3.3  treehouse_course     0x8f  n_maple_n             _F  MT    Maple Treeway
  3.  3.4  volcano_course       0x8b  n_Volcano32_n         _f  GV    Grumble Volcano
----------------------------------------------------------------------------------------------
 14.  4.1  desert_course        0x89  STRM_N_DESERT_N       _F  DDR   Dry Dry Ruins
 10.  4.2  ridgehighway_course  0x8d  STRM_N_RIDGEHIGHWAY_N _F  MH    Moonview Highway
 12.  4.3  koopa_course         0x91  STRM_N_KOOPA_N        _F  BC    Bowser's Castle
 13.  4.4  rainbow_course       0x93  n_Rainbow32_n         _f  RR    Rainbow Road
----------------------------------------------------------------------------------------------
 16.  5.1  old_peach_gc         0xa5  r_GC_Beach32_n        _f  gPB   GCN Peach Beach
 20.  5.2  old_falls_ds         0xad  r_DS_Jungle32_n       _f  dYF   DS Yoshi Falls
 25.  5.3  old_obake_sfc        0x97  r_SFC_Obake32_n       _f  sGV2  SNES Ghost Valley 2
 26.  5.4  old_mario_64         0x9f  r_64_Circuit32_n      _f  nMR   N64 Mario Raceway
----------------------------------------------------------------------------------------------
 27.  6.1  old_sherbet_64       0x9d  r_64_Sherbet32_n      _f  nSL   N64 Sherbet Land
 31.  6.2  old_heyho_gba        0x95  r_AGB_Beach32_n       _f  gSGB  GBA Shy Guy Beach
 23.  6.3  old_town_ds          0xaf  r_DS_Town32_n         _f  dDS   DS Delfino Square
 18.  6.4  old_waluigi_gc       0xa9  r_GC_Stadium32_n      _f  gWS   GCN Waluigi Stadium
----------------------------------------------------------------------------------------------
 21.  7.1  old_desert_ds        0xb1  r_DS_Desert32_n       _f  dDH   DS Desert Hills
 30.  7.2  old_koopa_gba        0x9b  r_AGB_Kuppa32_n       _f  gBC3  GBA Bowser Castle 3
 29.  7.3  old_donkey_64        0xa1  r_64_Jungle32_n       _f  nDKJP N64 DK's Jungle Parkway
 17.  7.4  old_mario_gc         0xa7  r_GC_Circuit32_n      _f  gMC   GCN Mario Circuit
----------------------------------------------------------------------------------------------
 24.  8.1  old_mario_sfc        0x99  r_SFC_Circuit32_n     _f  sMC3  SNES Mario Circuit 3
 22.  8.2  old_garden_ds        0xb3  r_DS_Garden32_n       _f  dPG   DS Peach Gardens
 19.  8.3  old_donkey_gc        0xab  r_GC_Mountain32_n     _f  gDKM  GCN DK Mountain
 28.  8.4  old_koopa_64         0xa3  r_64_Kuppa32_n        _f  nBC   N64 Bowser's Castle
----------------------------------------------------------------------------------------------

Changing the order allows to move Special Slots to other places. The following command of Wiimms SZS Tools may change the track order:

wstrt patch StaticR.rel --tracks=LIST[1]

Arena Order Tables

There are 4 copies of the track assigning tables in the file. The tables consists of 10 32-bit numbers. Each value from 32 (0x20) to 41 (0x29) is used exactly once.

File offsets of the 4 tables
Table file offsets Comments
PAL NTSC NTSC/J KOREA
1 0x384fd8 0x383a60 0x384ca8 0x3853c8 ?
2 0x3974f8 0x39d130 0x396cd8 0x397938 Used for cup selection.
3 0x397780 0x39d3b8 0x396f60 0x397bc0 Used for track selection and racing.
4 0x39c8e0 0x39e988 0x39c0c0 0x39cd20 ?
  • The comments are based on tests with the PAL version.
  • The standard setting is: 0x21,0x20,0x23,0x22,0x24, 0x27,0x28,0x29,0x25,0x26
  • In the BMG message files the arena names are stored beginning from message IDs (MID) 0x24b8 and 0x24cc. Add the slot value and subtract 0x20 to find the specific messages.

The following table shows the native order (not reordered by the above tables) of all arenas and the corresponding file names. Add 0x20 to the index to find the value for the assigning tables:

      std  file name          sound standard    + fast  arena arena
 idx slot  of arena           slot  sound file name     abbr. name
-----------------------------------------------------------------------------------
  1.  1.1  block_battle       0xb7  n_block_n       _F  aBP   Block Plaza
  0.  1.2  venice_battle      0xb5  n_venice_n      _F  aDP   Delfino Pier
  3.  1.3  skate_battle       0xb9  n_skate_n       _F  aFS   Funky Stadium
  2.  1.4  casino_battle      0xbb  n_casino_n      _F  aCCW  Chain Chomp Wheel
  4.  1.5  sand_battle        0xbd  n_ryuusa_n      _F  aTD   Thwomp Desert
-----------------------------------------------------------------------------------
  7.  2.1  old_battle4_sfc    0xc3  r_sfc_battle_n  _F  asBC4 SNES Battle Course 4
  8.  2.2  old_battle3_gba    0xc5  r_agb_battle_n  _F  agBC3 GBA Battle Course 3
  9.  2.3  old_matenro_64     0xc7  r_64_battle_n   _F  anSS  N64 Skyscraper
  5.  2.4  old_CookieLand_gc  0xbf  r_GC_Battle32_n _F  agCL  GCN Cookie Land
  6.  2.5  old_House_ds       0xc1  r_ds_battle_n   _F  adTH  DS Twilight House
-----------------------------------------------------------------------------------

The following command of Wiimms SZS Tools may change the track order:

wstrt patch StaticR.rel --arenas=LIST[2]

Searching players for online gaming

If MKWii searches players worldwide or in regions for online gaming, it creates some text queries. These queries looks like a WHERE clause of SQL queries.

If analyzing the online communication, you can find for example the following condition string:

... and (rk = 'vs_21' and ev >= 5215 and ev <= 8215 and p = 0)
  • vs_21 is the region name (playing in region 21).
  • At this point I had 6715 points. The Wii builds a range from 6715-1500 up to 6715+1500 and search players within this range.

In StaticR.rel you can find the following string twice (1 for racing, 1 for battle):

%s >= %d and %s <= %d

If replacing the string by another one with the same number of characters ...

(%s > %d or %s <= %d)

... the above query becomes:

... and (rk = 'vs_21' and (ev > 5215 or ev <= 8215) and p = 0)

And now the inner part of the condition is always true, so that all players independent of their ranking points will be found.

The following command of Wiimms SZS Tools will exactly patch a StaticR.rel file in the described way:

wstrt patch StaticR.rel --all-ranks[3]
File offsets of the query strings
Info File Offsets
PAL NTSC/USA NTSC/JAP KOREA
First string 0x389f36 0x389be6 0x389716 0x38a34e
Second string 0x389f52 0x389c02 0x389732 0x38a36a

Change color of HUD

The color of the Head-up display in races can be changed at the following offsets:

File offsets of the HUD-data
PAL NTSC/USA NTSC/JAP KOREA
0x399346 0x397F9E 0x398B26 0x399786

The next 4 bytes are the main color, the next 18 bytes (4+14) may describe the color of the parts in detail.

Change color of region line

In online-races, every player has a colored line under his name, pointing to his kart/bike. The color of this line is region-dependant and can be changed at the following offsets:

Region line color
PAL NTSC/USA NTSC/JAP KOREA
0x399B13 0x39856C 0x3992F3 0x399F50

The definition is 48 bytes long, each group of 4 bytes describes the color for one region in RGBA format. The original colors are the following:

Offset Usage Default Color
0x00 Unknown 3F333333 : grey, transparent
0x04 Player 1 E61414FF : red team
0x08 Player 2 0078DCFF : blue team
0x0c Japan FF0000FF : red
0x10 North America 0000FFFF : blue
0x14 Europe 00FF00FF : green
0x18 Australia FFFF00FF : yellow
0x1c Korea FF00FFFF : magenta
0x20 Nintendo 000000FF : black
0x24 Unknown FFFFFFFF : white
0x28 Unknown 3F000000 : dark red, invisible
0x2c Unknown 00000000 : black, invisible

References